code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
= 1 += 1 puts
87Unicode variable names
14ruby
hgdjx
#![feature(non_ascii_idents)] #![allow(non_snake_case)] fn main() { let mut : i32 = 1; += 1; println!("{}", ); }
87Unicode variable names
15rust
krfh5
public class Bias { public static boolean biased(int n) { return Math.random() < 1.0 / n; } public static boolean unbiased(int n) { boolean a, b; do { a = biased(n); b = biased(n); } while (a == b); return a; } public static void main...
90Unbias a random generator
9java
akt1y
import Foundation infix operator : MultiplicationPrecedence infix operator : MultiplicationPrecedence public struct Vector { public var x = 0.0 public var y = 0.0 public var z = 0.0 public init(x: Double, y: Double, z: Double) { (self.x, self.y, self.z) = (x, y, z) } public static func (lhs: Vector...
72Vector products
17swift
qa1xg
puts unless defined? var var = puts unless defined? var puts
85Undefined values
14ruby
uc0vz
use std::ptr; let p: *const i32 = ptr::null(); assert!(p.is_null());
85Undefined values
15rust
5l8uq
var = 1 val = 3.141592 val = "hello" += 1 println()
87Unicode variable names
16scala
1h3pf
null
90Unbias a random generator
11kotlin
hgoj3
import numpy as np class Revolver: def __init__(self): self.cylinder = np.array([False] * 6) def unload(self): self.cylinder[:] = False def load(self): while self.cylinder[1]: self.cylinder[:] = np.roll(self.cylinder, 1) self.cy...
94Two bullet roulette
3python
ruegq
var x; # declared, but not defined x == nil && say "nil value"; defined(x) || say "undefined"; # Give "x" some value x = 42; defined(x) && say "defined"; # Change "x" back to `nil` x = nil; defined(x) || say "undefined";
85Undefined values
16scala
rungn
str = str.include?()
92Unicode strings
14ruby
8xm01
object UTF8 extends App { def charToInt(s: String) = { def charToInt0(c: Char, next: Char): Option[Int] = (c, next) match { case _ if (c.isHighSurrogate && next.isLowSurrogate) => Some(java.lang.Character.toCodePoint(c, next)) case _ if (c.isLowSurrogate) => None case _ ...
92Unicode strings
16scala
d82ng
package main import "fmt" func sieve(limit uint64) []bool { limit++
95Twin primes
0go
ebia6
var = 1 let = 3.141592 let = "hello" ++ println()
87Unicode variable names
17swift
j4n74
local function randN(n) return function() if math.random() < 1/n then return 1 else return 0 end end end local function unbiased(n) local biased = randN (n) return function() local a, b = biased(), biased() while a==b do a, b = biased(), biased() end return a end end local function...
90Unbias a random generator
1lua
krih2
void oops(const wchar_t *message) { wchar_t *buf; DWORD error; buf = NULL; error = GetLastError(); FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (wchar_t *)&buf, 0, NULL); if (buf) { fwprintf(stderr, L, message, buf); Lo...
96Truncate a file
5c
mz5ys
typedef uint32_t bitsieve; unsigned sieve_check(bitsieve *b, const unsigned v) { if ((v != 2 && !(v & 1)) || (v < 2)) return 0; else return !(b[v >> 6] & (1 << (v >> 1 & 31))); } bitsieve* sieve(const unsigned v) { unsigned i, j; bitsieve *b = calloc((v >> 6) + 1, sizeof(uint32_t)); ...
97Ulam spiral (for primes)
5c
42k5t
>>> import os >>> print('\n'.join(sorted(os.listdir('.')))) DLLs Doc LICENSE.txt Lib NEWS.txt README.txt Scripts Tools include libs python.exe pythonw.exe tcl >>>
86Unix/ls
3python
ruigq
cat(paste(list.files(), collapse = "\n"), "\n") cat(paste(list.files("bar"), collapse = "\n"), "\n")
86Unix/ls
13r
ucsvx
let flag = "" print(flag.characters.count)
92Unicode strings
17swift
0wys6
# International class; name and street class ( , Strae ) { # Say who am I! method { say "I am #{self.} from #{self.Strae}"; } } # all the people of the world! var = [ ( "Friederich", "" ), ( "Smith ", "Cant" ), ( "Stanisaw Lec", "poudniow" ), ...
92Unicode strings
15rust
oq983
import java.math.BigInteger; import java.util.Scanner; public class twinPrimes { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Search Size: "); BigInteger max = input.nextBigInteger(); int counter = 0; for(BigInteger x =...
95Twin primes
9java
isyos
use strict; use warnings; use feature 'say'; use ntheory 'is_prime'; use enum qw(False True); sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r } sub is_unprimeable { my($n) = @_; return False if is_prime($n); my $chrs = length $n; for my $place (0..$chrs-1) { my $pow = 10**(...
88Unprimeable numbers
2perl
hgnjl
(defn truncate [file size] (with-open [chan (.getChannel (java.io.FileOutputStream. file true))] (.truncate chan size))) (truncate "truncate_test.txt" 2)
96Truncate a file
6clojure
v9j2f
Dir.foreach(){|n| puts n}
86Unix/ls
14ruby
j4d7x
use std::{env, fmt, fs, process}; use std::io::{self, Write}; use std::path::Path; fn main() { let cur = env::current_dir().unwrap_or_else(|e| exit_err(e, 1)); let arg = env::args().nth(1); print_files(arg.as_ref().map_or(cur.as_path(), |p| Path::new(p))) .unwrap_or_else(|e| exit_err(e, 2)); } #[i...
86Unix/ls
15rust
hgfj2
import java.math.BigInteger import java.util.* fun main() { val input = Scanner(System.`in`) println("Search Size: ") val max = input.nextBigInteger() var counter = 0 var x = BigInteger("3") while (x <= max) { val sqrtNum = x.sqrt().add(BigInteger.ONE) if (x.add(BigInteger.TWO) ...
95Twin primes
11kotlin
qafx1
sub randn { my $n = shift; return int(rand($n) / ($n - 1)); } for my $n (3 .. 6) { print "Bias $n: "; my (@raw, @fixed); for (1 .. 10000) { my $x = randn($n); $raw[$x]++; $fixed[$x]++ if randn($n) != $x } print "...
90Unbias a random generator
2perl
zngtb
scala> new java.io.File("/").listFiles.sorted.foreach(println) /bin /boot /core /dev /etc /home /lib /lib64 /local /lost+found /media /mnt /opt /proc /root /run /sbin /selinux /srv /sys /tmp /user /usr /var
86Unix/ls
16scala
pj3bj
use strict; use warnings; use Primesieve; sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r } printf "Twin prime pairs less than%14s:%s\n", comma(10**$_), comma count_twins(1, 10**$_) for 1..10;
95Twin primes
2perl
v9h20
from itertools import count, islice def primes(_cache=[2, 3]): yield from _cache for n in count(_cache[-1]+2, 2): if isprime(n): _cache.append(n) yield n def isprime(n, _seen={0: False, 1: False}): def _isprime(n): for p in primes(): if p*p > n: ...
88Unprimeable numbers
3python
krdhf
primes = [2, 3, 5, 7, 11, 13, 17, 19] def count_twin_primes(limit: int) -> int: global primes if limit > primes[-1]: ram_limit = primes[-1] + 90000000 - len(primes) reasonable_limit = min(limit, primes[-1] ** 2, ram_limit) - 1 while reasonable_limit < limit: ram_limit = pr...
95Twin primes
3python
uckvd
import ( "fmt" "os" ) if err := os.Truncate("filename", newSize); err != nil { fmt.Println(err) }
96Truncate a file
0go
ak81f
typedef int bool; typedef struct { char name; bool val; } var; typedef struct { int top; bool els[STACK_SIZE]; } stack_of_bool; char expr[BUFFER_SIZE]; int expr_len; var vars[24]; int vars_len; bool is_full(stack_of_bool *sp) { return sp->top == STACK_SIZE - 1; } bool is_empty(stack_of_bool *...
98Truth table
5c
5ljuk
from __future__ import print_function import random def randN(N): return lambda: random.randrange(N) == 0 def unbiased(biased): 'uses a biased() generator of 1 or 0, to create an unbiased one' this, that = biased(), biased() while this == that: this, that = biased(), biased() return ...
90Unbias a random generator
3python
3drzc
setFileSize :: FilePath -> FileOffset -> IO ()
96Truncate a file
8haskell
znlt0
package main import ( "fmt" "io" "os" "strings" ) type nNode struct { name string children []nNode } type iNode struct { level int name string } func printNest(n nNode, level int, w io.Writer) { if level == 0 { fmt.Fprintln(w, "\n==Nest form==\n") } fmt.Fprin...
99Tree datastructures
0go
2m4l7
randN = function(N) sample.int(N, 1) == 1 unbiased = function(f) {while ((x <- f()) == f()) {} x} samples = 10000 print(t(round(d = 2, sapply(3:6, function(N) c( N = N, biased = mean(replicate(samples, randN(N))), unbiased = mean(replicate(samples, unbiased(function() randN(N)))))))))
90Unbias a random generator
13r
d8unt
import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class TruncFile { public static void main(String[] args) throws IOException{ if(args.length < 2){ System.out.println("Usage: java TruncFile fileName newSize"); return; }
96Truncate a file
9java
oq38d
import Data.List (span) data Nest a = Nest (Maybe a) [Nest a] deriving Eq instance Show a => Show (Nest a) where show (Nest (Just a) []) = show a show (Nest (Just a) s) = show a ++ show s show (Nest Nothing []) = "\"\"" show (Nest Nothing s) = "\"\"" ++ show s type Indent a = [(Int, a)] class Iso b a...
99Tree datastructures
8haskell
akq1g
(use '[clojure.math.combinatorics] (defn xor? [& args] (odd? (count (filter identity args)))) (defn twelve-statements [] (for [[a b c d e f g h i j k l] (selections [true false] 12) :when (true? a) :when (if (= 3 (count (filter true? [g h i j k l]))) (true? b) (false? b)) :when (if (= 2 (count (filter tr...
100Twelve statements
6clojure
c6v9b
require 'prime' (1..8).each do |n| count = Prime.each(10**n).each_cons(2).count{|p1, p2| p2-p1 == 2} puts end
95Twin primes
14ruby
42p5p
null
88Unprimeable numbers
15rust
1hzpu
null
96Truncate a file
11kotlin
x1nws
use strict; use warnings; use feature 'say'; use JSON; use Data::Printer; my $trees = <<~END; RosettaCode encourages code diversity comparison discourages golfing trolling emphasising execution speed code-golf.io encourages golfing ...
99Tree datastructures
2perl
oqf8x
(ns clojure-sandbox.truthtables (:require [clojure.string:as s] [clojure.pprint:as pprint])) (defn !op [expr] (not expr)) (defn |op [e1 e2] (not (and (not e1) (not e2)))) (defn &op [e1 e2] (and e1 e2)) (defn ->op [e1 e2] (if e1 e2 true)) (def operators {"!" !op ...
98Truth table
6clojure
j417m
null
95Twin primes
15rust
gv14o
package main import "fmt" type any = interface{} func toTree(list []int) any { s := []any{[]any{}} for _, n := range list { for n != len(s) { if n > len(s) { inner := []any{} s[len(s)-1] = append(s[len(s)-1].([]any), inner) s = append(s, inn...
101Tree from nesting levels
0go
n0fi1
import Foundation class BitArray { var array: [UInt32] init(size: Int) { array = Array(repeating: 0, count: (size + 31)/32) } func get(index: Int) -> Bool { let bit = UInt32(1) << (index & 31) return (array[index >> 5] & bit)!= 0 } func set(index: Int, value: Bool) { ...
88Unprimeable numbers
17swift
b7fkd
def rand_n(bias) rand(bias) == 0? 1: 0 end def unbiased(bias) a, b = rand_n(bias), rand_n(bias) until a!= b a end runs = 1_000_000 keys = %i(bias biased unbiased) puts keys.join() (3..6).each do |bias| counter = Hash.new(0) runs.times do counter[:biased] += 1 if rand_n(bias) == 1 counter[:unbia...
90Unbias a random generator
14ruby
ytj6n
function truncate (filename, length) local inFile = io.open(filename, 'r') if not inFile then error("Specified filename does not exist") end local wholeFile = inFile:read("*all") inFile:close() if length >= wholeFile:len() then error("Provided length is not less than current file...
96Truncate a file
1lua
qadx0
from pprint import pprint as pp def to_indent(node, depth=0, flat=None): if flat is None: flat = [] if node: flat.append((depth, node[0])) for child in node[1]: to_indent(child, depth + 1, flat) return flat def to_nest(lst, depth=0, level=None): if level is None: le...
99Tree datastructures
3python
istof
#![feature(inclusive_range_syntax)] extern crate rand; use rand::Rng; fn rand_n<R: Rng>(rng: &mut R, n: u32) -> usize { rng.gen_weighted_bool(n) as usize
90Unbias a random generator
15rust
mzhya
def biased( n:Int ) = scala.util.Random.nextFloat < 1.0 / n def unbiased( n:Int ) = { def loop : Boolean = { val a = biased(n); if( a != biased(n) ) a else loop }; loop } for( i <- (3 until 7) ) println { val m = 50000 var c1,c2 = 0 (0 until m) foreach { j => if( biased(i) ) c1 += 1; if( unbiased(i) ) c2 += ...
90Unbias a random generator
16scala
lypcq
import Data.Bifunctor (bimap) import Data.Tree (Forest, Tree (..), drawTree, foldTree) treeFromSparseLevels :: [Int] -> Tree (Maybe Int) treeFromSparseLevels = Node Nothing . forestFromNestLevels . rooted . normalised sparseLevelsFromTree :: Tree (Maybe Int) -> [Int] sparseLevelsFromTree = foldTree go...
101Tree from nesting levels
8haskell
uc4v2
char *primes; int n_primes; void init_primes() { int j; primes = malloc(sizeof(char) * MAX_PRIME); memset(primes, 1, MAX_PRIME); primes[0] = primes[1] = 0; int i = 2; while (i * i < MAX_PRIME) { for (j = i * 2; j < MAX_PRIME; j += i) primes[j] = 0; while (++i < MAX_PRIME && !primes[i]); } } int left_tr...
102Truncatable primes
5c
8xo04
package main import ( "math" "fmt" ) type Direction byte const ( RIGHT Direction = iota UP LEFT DOWN ) func generate(n,i int, c byte) { s := make([][]string, n) for i := 0; i < n; i++ { s[i] = make([]string, n) } dir := RIGHT y := n / 2 var x int if (n % 2 == 0) { x = y - 1 } else { x = y }
97Ulam spiral (for primes)
0go
oqz8q
open FOO, ">>file" or die; truncate(FOO, 1234); close FOO; truncate("file", 567);
96Truncate a file
2perl
2m7lf
use strict; use warnings; use Data::Dump qw(dd pp); my @tests = ( [] ,[1, 2, 4] ,[3, 1, 3, 1] ,[1, 2, 3, 1] ,[3, 2, 1, 3] ,[3, 3, 3, 1, 1, 3, 3, 3] ); for my $before ( @tests ) { dd { before => $before }; local $_ = (pp $before) =~ s/\d+/ '['x($&-1) . $& . ']'x($&-1) /ger; 1 while s/\](,\s*)\[...
101Tree from nesting levels
2perl
krphc
import Data.List import Data.Numbers.Primes ulam n representation = swirl n . map representation
97Ulam spiral (for primes)
8haskell
2mrll
package main import "fmt"
100Twelve statements
0go
b7akh
package main import ( "bufio" "errors" "fmt" "go/ast" "go/parser" "go/token" "os" "reflect" ) func main() { in := bufio.NewScanner(os.Stdin) for { fmt.Print("Expr: ") in.Scan() if err := in.Err(); err != nil { fmt.Println(err) re...
98Truth table
0go
8xf0g
(use '[clojure.contrib.lazy-seqs:only [primes]]) (def prime? (let [mem (ref #{}) primes (ref primes)] (fn [n] (dosync (if (< n (first @primes)) (@mem n) (let [[mems ss] (split-with #(<= % n) @primes)] (ref-set primes ss) ((commute mem into mems) n))))))) (defn drop-lefts [n] (let [dr...
102Truncatable primes
6clojure
fotdm
def to_tree(x, index=0, depth=1): so_far = [] while index < len(x): this = x[index] if this == depth: so_far.append(this) elif this > depth: index, deeper = to_tree(x, index, depth + 1) so_far.append(deeper) else: index -=1 break ...
101Tree from nesting levels
3python
b71kr
enum Rule { r01( 1, { r()*.num == (1..12) }), r02( 2, { r(7..12).count { it.truth } == 3 }), r03( 3, { r(2..12, 2).count { it.truth } == 2 }), r04( 4, { r(5).truth ? r(6).truth && r(7).truth: true }), r05( 5, { r(2..4).count { it.truth } == 0 }), r06( 6, { r(1..11, 2).count { it.truth } == 4 }),...
100Twelve statements
7groovy
ruhgh
import Control.Monad (mapM, foldM, forever) import Data.List (unwords, unlines, nub) import Data.Maybe (fromJust) truthTable expr = let tokens = words expr operators = ["&", "|", "!", "^", "=>"] variables = nub $ filter (not . (`elem` operators)) tokens table = zip variables <$> mapM (const [True,False...
98Truth table
8haskell
ly4ch
import java.util.Arrays; public class Ulam{ enum Direction{ RIGHT, UP, LEFT, DOWN; } private static String[][] genUlam(int n){ return genUlam(n, 1); } private static String[][] genUlam(int n, int i){ String[][] spiral = new String[n][n]; Direction dir = Direction.RIGHT; int j = i; int y = n / 2; i...
97Ulam spiral (for primes)
9java
6f23z
def truncate_file(name, length): if not os.path.isfile(name): return False if length >= os.path.getsize(name): return False with open(name, 'ab') as f: f.truncate(length) return True
96Truncate a file
3python
v9j29
truncate_file <- function(filename, n_bytes) { stopifnot( "file does not exist"= file.exists(filename), "not enough bytes in file"= file.size(filename) >= n_bytes ) input.con <- file(filename, "rb") bindata <- readBin(input.con, integer(), n=n_bytes/4) close(input.con) tmp.filename <- te...
96Truncate a file
13r
934mg
import Data.List (findIndices) tf :: [[Int] -> Bool] -> [[Int]] tf = traverse (const [1, 0]) wrongness :: [Int] -> [[Int] -> Bool] -> [Int] wrongness ns ps = findIndices id (zipWith (/=) ns (map (fromEnum . ($ ns)) ps)) statements :: [[Int] -> Bool] statements = [ (== 12) . length , 3 [length statements - 6 ..]...
100Twelve statements
8haskell
d8zn4
<!-- UlamSpiral.html --> <html> <head><title>Ulam Spiral</title> <script src="VOE.js"></script> <script>
97Ulam spiral (for primes)
10javascript
lygcf
enum { LEFT, RIGHT, STAY }; typedef struct { int state1; int symbol1; int symbol2; int dir; int state2; } transition_t; typedef struct tape_t tape_t; struct tape_t { int symbol; tape_t *left; tape_t *right; }; typedef struct { int states_len; char **states; int...
103Universal Turing machine
5c
sesq5
public class LogicPuzzle { boolean S[] = new boolean[13]; int Count = 0; public boolean check2 () { int count = 0; for (int k = 7; k <= 12; k++) if (S[k]) count++; return S[2] == (count == 3); } public boolean check3 () { int count = 0; f...
100Twelve statements
9java
seoq0
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; public class TruthTable { public static void main( final String... args ) { System.out.println( new Tru...
98Truth table
9java
3dczg
File.open(, ) do |f| f.truncate(1234) f << end File.truncate(, 567)
96Truncate a file
14ruby
5lkuj
use std::path::Path; use std::fs; fn truncate_file<P: AsRef<Path>>(filename: P, filesize: usize) -> Result<(), Error> { use Error::*; let file = fs::read(&filename).or(Err(NotFound))?; if filesize > file.len() { return Err(FilesizeTooSmall) } fs::write(&filename, &file[..filesize]).or(Err...
96Truncate a file
15rust
42b5u
typedef struct { char v[16]; } deck; typedef unsigned int uint; uint n, d, best[16]; void tryswaps(deck *a, uint f, uint s) { if (d > best[n]) best[n] = d; while (1) { if ((A[s] == s || (A[s] == -1 && !(f & 1U << s))) && (d + best[s] >= best[n] || A[s] == -1)) break; if (d + best[s] <= best[n]) return;...
104Topswops
5c
ox080
<!DOCTYPE html><html><head><title>Truth table</title><script> var elem,expr,vars; function isboolop(chr){return "&|!^".indexOf(chr)!=-1;} function varsindexof(chr){ var i; for(i=0;i<vars.length;i++){if(vars[i][0]==chr)return i;} return -1; } function printtruthtable(){ var i,str; elem=document.creat...
98Truth table
10javascript
c659j
import java.io.FileOutputStream object TruncFile extends App { if (args.length < 2) println("Usage: java TruncFile fileName newSize") else {
96Truncate a file
16scala
75ar9
null
100Twelve statements
11kotlin
akx13
object Ulam { fun generate(n: Int, i: Int = 1, c: Char = '*') { require(n > 1) val s = Array(n) { Array(n, { "" }) } var dir = Direction.RIGHT var y = n / 2 var x = if (n % 2 == 0) y - 1 else y
97Ulam spiral (for primes)
11kotlin
d8ynz
(defn tape "Creates a new tape with given blank character and tape contents" ([blank] (tape () blank () blank)) ([right blank] (tape () (first right) (rest right) blank)) ([left head right blank] [(reverse left) (or head blank) (into () right) blank])) (defn- left [[[l & ls] _ rs b] c] [ls (or...
103Universal Turing machine
6clojure
n0nik
null
98Truth table
11kotlin
n03ij
local function ulamspiral(n, f) print("n = " .. n) local function isprime(p) if p < 2 then return false end if p % 2 == 0 then return p==2 end if p % 3 == 0 then return p==3 end local limit = math.sqrt(p) for f = 5, limit, 6 do if p % f == 0 or p % (f+2) == 0 then return false end end ...
97Ulam spiral (for primes)
1lua
fomdp
user=> 3 3 user=> (Math/pow *1 2) 9.0 user=> (Math/pow *2 0.5) 1.7320508075688772
105Topic variable
6clojure
q1ext
int main () { double inputs[11], check = 400, result; int i; printf (); for (i = 0; i < 11; i++) { scanf (, &inputs[i]); } printf (); for (i = 10; i >= 0; i--) { result = sqrt (fabs (inputs[i])) + 5 * pow (inputs[i], 3); printf (); if (result > check) { ...
106Trabb Pardo–Knuth algorithm
5c
toif4
package main import ( "math" "os" "strconv" "text/template" ) func sqr(x string) string { f, err := strconv.ParseFloat(x, 64) if err != nil { return "NA" } return strconv.FormatFloat(f*f, 'f', -1, 64) } func sqrt(x string) string { f, err := strconv.ParseFloat(x, 64) i...
105Topic variable
0go
yfz64
use List::Util 'sum'; my @condition = ( sub { 0 }, sub { 13==@_ }, sub { 3==sum @_[7..12] }, sub { 2==sum @_[2,4,6,8,10,12] }, sub { $_[5] ? ($_[6] and $_[7]) : 1 }, sub { !$_[2] and !$_[3] and !$_[4] }, ...
100Twelve statements
2perl
932mn
Prelude> [1..10] [1,2,3,4,5,6,7,8,9,10] Prelude> map (^2) it [1,4,9,16,25,36,49,64,81,100]
105Topic variable
8haskell
h4rju
null
105Topic variable
11kotlin
c3y98
typedef double Fp; typedef struct { Fp x, y, r; } Circle; Circle circles[] = { { 1.6417233788, 1.6121789534, 0.0848270516}, {-1.4944608174, 1.2077959613, 1.1039549836}, { 0.6110294452, -0.6907087527, 0.9089162485}, { 0.3844862411, 0.2923344616, 0.2375743054}, {-0.2495892950, -0.3832854473, 1.084...
107Total circles area
5c
2yylo
print sqrt . " " for (4, 16, 64)
105Topic variable
2perl
xpaw8
null
104Topswops
0go
4lu52
>>> 3 3 >>> _*_, _**0.5 (9, 1.7320508075688772) >>>
105Topic variable
3python
q1exi
int totient(int n){ int tot = n,i; for(i=2;i*i<=n;i+=2){ if(n%i==0){ while(n%i==0) n/=i; tot-=tot/i; } if(i==2) i=1; } if(n>1) tot-=tot/n; return tot; } int main() { int count = 0,n,tot; printf(,237); printf(); for(n=1;n<=25;n++){ tot = totient(n); if(n-1 == tot) coun...
108Totient function
5c
p7rby
import Data.List (permutations) topswops :: Int -> Int topswops n = maximum $ map tops $ permutations [1 .. n] where tops (1:_) = 0 tops xa@(x:_) = 1 + tops reordered where reordered = reverse (take x xa) ++ drop x xa main = mapM_ (putStrLn . ((++) <$> show <*> (":\t" ++) . show . topswops))...
104Topswops
8haskell
q1wx9
from itertools import product constraintinfo = ( (lambda st: len(st) == 12 ,(1, 'This is a numbered list of twelve statements')), (lambda st: sum(st[-6:]) == 3 ,(2, 'Exactly 3 of the last 6 statements are true')), (lambda st: sum(st[1::2]) == 2 ,(3, 'Exactly 2 of the eve...
100Twelve statements
3python
c6v9q
use ntheory qw/is_prime/; use Imager; my $n = shift || 512; my $start = shift || 1; my $file = "ulam.png"; sub cell { my($n, $x, $y, $start) = @_; $y -= $n>>1; $x -= ($n-1)>>1; my $l = 2*(abs($x) > abs($y) ? abs($x) : abs($y)); my $d = ($y > $x) ? $l*3 + $x + $y : $l-$x-$y; ($l-1)**2 + $d + $start - 1;...
97Ulam spiral (for primes)
2perl
j4a7f
while DATA.gets print end __END__ This is line one This is line two This is line three
105Topic variable
14ruby
0exsu
object TopicVar extends App { class SuperString(val org: String){ def it(): Unit = println(org) } new SuperString("FvdB"){it()} new SuperString("FvdB"){println(org)} Seq(1).foreach {println} Seq(2).foreach {println(_)} Seq(4).foreach { it => println(it)} Seq(8).foreach { it => println(it + it)} }
105Topic variable
16scala
ns8ic