code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
val src = io.Source fromURL "http:
1,152Anagrams
16scala
idnox
var deficients = 0
1,161Abundant, deficient and perfect number classifications
17swift
ftxdk
from itertools import zip_longest txt = parts = [line.rstrip().split() for line in txt.splitlines()] widths = [max(len(word) for word in col) for col in zip_longest(*parts, fillvalue='')] for justify in .split(): j, jtext = justify.split('_') print(f) for line in parts: print(' '.join...
1,160Align columns
3python
ymi6q
function integer_classification(){ var sum:number=0, i:number,j:number; var try:number=0; var number_list:number[]={1,0,0}; for(i=2;i<=20000;i++){ try=i/2; sum=1; for(j=2;j<try;j++){ if (i%j) continue; try=i/j; sum+=j; if (j!=try) sum+=try; } if (sum<i){ number_list[d]++; continu...
1,161Abundant, deficient and perfect number classifications
20typescript
4gy53
lines <- readLines(tc <- textConnection("Given$a$text$file$of$many$lines,$where$fields$within$a$line$ are$delineated$by$a$single$'dollar'$character,$write$a$program that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$ column$are$separated$by$at$least$one$space. Further,$allow$for$each$word$in$a$column$to$b...
1,160Align columns
13r
tzsfz
import Foundation let wordsURL = NSURL(string: "http:
1,152Anagrams
17swift
q0sxg
J2justifier = {Left: :ljust, Right: :rjust, Center: :center} =begin Justify columns of textual tabular input where the record separator is the newline and the field separator is a 'dollar' character. justification can be Symbol; (:Left,:Right, or:Center). Return the justified output as a string =end def aligner(infil...
1,160Align columns
14ruby
9cdmz
use std::iter::{repeat, Extend}; enum AlignmentType { Left, Center, Right, } fn get_column_widths(text: &str) -> Vec<usize> { let mut widths = Vec::new(); for line in text .lines() .map(|s| s.trim_matches(' ').trim_end_matches('$')) { let lens = line.split('$').map(|s| ...
1,160Align columns
15rust
clf9z
func Ackermann(m, n uint) uint { switch 0 { case m: return n + 1 case n: return Ackermann(m - 1, 1) } return Ackermann(m - 1, Ackermann(m, n - 1)) }
1,162Ackermann function
0go
7j9r2
object ColumnAligner { val eol = System.getProperty("line.separator") def getLines(filename: String) = scala.io.Source.fromPath(filename).getLines(eol) def splitter(line: String) = line split '$' def getTable(filename: String) = getLines(filename) map splitter def fieldWidths(fields: Array[String]) = fields m...
1,160Align columns
16scala
vu32s
def ack ( m, n ) { assert m >= 0 && n >= 0: 'both arguments must be non-negative' m == 0 ? n + 1: n == 0 ? ack(m-1, 1): ack(m-1, ack(m, n-1)) }
1,162Ackermann function
7groovy
u5zv9
ack :: Int -> Int -> Int ack 0 n = succ n ack m 0 = ack (pred m) 1 ack m n = ack (pred m) (ack m (pred n)) main :: IO () main = mapM_ print $ uncurry ack <$> [(0, 0), (3, 4)]
1,162Ackermann function
8haskell
8ob0z
import Foundation extension String { func dropLastIf(_ char: Character) -> String { if last == char { return String(dropLast()) } else { return self } } } enum Align { case left, center, right } func getLines(input: String) -> [String] { input .components(separatedBy: "\n") .m...
1,160Align columns
17swift
m9nyk
import java.math.BigInteger; public static BigInteger ack(BigInteger m, BigInteger n) { return m.equals(BigInteger.ZERO) ? n.add(BigInteger.ONE) : ack(m.subtract(BigInteger.ONE), n.equals(BigInteger.ZERO) ? BigInteger.ONE : ack(m, n.subtract(BigInteger.ONE))); }
1,162Ackermann function
9java
ewga5
function ack(m, n) { return m === 0 ? n + 1 : ack(m - 1, n === 0 ? 1 : ack(m, n - 1)); }
1,162Ackermann function
10javascript
08ksz
tailrec fun A(m: Long, n: Long): Long { require(m >= 0L) { "m must not be negative" } require(n >= 0L) { "n must not be negative" } if (m == 0L) { return n + 1L } if (n == 0L) { return A(m - 1L, 1L) } return A(m - 1L, A(m, n - 1L)) } inline fun<T> tryOrNull(block: () -> T): ...
1,162Ackermann function
11kotlin
kb2h3
function ack(M,N) if M == 0 then return N + 1 end if N == 0 then return ack(M-1,1) end return ack(M-1,ack(M, N-1)) end
1,162Ackermann function
1lua
bpvka
int main(int argc, char** argv) { int i,j,sandPileEdge, centerPileHeight, processAgain = 1,top,down,left,right; int** sandPile; char* fileName; static unsigned char colour[3]; if(argc!=3){ printf(,argv[0]); return 0; } sandPileEdge = atoi(argv[1]); centerPileHeight = atoi(argv[2]); if(sandPileEdge<=0 |...
1,163Abelian sandpile model
5c
ew4av
const char* command_table = ; typedef struct command_tag { char* cmd; size_t length; size_t min_len; struct command_tag* next; } command_t; bool command_match(const command_t* command, const char* str) { size_t olen = strlen(str); return olen >= command->min_len && olen...
1,164Abbreviations, simple
5c
xqgwu
(defn words "Split string into words" [^String str] (.split (.stripLeading str) "\\s+")) (defn join-words "Join words into a single string" ^String [strings] (String/join " " strings)) (defn starts-with-ignore-case "Does string start with prefix (ignoring case)?" ^Boolean [^String string, ^String pre...
1,164Abbreviations, simple
6clojure
oik8j
const char* command_table = ; typedef struct command_tag { char* cmd; size_t length; size_t min_len; struct command_tag* next; } command_t; bool command_match(const command_t* command, const char* str) { size_t olen = strlen(str); return olen >= command->min_len && olen <=...
1,165Abbreviations, easy
5c
ymq6f
(defn words [str] "Split string into words" (.split str "\\s+")) (defn join-words [strings] "Join words into a single string" (clojure.string/join " " strings)) (def cmd-table "Command Table - List of words to match against" (words "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPre...
1,165Abbreviations, easy
6clojure
2vil1
package main import ( "fmt" "log" "os" "strings" ) const dim = 16
1,163Abelian sandpile model
0go
9comt
module Rosetta.AbelianSandpileModel.ST ( simulate , test , toPGM ) where import Control.Monad.Reader (asks, MonadReader (..), ReaderT, runReaderT) import Control.Monad.ST (runST, ST) import Control.Monad.State (evalStateT, forM_, lift, MonadState (..), StateT, modify, when) import Data.Array.ST (freez...
1,163Abelian sandpile model
8haskell
bp2k2
package main import ( "fmt" "strings" ) var table = "Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy " + "COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find " + "NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput "...
1,165Abbreviations, easy
0go
1a2p5
typedef struct sAbstractCls *AbsCls; typedef struct sAbstractMethods { int (*method1)(AbsCls c, int a); const char *(*method2)(AbsCls c, int b); void (*method3)(AbsCls c, double d); } *AbstractMethods, sAbsMethods; struct sAbstractCls { AbstractMethods klass; void *instData; };...
1,166Abstract type
5c
vui2o
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class AbelianSandpile { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Frame frame = new Frame(); frame.setVisible(true); ...
1,163Abelian sandpile model
9java
gr64m
package main import ( "io" "os" "strconv" "strings" "text/tabwriter" ) func readTable(table string) ([]string, []int) { fields := strings.Fields(table) var commands []string var minLens []int for i, max := 0, len(fields); i < max; { cmd := fields[i] cmdLen := len(cmd) i++ if i < max { num, err :...
1,164Abbreviations, simple
0go
l2icw
import Data.Maybe (fromMaybe) import Data.List (find, isPrefixOf) import Data.Char (toUpper, isUpper) isAbbreviationOf :: String -> String -> Bool isAbbreviationOf abbreviation command = minimumPrefix `isPrefixOf` normalizedAbbreviation && normalizedAbbreviation `isPrefixOf` normalizedCommand where normalize...
1,165Abbreviations, easy
8haskell
tzaf7
package main import ( "fmt" "strconv" "strings" ) type sandpile struct{ a [9]int } var neighbors = [][]int{ {1, 3}, {0, 2, 4}, {1, 5}, {0, 4, 6}, {1, 3, 5, 7}, {2, 4, 8}, {3, 7}, {4, 6, 8}, {5, 7}, }
1,167Abelian sandpile model/Identity
0go
08gsk
local sandpile = { init = function(self, dim, val) self.cell, self.dim = {}, dim for r = 1, dim do self.cell[r] = {} for c = 1, dim do self.cell[r][c] = 0 end end self.cell[math.floor(dim/2)+1][math.floor(dim/2)+1] = val end, iter = function(self) local dim, cel, more...
1,163Abelian sandpile model
1lua
vuf2x
import Data.List (find, isPrefixOf) import Data.Char (isDigit, toUpper) import Data.Maybe (maybe) withExpansions :: [(String, Int)] -> String -> String withExpansions tbl s = unwords $ expanded tbl <$> words s expanded :: [(String, Int)] -> String -> String expanded tbl k = maybe "*error" fst (expand k) where e...
1,164Abbreviations, simple
8haskell
1avps
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class AbbreviationsEasy { private static final Scanner input = new Scanner(System.in); private static final String COMMAND_TABLE = " Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy...
1,165Abbreviations, easy
9java
8oj06
import Data.List (findIndex, transpose) import Data.List.Split (chunksOf) main :: IO () main = do let s0 = [[4, 3, 3], [3, 1, 2], [0, 2, 3]] s1 = [[1, 2, 0], [2, 1, 1], [0, 1, 3]] s2 = [[2, 1, 3], [1, 0, 1], [0, 1, 0]] s3_id = [[2, 1, 2], [1, 0, 1], [2, 1, 2]] s3 = replicate 3 (replicate 3 3...
1,167Abelian sandpile model/Identity
8haskell
cls94
(defprotocol Foo (foo [this]))
1,166Abstract type
6clojure
r7zg2
var abr=`Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPre...
1,165Abbreviations, easy
10javascript
ft1dg
import java.util.*; public class Abbreviations { public static void main(String[] args) { CommandList commands = new CommandList(commandTable); String input = "riG rePEAT copies put mo rest types fup. 6 poweRin"; System.out.println(" input: " + input); System.out....
1,164Abbreviations, simple
9java
7jyrj
use strict; use warnings; my ($high, $wide) = split ' ', qx(stty size); my $mask = "\0" x $wide . ("\0" . "\177" x ($wide - 2) . "\0") x ($high - 5) . "\0" x $wide; my $pile = $mask =~ s/\177/ rand() < 0.02 ? chr 64 + rand 20 : "\0" /ger; for ( 1 .. 1e6 ) { print "\e[H", $pile =~ tr/\0-\177/ 1-~/r, "\n$_"; m...
1,163Abelian sandpile model
2perl
s0jq3
(() => { 'use strict';
1,164Abbreviations, simple
10javascript
p12b7
null
1,165Abbreviations, easy
11kotlin
wx5ek
sandpile.__index = sandpile sandpile.new = function(self, vals) local inst = setmetatable({},sandpile) inst.cell, inst.dim = {}, #vals for r = 1, inst.dim do inst.cell[r] = {} for c = 1, inst.dim do inst.cell[r][c] = vals[r][c] end end return inst end sandpile.add = function(self, other) l...
1,167Abelian sandpile model/Identity
1lua
ndhi8
#!/usr/bin/lua local list1 = [[ Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWe...
1,165Abbreviations, easy
1lua
xq4wz
import numpy as np import matplotlib.pyplot as plt def iterate(grid): changed = False for ii, arr in enumerate(grid): for jj, val in enumerate(arr): if val > 3: grid[ii, jj] -= 4 if ii > 0: grid[ii - 1, jj] += 1 if ii < le...
1,163Abelian sandpile model
3python
08hsq
import java.util.Locale private const val table = "" + "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 " + "compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate " + "3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP...
1,164Abbreviations, simple
11kotlin
u5fvc
{ my @memo; sub A { my( $m, $n ) = @_; $memo[ $m ][ $n ] and return $memo[ $m ][ $n ]; $m or return $n + 1; return $memo[ $m ][ $n ] = ( $n ? A( $m - 1, A( $m, $n - 1 ) ) : A( $m - 1, 1 ) ); } }
1,162Ackermann function
2perl
36szs
abbr = { define = function(self, cmdstr) local cmd self.hash = {} for word in cmdstr:upper():gmatch("%S+") do if cmd then local n = tonumber(word) for len = n or #cmd, #cmd do self.hash[cmd:sub(1,len)] = cmd end cmd = n==nil and word or nil else ...
1,164Abbreviations, simple
1lua
54tu6
null
1,163Abelian sandpile model
15rust
inpod
from itertools import product from collections import defaultdict class Sandpile(): def __init__(self, gridtext): array = [int(x) for x in gridtext.strip().split()] self.grid = defaultdict(int, {(i for i, x in enumerate(array)}) ...
1,167Abelian sandpile model/Identity
3python
7jzrm
function ackermann( $m , $n ) { if ( $m==0 ) { return $n + 1; } elseif ( $n==0 ) { return ackermann( $m-1 , 1 ); } return ackermann( $m-1, ackermann( $m , $n-1 ) ); } echo ackermann( 3, 4 );
1,162Ackermann function
12php
p1uba
@c = (join ' ', qw< Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LP...
1,165Abbreviations, easy
2perl
l2oc5
void process(int lineNum, char buffer[]) { char days[7][64]; int i = 0, d = 0, j = 0; while (buffer[i] != 0) { if (buffer[i] == ' ') { days[d][j] = '\0'; ++d; j = 0; } else if (buffer[i] == '\n' || buffer[i] == '\r') { days[d][j] = '\0'; ...
1,168Abbreviations, automatic
5c
grd45
package main import "fmt" type Beast interface { Kind() string Name() string Cry() string } type Dog struct { kind string name string } func (d Dog) Kind() string { return d.kind } func (d Dog) Name() string { return d.name } func (d Dog) Cry() string { return "Woof" } type Cat struct { k...
1,166Abstract type
0go
s0gqa
$commands = 'Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase ...
1,165Abbreviations, easy
12php
qsgx3
public interface Interface { int method1(double value) int method2(String name) int add(int a, int b) }
1,166Abstract type
7groovy
ae21p
class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool
1,166Abstract type
8haskell
9csmo
@c = (uc join ' ', qw< add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get help 1 hexType 4 input 1 ...
1,164Abbreviations, simple
2perl
8oh0w
class Sandpile def initialize(ar) = @grid = ar def to_a = @grid.dup def + (other) res = self.to_a.zip(other.to_a).map{|row1, row2| row1.zip(row2).map(&:sum) } Sandpile.new(res) end def stable? = @grid.flatten.none?{|v| v > 3} def avalanche topple until stable? self end def == (oth...
1,167Abelian sandpile model/Identity
14ruby
hk6jx
public abstract class Abs { public abstract int method1(double value); protected abstract int method2(String name); int add(int a, int b) { return a + b; } }
1,166Abstract type
9java
tz1f9
command_table_text = user_words = def find_abbreviations_length(command_table_text): command_table = dict() input_iter = iter(command_table_text.split()) word = None try: while True: if word is None: word = next(input_iter) abbr_len = next(input...
1,164Abbreviations, simple
3python
oik81
command_table_text = \ user_words = def find_abbreviations_length(command_table_text): command_table = dict() for word in command_table_text.split(): abbr_len = sum(1 for c in word if c.isupper()) if abbr_len == 0: abbr_len = len(word) command_table[word] = abbr_len ...
1,165Abbreviations, easy
3python
2vilz
unsigned sum_proper_divisors(const unsigned n) { unsigned sum = 1; for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j); return sum; } int main(int argc, char const *argv[]) { unsigned n, c; for (n = 1, c = 0; c < 25; n += 2) if (n < sum_proper_divisors(n)) pri...
1,169Abundant odd numbers
5c
2vslo
null
1,166Abstract type
11kotlin
oij8z
#[derive(Clone)] struct Box { piles: [[u8; 3]; 3], } impl Box { fn init(piles: [[u8; 3]; 3]) -> Box { let a = Box { piles }; if a.piles.iter().any(|&row| row.iter().any(|&pile| pile >= 4)) { return a.avalanche(); } else { return a; } } fn avalan...
1,167Abelian sandpile model/Identity
15rust
kbyh5
BaseClass = {} function class ( baseClass ) local new_class = {} local class_mt = { __index = new_class } function new_class:new() local newinst = {} setmetatable( newinst, class_mt ) return newinst end if not baseClass then baseClass = BaseClass end setmetatable( ...
1,166Abstract type
1lua
inhot
cmd_table = File.read(ARGV[0]).split user_str = File.read(ARGV[1]).split user_str.each do |abbr| candidate = cmd_table.find do |cmd| cmd.count('A-Z') <= abbr.length && abbr.casecmp(cmd[0...abbr.length]).zero? end print candidate.nil?? '*error*': candidate.upcase print ' ' end puts
1,165Abbreviations, easy
14ruby
u5dvz
use std::collections::HashMap; fn main() { let commands = " Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy \ COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find \ NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWe...
1,165Abbreviations, easy
15rust
54fuq
str = RE = /(?<word1>[a-zA-Z]+)\s+(?<word2>[a-zA-Z]+)/ str = str.upcase 2.times{ str.gsub!(RE){ [ $~[:word1], $~[:word1].size, $~[:word2] ].join()} } table = Hash[*str.split].transform_values(&:to_i) test = ar = test.split.map do |w| (res = table.detect{|k,v| k.start_with?(w.upcase) && w.size >= v})? res[0]: ...
1,164Abbreviations, simple
14ruby
ndpit
object Main extends App { implicit class StrOps(i: String) { def isAbbreviationOf(target: String): Boolean = { @scala.annotation.tailrec def checkPAsPrefixOfM(p: List[Char], m: List[Char]): Boolean = (p, m) match { case (Nil, _) => true
1,165Abbreviations, easy
16scala
r73gn
package main import( "bufio" "fmt" "os" "strings" ) func distinctStrings(strs []string) []string { len := len(strs) set := make(map[string]bool, len) distinct := make([]string, 0, len) for _, str := range strs { if !set[str] { distinct = append(distinct, str) ...
1,168Abbreviations, automatic
0go
in7og
use std::collections::HashMap;
1,164Abbreviations, simple
15rust
df1ny
class Abbreviations { static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("days_of_week.txt"), "utf-8")) List<String> readAllLines = br.readLines() for (int i = 0; i < readAllLines.size(); i++) { S...
1,168Abbreviations, automatic
7groovy
qsuxp
object Main extends App { implicit class StrOps(i: String) { def isAbbreviationOf(target: String, targetMinLength: Int): Boolean = { @scala.annotation.tailrec def checkPAsPrefixOfM(p: List[Char], m: List[Char]): Boolean = (p, m) match { case (Nil, _) => true
1,164Abbreviations, simple
16scala
z3wtr
mpz_t p[N + 1]; void calc(int n) { mpz_init_set_ui(p[n], 0); for (int k = 1; k <= n; k++) { int d = n - k * (3 * k - 1) / 2; if (d < 0) break; if (k&1)mpz_add(p[n], p[n], p[d]); else mpz_sub(p[n], p[n], p[d]); d -= k; if (d < 0) break; if (k&1)mpz_add(p[n], p[n], p[d]); else mpz_sub(p[n], p[n], p...
1,1709 billion names of God the integer
5c
ndri6
import Data.List (inits, intercalate, transpose) import qualified Data.Set as S minAbbrevnLength :: [String] -> Int minAbbrevlnLength [] = 0 minAbbrevnLength xs = length . head . S.toList . head $ dropWhile ((< n) . S.size) $ S.fromList <$> transpose (inits <$> xs) where n = length xs mai...
1,168Abbreviations, automatic
8haskell
vu82k
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.List; import java.util.Map; public class Abbreviations { public static void main(String[] args) throws IOException { Path path = Paths.get("days_of_week....
1,168Abbreviations, automatic
9java
yme6g
(defn nine-billion-names [row column] (cond (<= row 0) 0 (<= column 0) 0 (< row column) 0 (= row 1) 1 :else (let [addend (nine-billion-names (dec row) (dec column)) augend (nine-billion-names (- row column) column)] (+ addend augend)))) (defn print-row ...
1,1709 billion names of God the integer
6clojure
36bzr
Array.prototype.hasDoubles = function() { let arr = this.slice(); while (arr.length > 1) { let cur = arr.shift(); if (arr.includes(cur)) return true; } return false; } function getMinAbbrLen(arr) { if (arr.length <= 1) return ''; let testArr = [], len = 0, i; do { len++; for (i = 0;...
1,168Abbreviations, automatic
10javascript
2v0lr
def ack1(M, N): return (N + 1) if M == 0 else ( ack1(M-1, 1) if N == 0 else ack1(M-1, ack1(M, N-1)))
1,162Ackermann function
3python
6y03w
null
1,168Abbreviations, automatic
11kotlin
ftkdo
function split(line) local wa = {} for i in string.gmatch(line, "%S+") do table.insert(wa, i) end return wa end
1,168Abbreviations, automatic
1lua
tzbfn
package main import ( "fmt" "strconv" ) func divisors(n int) []int { divs := []int{1} divs2 := []int{} for i := 2; i*i <= n; i++ { if n%i == 0 { j := n / i divs = append(divs, i) if i != j { divs2 = append(divs2, j) } ...
1,169Abundant odd numbers
0go
qsvxz
import 'dart:math'; List<BigInt> partitions(int n) { var cache = List<List<BigInt>>.filled(1, List<BigInt>.filled(1, BigInt.from(1)), growable: true); for(int length = cache.length; length < n + 1; length++) { var row = List<BigInt>.filled(1, BigInt.from(0), growable: true); for(int index = 1; index < leng...
1,1709 billion names of God the integer
18dart
qs2xo
package AbstractFoo; use strict; sub frob { die "abstract" } sub baz { die "abstract" } sub frob_the_baz { my $self = shift; $self->frob($self->baz()); } 1;
1,166Abstract type
2perl
grt4e
ackermann <- function(m, n) { if ( m == 0 ) { n+1 } else if ( n == 0 ) { ackermann(m-1, 1) } else { ackermann(m-1, ackermann(m, n-1)) } }
1,162Ackermann function
13r
ftwdc
class Abundant { static List<Integer> divisors(int n) { List<Integer> divs = new ArrayList<>() divs.add(1) List<Integer> divs2 = new ArrayList<>() int i = 2 while (i * i < n) { if (n % i == 0) { int j = (int) (n / i) divs.add(i) ...
1,169Abundant odd numbers
7groovy
1amp6
abstract class Abs { abstract public function method1($value); abstract protected function method2($name); function add($a, $b){ return a + b; } }
1,166Abstract type
12php
ndkig
import Data.List (nub) divisorSum :: Integral a => a -> a divisorSum n = sum . map (\i -> sum $ nub [i, n `quot` i]) . filter ((== 0) . (n `rem`)) $ takeWhile ((<= n) . (^ 2)) [1 ..] oddAbundants :: Integral a => a -> [(a, a)] oddAbundants n = [ (i, divisorSum i) | i <- [n ..], odd i, divisorSum i > i...
1,169Abundant odd numbers
8haskell
m9eyf
use strict; use utf8; binmode STDOUT, ":utf8"; sub auto_abbreviate { my($string) = @_; my @words = split ' ', $string; my $max = 0; return '' unless @words; map { $max = length($_) if length($_) > $max } @words; for $i (1..$max) { my %seen; return $i if @words == grep {!$seen{su...
1,168Abbreviations, automatic
2perl
hk3jl
class BaseQueue(object): def __init__(self): self.contents = list() raise NotImplementedError def Enqueue(self, item): raise NotImplementedError def Dequeue(self): raise NotImplementedError def Print_Contents(self): for i in self.contents: print i...
1,166Abstract type
3python
r7zgq
import java.util.ArrayList; import java.util.List; public class AbundantOddNumbers { private static List<Integer> list = new ArrayList<>(); private static List<Integer> result = new ArrayList<>(); public static void main(String[] args) { System.out.println("First 25: "); abundantOdd(1,1000...
1,169Abundant odd numbers
9java
fthdv
int a,b,c,d,e,f,g; int lo,hi,unique,show; int solutions; void bf() { for (f = lo;f <= hi; f++) if ((!unique) || ((f != a) && (f != c) && (f != d) && (f != g) && (f != e))) { b = e + f - c; if ((b >= lo) && (b <= hi) && ((!unique) || ((b != a...
1,1714-rings or 4-squares puzzle
5c
jhd70
(() => { 'use strict'; const main = () => {
1,169Abundant odd numbers
10javascript
yma6r
package main import ( "fmt" "math/big" ) func main() { intMin := func(a, b int) int { if a < b { return a } else { return b } } var cache = [][]*big.Int{{big.NewInt(1)}} cumu := func(n int) []*big.Int { for y := len(cache); y <= n; y++ { row := []*big.Int{big.NewInt(0)} for x := 1; x <= y...
1,1709 billion names of God the integer
0go
r7ngm
def partitions(c) { def p=[]; int k = 0; p[k] = c; int counter=0; def counts=[]; for (i in 0..c-1) {counts[i]=0;} while (true) { counter++; counts[p[0]-1]=counts[p[0]-1]+1; int rem_val = 0; while (k >= 0 && p[k] == 1) { rem_val += p[k]; k--...
1,1709 billion names of God the integer
7groovy
vus28
(use '[clojure.math.combinatorics] (defn rings [r & {:keys [unique]:or {unique true}}] (if unique (apply concat (map permutations (combinations r 7))) (selections r 7))) (defn four-rings [low high & {:keys [unique]:or {unique true}}] (for [[a b c d e f g] (rings (range low (inc high)):unique unique)...
1,1714-rings or 4-squares puzzle
6clojure
1a6py
import Data.List (mapAccumL) cumu :: [[Integer]] cumu = [1]: map (scanl (+) 0) rows rows :: [[Integer]] rows = snd $ mapAccumL f [] cumu where f r row = (rr, new_row) where new_row = map head rr rr = map tailKeepOne (row:r) tailKeepOne [x] = [x] tailKeepOne (_:xs) = xs sums n = cumu !! n ...
1,1709 billion names of God the integer
8haskell
08us7
require 'abstraction' class AbstractQueue abstract def enqueue(object) raise NotImplementedError end def dequeue raise NotImplementedError end end class ConcreteQueue < AbstractQueue def enqueue(object) puts end end
1,166Abstract type
14ruby
jh67x
def shortest_abbreviation_length(line, list_size): words = line.split() word_count = len(words) if word_count != list_size: raise ValueError(f'Not enough entries, expected {list_size} found {word_count}') abbreviation_length = 1 abbreviations = set() while(True): abbre...
1,168Abbreviations, automatic
3python
kb6hf
fun divisors(n: Int): List<Int> { val divs = mutableListOf(1) val divs2 = mutableListOf<Int>() var i = 2 while (i * i <= n) { if (n % i == 0) { val j = n / i divs.add(i) if (i != j) { divs2.add(j) } } i++ } ...
1,169Abundant odd numbers
11kotlin
8o40q
trait Shape { fn area(self) -> i32; }
1,166Abstract type
15rust
hkyj2