code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
use List::Util qw(sum min); $source = <<'END'; ............................................................ .. .. .. .. .... .... .... .... .... .... .... .... .. .. .. .. ............................................................ END for $line (split "\n", $source) { push @lines, [map { 1 & ord $_ } split '', ...
15Zhang-Suen thinning algorithm
2perl
rngd
use std::cmp::Ordering; use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign, Neg}; fn gcd(a: i64, b: i64) -> i64 { match b { 0 => a, _ => gcd(b, a% b), } } fn lcm(a: i64, b: i64) -> i64 { a / gcd(a, b) * b } #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord)]...
8Arithmetic/Rational
15rust
ci9z
> Math.pow(0, 0); 1
14Zero to the zero power
10javascript
meyv
class Rational(n: Long, d:Long) extends Ordered[Rational] { require(d!=0) private val g:Long = gcd(n, d) val numerator:Long = n/g val denominator:Long = d/g def this(n:Long)=this(n,1) def +(that:Rational):Rational=new Rational( numerator*that.denominator + that.numerator*denominator, den...
8Arithmetic/Rational
16scala
vf2s
package main import ( "fmt" "log" "os/exec" ) func gcd(x, y int) int { for y != 0 { x, y = y, x%y } return x } func yellowstone(n int) []int { m := make(map[int]bool) a := make([]int, n+1) for i := 1; i < 4; i++ { a[i] = i m[i] = true } min := 4 ...
20Yellowstone sequence
0go
mhyi
import scala.collection.mutable.ListBuffer object ZeckendorfArithmetic extends App { val elapsed: (=> Unit) => Long = f => { val s = System.currentTimeMillis f (System.currentTimeMillis - s) / 1000 } val add: (Z, Z) => Z = (z1, z2) => z1 + z2 val subtract: (Z, Z) => Z = (z1, z2) => z1 - z2 va...
17Zeckendorf arithmetic
16scala
btk6
from sympy import divisors from sympy.combinatorics.subsets import Subset def isZumkeller(n): d = divisors(n) s = sum(d) if not s% 2 and max(d) <= s/2: for x in range(1, 2**len(d)): if sum(Subset.unrank_binary(x, d).subset) == s/2: return True return False def p...
19Zumkeller numbers
3python
1tpc
beforeTxt = '''\ 1100111 1100111 1100111 1100111 1100110 1100110 1100110 1100110 1100110 1100110 1100110 1100110 1111110 0000000\ ''' smallrc01 = '''\ 00000000000000000000000000000000 01111111110000000111111110000000 01110001111000001111001111000000 01110000111000001110000111000000 01110001111000001110000000000000 01...
15Zhang-Suen thinning algorithm
3python
7drm
package main import "fmt" func main() { for i := 0; i <= 20; i++ { fmt.Printf("%2d%7b\n", i, zeckendorf(i)) } } func zeckendorf(n int) int {
16Zeckendorf number representation
0go
i4og
>>> z1 = 1.5 + 3j >>> z2 = 1.5 + 1.5j >>> z1 + z2 (3+4.5j) >>> z1 - z2 1.5j >>> z1 * z2 (-2.25+6.75j) >>> z1 / z2 (1.5+0.5j) >>> - z1 (-1.5-3j) >>> z1.conjugate() (1.5-3j) >>> abs(z1) 3.3541019662496847 >>> z1 ** z2 (-1.1024829553277784-0.38306415117199333j) >>> z1.real 1.5 >>> z1.imag 3.0 >>>
9Arithmetic/Complex
3python
d1n1
null
14Zero to the zero power
11kotlin
og8z
import Data.List (unfoldr) yellowstone :: [Integer] yellowstone = 1: 2: 3: unfoldr (Just . f) (2, 3, [4 ..]) where f :: (Integer, Integer, [Integer]) -> (Integer, (Integer, Integer, [Integer])) f (p2, p1, rest) = (next, (p1, next, rest_)) where (next, rest_) = select rest se...
20Yellowstone sequence
8haskell
kih0
package main import ( "fmt" "golang.org/x/net/html" "io/ioutil" "net/http" "regexp" "strings" ) var ( expr = `<h3 class="title"><a class=.*?href="(.*?)".*?>(.*?)</a></h3>` + `.*?<div class="compText aAbs" ><p class=.*?>(.*?)</p></div>` rx = regexp.MustCompile(expr) ) type Yaho...
22Yahoo! search interface
0go
s6qa
import Data.Bits import Numeric zeckendorf = map b $ filter ones [0..] where ones :: Int -> Bool ones x = 0 == x .&. (x `shiftR` 1) b x = showIntAtBase 2 ("01"!!) x "" main = mapM_ putStrLn $ take 21 zeckendorf
16Zeckendorf number representation
8haskell
vq2k
z1 <- 1.5 + 3i z2 <- 1.5 + 1.5i print(z1 + z2) print(z1 - z2) print(z1 * z2) print(z1 / z2) print(-z1) print(Conj(z1)) print(abs(z1)) print(z1^z2) print(exp(z1)) print(Re(z1)) print(Im(z1))
9Arithmetic/Complex
13r
8h0x
import java.util.ArrayList; import java.util.List; public class YellowstoneSequence { public static void main(String[] args) { System.out.printf("First 30 values in the yellowstone sequence:%n%s%n", yellowstoneSequence(30)); } private static List<Integer> yellowstoneSequence(int sequenceCount) {...
20Yellowstone sequence
9java
4x58
import Network.HTTP import Text.Parsec data YahooSearchItem = YahooSearchItem { itemUrl, itemTitle, itemContent :: String } data YahooSearch = YahooSearch { searchQuery :: String, searchPage :: Int, searchItems :: [YahooSearchItem] } yahooUrl = "http://search.yahoo.com/search?p=" yahoo :: String -...
22Yahoo! search interface
8haskell
9jmo
print(0^0)
14Zero to the zero power
1lua
irot
(() => { 'use strict';
20Yellowstone sequence
10javascript
hojh
class Integer def divisors res = [1, self] (2..Integer.sqrt(self)).each do |n| div, mod = divmod(n) res << n << div if mod.zero? end res.uniq.sort end def zumkeller? divs = divisors sum = divs.sum return false unless sum.even? && sum >= self*2 half = sum / 2 max_...
19Zumkeller numbers
14ruby
e3ax
class ZhangSuen NEIGHBOUR8 = [[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1]] CIRCULARS = NEIGHBOUR8 + [NEIGHBOUR8.first] def initialize(str, black=) s1 = str.each_line.map{|line| line.chomp.each_char.map{|c| c==black? 1: 0}} s2 = s1.map{|line| line.map{0}} xrange = 1 ....
15Zhang-Suen thinning algorithm
14ruby
htjx
import java.util.*; class Zeckendorf { public static String getZeckendorf(int n) { if (n == 0) return "0"; List<Integer> fibNumbers = new ArrayList<Integer>(); fibNumbers.add(1); int nextFib = 2; while (nextFib <= n) { fibNumbers.add(nextFib); nextFib += fibNumbers.get(fib...
16Zeckendorf number representation
9java
yp6g
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.regex.M...
22Yahoo! search interface
9java
tuf9
use std::convert::TryInto;
19Zumkeller numbers
15rust
w6e4
package main import ( "fmt" "math/big" ) func main() { x := big.NewInt(2) x = x.Exp(big.NewInt(3), x, nil) x = x.Exp(big.NewInt(4), x, nil) x = x.Exp(big.NewInt(5), x, nil) str := x.String() fmt.Printf("5^(4^(3^2)) has%d digits:%s ...%s\n", len(str), str[:20], str[len(str)-20:], ) }
18Arbitrary-precision integers (included)
0go
r8gm
(() => { 'use strict'; const main = () => unlines( map(n => concat(zeckendorf(n)), enumFromTo(0, 20) ) );
16Zeckendorf number representation
10javascript
2xlr
(defn doors [] (let [doors (into-array (repeat 100 false))] (doseq [pass (range 1 101) i (range (dec pass) 100 pass) ] (aset doors i (not (aget doors i)))) doors)) (defn open-doors [] (for [[d n] (map vector (doors) (iterate inc 1)):when d] n)) (defn print-open-doors [] (print...
21100 doors
6clojure
z4tj
xmlDocPtr getdoc (char *docname) { xmlDocPtr doc; doc = xmlParseFile(docname); return doc; } xmlXPathObjectPtr getnodeset (xmlDocPtr doc, xmlChar *xpath){ xmlXPathContextPtr context; xmlXPathObjectPtr result; context = xmlXPathNewContext(doc); result = xmlXPathEvalExpression(xpath, context); xmlXPathFreeCo...
23XML/XPath
5c
97m1
fun main() { println("First 30 values in the yellowstone sequence:") println(yellowstoneSequence(30)) } private fun yellowstoneSequence(sequenceCount: Int): List<Int> { val yellowstoneList = mutableListOf(1, 2, 3) var num = 4 val notYellowstoneList = mutableListOf<Int>() var yellowSize = 3 ...
20Yellowstone sequence
11kotlin
lpcp
null
22Yahoo! search interface
11kotlin
o98z
import Foundation extension BinaryInteger { @inlinable public var isZumkeller: Bool { let divs = factors(sorted: false) let sum = divs.reduce(0, +) guard sum & 1!= 1 else { return false } guard self & 1!= 1 else { let abundance = sum - 2*self return abundance > 0 && abundan...
19Zumkeller numbers
17swift
az1i
def bigNumber = 5G ** (4 ** (3 ** 2))
18Arbitrary-precision integers (included)
7groovy
vw28
main :: IO () main = do let y = show (5 ^ 4 ^ 3 ^ 2) let l = length y putStrLn ("5**4**3**2 = " ++ take 20 y ++ "..." ++ drop (l - 20) y ++ " and has " ++ show l ++ " digits")
18Arbitrary-precision integers (included)
8haskell
0ls7
import UIKit
15Zhang-Suen thinning algorithm
17swift
jf74
a = Complex(1, 1) i = Complex::I b = 3.14159 + 1.25 * i c = '1/2+3/4i'.to_c c = 1.0/2+3/4i puts a + b puts a * b puts -a puts 1.quo a puts a.conjugate puts a.conj
9Arithmetic/Complex
14ruby
tef2
import Foundation extension BinaryInteger { @inlinable public func gcd(with other: Self) -> Self { var gcd = self var b = other while b!= 0 { (gcd, b) = (b, gcd% b) } return gcd } @inlinable public func lcm(with other: Self) -> Self { let g = gcd(with: other) return self...
8Arithmetic/Rational
17swift
m8yk
enum HouseStatus { Invalid, Underfull, Valid }; enum Attrib { C, M, D, A, S }; enum Colors { Red, Green, White, Yellow, Blue }; enum Mans { English, Swede, Dane, German, Norwegian }; enum Drinks { Tea, Coffee, Milk, Beer, Water }; enum Animals { Dog, Birds, Cats, Horse, Zebra }; enum Smokes { PallMall, Dunhill, Blen...
24Zebra puzzle
5c
mgys
typedef struct func_t *func; typedef struct func_t { func (*fn) (func, func); func _; int num; } func_t; func new(func(*f)(func, func), func _) { func x = malloc(sizeof(func_t)); x->fn = f; x->_ = _; x->num = 0; return x; } func call(func f, func ...
25Y combinator
5c
4p5t
function gcd(a, b) if b == 0 then return a end return gcd(b, a % b) end function printArray(a) io.write('[') for i,v in pairs(a) do if i > 1 then io.write(', ') end io.write(v) end io.write(']') return nil end function removeAt(a, i) loca...
20Yellowstone sequence
1lua
21l3
null
16Zeckendorf number representation
11kotlin
f7do
extern crate num; use num::complex::Complex; fn main() {
9Arithmetic/Complex
15rust
zwto
package org.rosettacode package object ArithmeticComplex { val i = Complex(0, 1) implicit def fromDouble(d: Double) = Complex(d) implicit def fromInt(i: Int) = Complex(i.toDouble) } package ArithmeticComplex { case class Complex(real: Double = 0.0, imag: Double = 0.0) { def this(s: String) = thi...
9Arithmetic/Complex
16scala
ys63
use strict; use warnings; use feature 'say'; use List::Util qw(first); use GD::Graph::bars; use constant Inf => 1e5; sub gcd { my ($u, $v) = @_; while ($v) { ($u, $v) = ($v, $u % $v); } return abs($u); } sub yellowstone { my($terms) = @_; my @s = (1, 2, 3); my @used = (1) x 4; my $min ...
20Yellowstone sequence
2perl
qyx6
import java.math.BigInteger; class IntegerPower { public static void main(String[] args) { BigInteger power = BigInteger.valueOf(5).pow(BigInteger.valueOf(4).pow(BigInteger.valueOf(3).pow(2).intValueExact()).intValueExact()); String str = power.toString(); int len = str.length(); Sy...
18Arbitrary-precision integers (included)
9java
a31y
void draw_yinyang(int trans, double scale) { printf(, trans, trans, scale); } int main() { printf( ); draw_yinyang(20, .05); draw_yinyang(8, .02); printf(); return 0; }
26Yin and yang
5c
5kuk
int main(int c, char **v) { int i, j, m, n, *s; if (c < 2 || ((m = atoi(v[1]))) <= 0) m = 5; s = malloc(sizeof(int) * m * m); for (i = n = 0; i < m * 2; i++) for (j = (i < m) ? 0 : i-m+1; j <= i && j < m; j++) s[(i&1)? j*(m-1)+i : (i-j)*m+j ] = n++; for (i = 0; i < m * m; putchar((++i % m) ? ' ':'\n')...
27Zig-zag matrix
5c
qnxc
package YahooSearch; use Encode; use HTTP::Cookies; use WWW::Mechanize; sub apply (&$) {my $f = shift; local $_ = shift; $f->(); return $_;} my $search_prefs = 'v=1&n=100&sm=' . apply {s/([^a-zA-Z0-9])/sprintf '%%%02X', ord $1/ge} join '|', map {'!' . $_} qw(hsb Zq0 XbM sss dDO VFM RQh uZ0 Fxe...
22Yahoo! search interface
2perl
gw4e
>>> const y = (5n**4n**3n**2n).toString(); >>> console.log(`5**4**3**2 = ${y.slice(0,20)}...${y.slice(-20)} and has ${y.length} digits`); 5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits
18Arbitrary-precision integers (included)
10javascript
scqz
(ns zebra.core (:refer-clojure:exclude [==]) (:use [clojure.core.logic] [clojure.tools.macro:as macro])) (defne lefto [x y l] ([_ _ [x y .?r]]) ([_ _ [_ .?r]] (lefto x y?r))) (defn nexto [x y l] (conde ((lefto x y l)) ((lefto y x l)))) (defn zebrao [hs] (macro/symbol-macrolet [_...
24Zebra puzzle
6clojure
vk2f
import java.math.BigInteger fun main(args: Array<String>) { val x = BigInteger.valueOf(5).pow(Math.pow(4.0, 3.0 * 3.0).toInt()) val y = x.toString() val len = y.length println("5^4^3^2 = ${y.substring(0, 20)}...${y.substring(len - 20)} and has $len digits") }
18Arbitrary-precision integers (included)
11kotlin
hnj3
null
16Zeckendorf number representation
1lua
tjfn
'''Yellowstone permutation OEIS A098550''' from itertools import chain, count, islice from operator import itemgetter from math import gcd from matplotlib import pyplot def yellowstone(): '''A non-finite stream of terms from the Yellowstone permutation. OEIS A098550. ''' def relative...
20Yellowstone sequence
3python
smq9
import urllib import re def fix(x): p = re.compile(r'<[^<]*?>') return p.sub('', x).replace('&amp;', '&') class YahooSearch: def __init__(self, query, page=1): self.query = query self.page = page self.url = %(self.query, ((self.page - 1) * 10 + 1)) self.content = url...
22Yahoo! search interface
3python
rxgq
(defn Y [f] ((fn [x] (x x)) (fn [x] (f (fn [& args] (apply (x x) args)))))) (def fac (fn [f] (fn [n] (if (zero? n) 1 (* n (f (dec n))))))) (def fib (fn [f] (fn [n] (condp = n 0 0 1 1 (+ (f (dec n)) (f (dec (de...
25Y combinator
6clojure
hxjr
(defn partitions [sizes coll] (lazy-seq (when-let [n (first sizes)] (when-let [s (seq coll)] (cons (take n coll) (partitions (next sizes) (drop n coll))))))) (defn take-from [n colls] (lazy-seq (when-let [s (seq colls)] (let [[first-n rest-n] (split-at n s)] (cons (map first fir...
27Zig-zag matrix
6clojure
i3om
YahooSearch <- function(query, page=1, .opts=list(), ignoreMarkUpErrors=TRUE) { if(!require(RCurl) ||!require(XML)) { stop("Could not load required packages") } query <- curlEscape(query) b <- 10*(page-1)+1 theurl <- paste("http://uk.search.yahoo.com/search?p=", query, "&b=", ...
22Yahoo! search interface
13r
u1vx
bc = require("bc")
18Arbitrary-precision integers (included)
1lua
kdh2
print 0 ** 0, "\n"; use Math::Complex; print cplx(0,0) ** cplx(0,0), "\n";
14Zero to the zero power
2perl
gn4e
package main import ( "fmt" ) func main() {
13Arrays
0go
19p5
public struct Complex { public let real: Double public let imaginary: Double public init(real inReal:Double, imaginary inImaginary:Double) { real = inReal imaginary = inImaginary } public static var i: Complex = Complex(real:0, imaginary: 1) public static var zero: Complex = C...
9Arithmetic/Complex
17swift
fadk
def yellow(n) a = [1, 2, 3] b = { 1 => true, 2 => true, 3 => true } i = 4 while n > a.length if!b[i] && i.gcd(a[-1]) == 1 && i.gcd(a[-2]) > 1 a << i b[i] = true i = 4 end i += 1 end a end p yellow(30)
20Yellowstone sequence
14ruby
8c01
null
20Yellowstone sequence
15rust
ol83
require 'open-uri' require 'hpricot' SearchResult = Struct.new(:url, :title, :content) class SearchYahoo @@urlinfo = [nil, 'ca.search.yahoo.com', 80, '/search', nil, nil] def initialize(term) @term = term @page = 1 @results = nil @url = URI::HTTP.build(@@urlinfo) end def next_result if n...
22Yahoo! search interface
14ruby
js7x
my @fib; sub fib { my $n = shift; return 1 if $n < 2; return $fib[$n] //= fib($n-1)+fib($n-2); } sub zeckendorf { my $n = shift; return "0" unless $n; my $i = 1; $i++ while fib($i) <= $n; my $z = ''; while( --$i ) { $z .= "0", next if fib( $i ) > $n; $z .= "1"; $n -= fib( $i ); } ret...
16Zeckendorf number representation
2perl
hfjl
<?php echo pow(0,0); echo 0 ** 0; ?>
14Zero to the zero power
12php
n7ig
def aa = [ 1, 25, 31, -3 ]
13Arrays
7groovy
jz7o
package main import ( "fmt" "os" "text/template" ) var tmpl = `<?xml version="1.0"?> <svg xmlns="http:
26Yin and yang
0go
8z0g
<?php $m = 20; $F = array(1,1); while ($F[count($F)-1] <= $m) $F[] = $F[count($F)-1] + $F[count($F)-2]; while ($n = $m--) { while ($F[count($F)-1] > $n) array_pop($F); $l = count($F)-1; print ; while ($n) { if ($n >= $F[$l]) { $n = $n - $F[$l]; print '1'; } else print '0';...
16Zeckendorf number representation
12php
zht1
package main import ( "encoding/xml" "fmt" "log" "os" ) type Inventory struct { XMLName xml.Name `xml:"inventory"` Title string `xml:"title,attr"` Sections []struct { XMLName xml.Name `xml:"section"` Name string `xml:"name,attr"` Items []struct { XMLName xml.Name `xml:"item"` Name ...
23XML/XPath
0go
eda6
import Diagrams.Prelude import Diagrams.Backend.Cairo.CmdLine yinyang = lw 0 $ perim # lw 0.003 <> torus white black # xform id <> torus black white # xform negate <> clipBy perim base where perim = arc 0 (360 :: Deg) # scale (1/2) torus c c' = circle (1/3) # fc c...
26Yin and yang
8haskell
lrch
from decimal import Decimal from fractions import Fraction from itertools import product zeroes = [0, 0.0, 0j, Decimal(0), Fraction(0, 1), -0.0, -0.0j, Decimal(-0.0)] for i, j in product(zeroes, repeat=2): try: ans = i**j except: ans = '<Exception raised>' print(f'{i!r:>15} ** {j!r:<15} = {...
14Zero to the zero power
3python
rdgq
def inventory = new XmlSlurper().parseText("<inventory...")
23XML/XPath
7groovy
k0h7
import Data.List import Control.Arrow import Control.Monad takeWhileIncl :: (a -> Bool) -> [a] -> [a] takeWhileIncl _ [] = [] takeWhileIncl p (x:xs) | p x = x: takeWhileIncl p xs | otherwise = [x] getmultiLineItem n = takeWhileIncl(not.isInfixOf ("</" ++ n)). dropWhile...
23XML/XPath
8haskell
35zj
print(0^0)
14Zero to the zero power
13r
u8vx
import java.io.StringReader; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; public class XMLPars...
23XML/XPath
9java
i9os
null
23XML/XPath
10javascript
zut2
package org.rosettacode.yinandyang; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class YinYangGenerator { private final int size; public YinYangGenerator(...
26Yin and yang
9java
32zg
def fib(): memo = [1, 2] while True: memo.append(sum(memo)) yield memo.pop(0) def sequence_down_from_n(n, seq_generator): seq = [] for s in seq_generator(): seq.append(s) if s >= n: break return seq[::-1] def zeckendorf(n): if n == 0: return [0] seq = sequen...
16Zeckendorf number representation
3python
kthf
main() { for (var k = 1, x = new List(101); k <= 100; k++) { for (int i = k; i <= 100; i += k) x[i] =!x[i]; if (x[k]) print("$k open"); } }
21100 doors
18dart
x3wh
import Data.Array.IO main = do arr <- newArray (1,10) 37 :: IO (IOArray Int Int) a <- readArray arr 1 writeArray arr 1 64 b <- readArray arr 1 print (a,b)
13Arrays
8haskell
tbf7
package main import ( "fmt" "log" "strings" )
24Zebra puzzle
0go
ai1f
null
23XML/XPath
11kotlin
qzx1
function Arc(posX,posY,radius,startAngle,endAngle,color){
26Yin and yang
10javascript
cg9j
use Math::BigInt; my $x = Math::BigInt->new('5') ** Math::BigInt->new('4') ** Math::BigInt->new('3') ** Math::BigInt->new('2'); my $y = "$x"; printf("5**4**3**2 =%s...%s and has%i digits\n", substr($y,0,20), substr($y,-20), length($y));
18Arbitrary-precision integers (included)
2perl
z7tb
require 'bigdecimal' [0, 0.0, Complex(0), Rational(0), BigDecimal()].each do |n| printf % [n.class, n**n] end
14Zero to the zero power
14ruby
jt7x
fn main() { println!("{}",0u32.pow(0)); }
14Zero to the zero power
15rust
hzj2
module Main where import Control.Applicative ((<$>), (<*>)) import Control.Monad (foldM, forM_) import Data.List ((\\)) data House = House { color :: Color , man :: Man , pet :: Pet , drink :: Drink , smoke :: Smoke } deriving (Eq, Show) data Color = Red | Green | Blue | Yel...
24Zebra puzzle
8haskell
zvt0
<?php $y = bcpow('5', bcpow('4', bcpow('3', '2'))); printf(, substr($y,0,20), substr($y,-20), strlen($y)); ?>
18Arbitrary-precision integers (included)
12php
bfk9
zeckendorf <- function(number) { indexOfFibonacciNumber <- function(n) { if (n < 1) { 2 } else { Phi <- (1 + sqrt(5)) / 2 invertClosedFormula <- log(n * sqrt(5)) / log(Phi) ceiling(invertClosedFormula) } } upperLimit <- indexOfFibonacciNumber(number) fibonacciSequenc...
16Zeckendorf number representation
13r
rigj
assert(math.pow(0, 0) == 1, "Scala blunder, should go back to school!")
14Zero to the zero power
16scala
pybj
require 'lxp' data = [[<inventory title="OmniCorp Store #45x10^3"> <section name="health"> <item upc="123456789" stock="12"> <name>Invisibility Cream</name> <price>14.50</price> <description>Makes you invisible</description> </item> <item upc="445322344" stock="18"> <name>Levitatio...
23XML/XPath
1lua
s3q8
null
26Yin and yang
11kotlin
nyij
package org.rosettacode.zebra; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Objects; import java.util.Set; public class Zebra { private static final int[] orders = {1, 2, 3, 4, 5}; private static final String[] nations = {"English", "Danish", "German", ...
24Zebra puzzle
9java
oy8d
function circle(x, y, c, r) return (r * r) >= (x * x) / 4 + ((y - c) * (y - c)) end function pixel(x, y, r) if circle(x, y, -r / 2, r / 6) then return '#' end if circle(x, y, r / 2, r / 6) then return '.' end if circle(x, y, -r / 2, r / 2) then return '.' end if ...
26Yin and yang
1lua
dmnq
>>> y = str( 5**4**3**2 ) >>> print (% (y[:20], y[-20:], len(y))) 5**4**3**2 = 62060698786608744707...92256259918212890625 and has 183231 digits
18Arbitrary-precision integers (included)
3python
3jzc
SQL> SELECT POWER(0,0) FROM dual;
14Zero to the zero power
19sql
ecau
library(gmp) large <- pow.bigz(5, pow.bigz(4, pow.bigz(3, 2))) largestr <- as.character(large) cat("first 20 digits:", substr(largestr, 1, 20), "\n", "last 20 digits:", substr(largestr, nchar(largestr) - 19, nchar(largestr)), "\n", "number of digits: ", nchar(largestr), "\n")
18Arbitrary-precision integers (included)
13r
d4nt
def zeckendorf return to_enum(__method__) unless block_given? x = 0 loop do bin = x.to_s(2) yield bin unless bin.include?() x += 1 end end zeckendorf.take(21).each_with_index{|x,i| puts % [i, x]}
16Zeckendorf number representation
14ruby
p3bh
import Darwin print(pow(0.0,0.0))
14Zero to the zero power
17swift
7frq
null
24Zebra puzzle
11kotlin
xfws