code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
.startswith()
.endswith()
in
in
loc = .find()
loc = .find()
loc = .find(,loc+1) | 188String matching | 3python | yne6q |
s <- "abcdefgh"
n <- 2; m <- 2; char <- 'd'; chars <- 'cd'
substring(s, n, n + m)
substring(s, n)
substring(s, 1, nchar(s)-1)
indx <- which(strsplit(s, '')[[1]]%in% strsplit(char, '')[[1]])
substring(s, indx, indx + m)
indx <- which(strsplit(s, '')[[1]]%in% strsplit(chars, '')[[1]])[1]
substring(s, indx, indx + m) | 183Substring | 13r | 23dlg |
use utf8;
use Encode qw(encode);
print length encode 'UTF-8', "Hello, world! ";
print length encode 'UTF-16', "Hello, world! "; | 190String length | 2perl | 3obzs |
<?php
foreach (array('mse', '', 'Jos') as $s1) {
printf('String measured with strlen:%d mb_strlen:%s grapheme_strlen%s%s',
$s1, strlen($s1),mb_strlen($s1), grapheme_strlen($s1), PHP_EOL);
} | 190String length | 12php | pg6ba |
puts (1..1000).inject{ |sum, x| sum + 1.0 / x ** 2 } | 171Sum of a series | 14ruby | dstns |
.downcase
.upcase
.swapcase
.capitalize | 189String case | 14ruby | t0kf2 |
fn main() {
println!("{}", "jalapeo".to_uppercase()); | 189String case | 15rust | z8bto |
val s="alphaBETA"
println(s.toUpperCase) | 189String case | 16scala | yna63 |
p 'abcd'.start_with?('ab')
p 'abcd'.end_with?('ab')
p 'abab'.include?('bb')
p 'abab'.include?('ab')
p 'abab'['bb']
p 'abab'['ab']
p 'abab'.index('bb')
p 'abab'.index('ab')
p 'abab'.index('ab', 1)
p 'abab'.rindex('ab') | 188String matching | 14ruby | 9fxmz |
const LOWER: i32 = 1;
const UPPER: i32 = 1000; | 171Sum of a series | 15rust | f0zd6 |
fn print_match(possible_match: Option<usize>) {
match possible_match {
Some(match_pos) => println!("Found match at pos {}", match_pos),
None => println!("Did not find any matches")
}
}
fn main() {
let s1 = "abcd";
let s2 = "abab";
let s3 = "ab"; | 188String matching | 15rust | ctq9z |
scala> 1 to 1000 map (x => 1.0 / (x * x)) sum
res30: Double = 1.6439345666815615 | 171Sum of a series | 16scala | 3iyzy |
"abcd".startsWith("ab") | 188String matching | 16scala | v682s |
str = 'abcdefgh'
n = 2
m = 3
puts str[n, m]
puts str[n..m]
puts str[n..-1]
puts str[0..-2]
puts str[str.index('d'), m]
puts str[str.index('de'), m]
puts str[/a.*d/] | 183Substring | 14ruby | rlygs |
print len('ascii') | 190String length | 3python | 6ip3w |
let s = "abcdef";
let n = 2;
let m = 3; | 183Substring | 15rust | 72mrc |
a <- "m\u00f8\u00f8se"
print(nchar(a, type="bytes")) | 190String length | 13r | fsjdc |
DECLARE @s VARCHAR(10)
SET @s = 'alphaBETA'
print UPPER(@s)
print LOWER(@s) | 189String case | 19sql | ctx9p |
var str = "Hello, playground"
str.hasPrefix("Hell") | 188String matching | 17swift | mdwyk |
object Substring { | 183Substring | 16scala | k5lhk |
CREATE TABLE t1 (n REAL);
-- this is postgresql specific, fill the table
INSERT INTO t1 (SELECT generate_series(1,1000)::REAL);
WITH tt AS (
SELECT 1/(n*n) AS recip FROM t1
) SELECT SUM(recip) FROM tt; | 171Sum of a series | 19sql | mfcyl |
import Foundation
println("alphaBETA".uppercaseString)
println("alphaBETA".lowercaseString)
println("foO BAr".capitalizedString) | 189String case | 17swift | fshdk |
func sumSeries(var n: Int) -> Double {
var ret: Double = 0
for i in 1...n {
ret += (1 / pow(Double(i), 2))
}
return ret
}
output: 1.64393456668156 | 171Sum of a series | 17swift | nqfil |
.bytesize | 190String length | 14ruby | mdayj |
fn main() {
let s = ""; | 190String length | 15rust | 9femm |
object StringLength extends App {
val s1 = "mse"
val s3 = List("\uD835\uDD18", "\uD835\uDD2B", "\uD835\uDD26",
"\uD835\uDD20", "\uD835\uDD2C", "\uD835\uDD21", "\uD835\uDD22").mkString
val s4 = "J\u0332o\u0332s\u0332e\u0301\u0332"
List(s1, s3, s4).foreach(s => println(
s"The string: $s, characterl... | 190String length | 16scala | 23qlb |
let string = "Hello, Swift language"
let (n, m) = (5, 4) | 183Substring | 17swift | gc649 |
VALUES LENGTH('mse', CODEUNITS16);
VALUES LENGTH('mse', CODEUNITS32);
VALUES CHARACTER_LENGTH('mse', CODEUNITS32);
VALUES LENGTH2('mse');
VALUES LENGTH4('mse');
VALUES LENGTH('', CODEUNITS16);
VALUES LENGTH('', CODEUNITS32);
VALUES CHARACTER_LENGTH('', CODEUNITS32);
VALUES LENGTH2('');
VALUES LENGTH4('');
VALUES LENGTH... | 190String length | 19sql | 5m8u3 |
let numberOfCharacters = "mse".characters.count | 190String length | 17swift | yn16e |
typedef struct stirling_cache_tag {
int max;
int* values;
} stirling_cache;
int stirling_number2(stirling_cache* sc, int n, int k) {
if (k == n)
return 1;
if (k == 0 || k > n || n > sc->max)
return 0;
return sc->values[n*(n-1)/2 + k - 1];
}
bool stirling_cache_create(stirling_cache... | 191Stirling numbers of the second kind | 5c | ejmav |
package main
import (
"fmt"
"math/big"
)
func main() {
limit := 100
last := 12
s2 := make([][]*big.Int, limit+1)
for n := 0; n <= limit; n++ {
s2[n] = make([]*big.Int, limit+1)
for k := 0; k <= limit; k++ {
s2[n][k] = new(big.Int)
}
s2[n][n].SetInt64... | 191Stirling numbers of the second kind | 0go | 9famt |
import Text.Printf (printf)
import Data.List (groupBy)
import qualified Data.MemoCombinators as Memo
stirling2 :: Integral a => (a, a) -> a
stirling2 = Memo.pair Memo.integral Memo.integral f
where
f (n, k)
| n == 0 && k == 0 = 1
| (n > 0 && k == 0) || (n == 0 && k > 0) = 0
| n == k = 1
|... | 191Stirling numbers of the second kind | 8haskell | b4zk2 |
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
public class SterlingNumbersSecondKind {
public static void main(String[] args) {
System.out.println("Stirling numbers of the second kind:");
int max = 12;
System.out.printf("n/k");
for ( int n = 0 ; n <= ... | 191Stirling numbers of the second kind | 9java | gco4m |
package main
import (
"fmt"
"log"
"math"
)
type Matrix [][]float64
func (m Matrix) rows() int { return len(m) }
func (m Matrix) cols() int { return len(m[0]) }
func (m Matrix) add(m2 Matrix) Matrix {
if m.rows() != m2.rows() || m.cols() != m2.cols() {
log.Fatal("Matrices must have the same d... | 192Strassen's algorithm | 0go | lzecw |
import java.math.BigInteger
fun main() {
println("Stirling numbers of the second kind:")
val max = 12
print("n/k")
for (n in 0..max) {
print("%10d".format(n))
}
println()
for (n in 0..max) {
print("%-3d".format(n))
for (k in 0..n) {
print("%10s".format(st... | 191Stirling numbers of the second kind | 11kotlin | 23xli |
use strict;
use warnings;
use bigint;
use feature 'say';
use feature 'state';
no warnings 'recursion';
use List::Util qw(max);
sub Stirling2 {
my($n, $k) = @_;
my $n1 = $n - 1;
return 1 if $n1 == $k;
return 0 unless $n1 && $k;
state %seen;
return ($seen{"{$n1}|{$k}" } //= Stirling2($n1,$k ... | 191Stirling numbers of the second kind | 2perl | sp2q3 |
from __future__ import annotations
from itertools import chain
from typing import List
from typing import NamedTuple
from typing import Optional
class Shape(NamedTuple):
rows: int
cols: int
class Matrix(List):
@classmethod
def block(cls, blocks) -> Matrix:
m = Matrix()
... | 192Strassen's algorithm | 3python | oeu81 |
null | 192Strassen's algorithm | 17swift | iw5o0 |
computed = {}
def sterling2(n, k):
key = str(n) + + str(k)
if key in computed.keys():
return computed[key]
if n == k == 0:
return 1
if (n > 0 and k == 0) or (n == 0 and k > 0):
return 0
if n == k:
return 1
if k > n:
return 0
result = k * sterling2(n - 1, k) + sterling2(n - 1, k - 1)
computed[key] =... | 191Stirling numbers of the second kind | 3python | 01vsq |
int main()
{
char str[24]=;
char *cstr=;
char *cstr2=;
int x=0;
if(sizeof(str)>strlen(str)+strlen(cstr)+strlen(cstr2))
{
strcat(str,cstr);
x=strlen(str);
sprintf(&str[x],,cstr2);
pri... | 193String append | 5c | ynk6f |
@memo = {}
def sterling2(n, k)
key = [n,k]
return @memo[key] if @memo.key?(key)
return 1 if n.zero? and k.zero?
return 0 if n.zero? or k.zero?
return 1 if n == k
return 0 if k > n
res = k * sterling2(n-1, k) + sterling2(n - 1, k-1)
@memo[key] = res
end
r = (0..12)
puts
puts %11d
r.each do |row|
p... | 191Stirling numbers of the second kind | 14ruby | oe58v |
const char *table[ROWS][COLS] =
{
{ , , , , , , , , , },
{ , , , NULL, , , , NULL, , },
{ , , , , , , , , , },
{ , , , , , , , , , NPRX }
};
GHashTable *create_table_from_array(const char *table[ROWS][COLS], bool is_encoding)
{
char buf[16];
GHashTable *r = g_hash_table_new_full(g_str_hash, g... | 194Straddling checkerboard | 5c | v6e2o |
typedef struct stirling_cache_tag {
int max;
int* values;
} stirling_cache;
int stirling_number1(stirling_cache* sc, int n, int k) {
if (k == 0)
return n == 0 ? 1 : 0;
if (n > sc->max || k > n)
return 0;
return sc->values[n*(n-1)/2 + k - 1];
}
bool stirling_cache_create(stirling_ca... | 195Stirling numbers of the first kind | 5c | uyev4 |
user=> (def s "app")
#'user/s
user=> s
"app"
user=> (def s (str s "end"))
#'user/s
user=> s
"append" | 193String append | 6clojure | 23el1 |
void merge(FILE* f1, FILE* f2, FILE* out)
{
int b1;
int b2;
if(f1) GET(1)
if(f2) GET(2)
while ( f1 && f2 )
{
if ( b1 <= b2 ) PUT(1)
else PUT(2)
}
while (f1 ) PUT(1)
while (f2 ) PUT(2)
}
int main(int argc, char* argv[])
{
if ( argc < 3 || argc > 3 )
... | 196Stream merge | 5c | gcx45 |
package main
import (
"fmt"
"strings"
)
func main() {
key := `
8752390146
ET AON RIS
5BC/FGHJKLM
0PQD.VWXYZU`
p := "you have put on 7.5 pounds since I saw you."
fmt.Println(p)
c := enc(key, p)
fmt.Println(c)
fmt.Println(dec(key, c))
}
func enc(bd, pt string) (ct string) {
enc :=... | 194Straddling checkerboard | 0go | sp9qa |
import Data.Char
import Data.Map
charToInt :: Char -> Int
charToInt c = ord c - ord '0'
decodeChar :: String -> (Char,String)
decodeChar ('7':'9':r:rs) = (r,rs)
decodeChar ('7':r:rs) = ("PQUVWXYZ. " !! charToInt r, rs)
decodeChar ('3':r:rs) = ("ABCDFGIJKN" !! charToInt r, rs)
decodeChar (r:rs) = ("H... | 194Straddling checkerboard | 8haskell | 9fbmo |
package main
import (
"fmt"
"math/big"
)
func main() {
limit := 100
last := 12
unsigned := true
s1 := make([][]*big.Int, limit+1)
for n := 0; n <= limit; n++ {
s1[n] = make([]*big.Int, limit+1)
for k := 0; k <= limit; k++ {
s1[n][k] = new(big.Int)
}
... | 195Stirling numbers of the first kind | 0go | 019sk |
import Text.Printf (printf)
import Data.List (groupBy)
import qualified Data.MemoCombinators as Memo
stirling1 :: Integral a => (a, a) -> a
stirling1 = Memo.pair Memo.integral Memo.integral f
where
f (n, k)
| n == 0 && k == 0 = 1
| n > 0 && k == 0 = 0
| k > n = 0
| otherwise =... | 195Stirling numbers of the first kind | 8haskell | ctb94 |
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
public class SterlingNumbersFirstKind {
public static void main(String[] args) {
System.out.println("Unsigned Stirling numbers of the first kind:");
int max = 12;
System.out.printf("n/k");
for ( int n = 0 ... | 195Stirling numbers of the first kind | 9java | z8gtq |
import java.util.HashMap;
import java.util.Map;
import java.util.regex.*;
public class StraddlingCheckerboard {
final static String[] keyvals = {"H:0", "O:1", "L:2", "M:4", "E:5", "S:6",
"R:8", "T:9", "A:30", "B:31", "C:32", "D:33", "F:34", "G:35", "I:36",
"J:37", "K:38", "N:39", "P:70", "Q:71", "... | 194Straddling checkerboard | 9java | t0gf9 |
package main
import (
"container/heap"
"fmt"
"io"
"log"
"os"
"strings"
)
var s1 = "3 14 15"
var s2 = "2 17 18"
var s3 = ""
var s4 = "2 3 5 7"
func main() {
fmt.Print("merge2: ")
merge2(
os.Stdout,
strings.NewReader(s1),
strings.NewReader(s2))
fmt.Println()
... | 196Stream merge | 0go | iwlog |
<script>
var alphabet=new Array("ESTONIA R","BCDFGHJKLM","PQUVWXYZ./") | 194Straddling checkerboard | 10javascript | mdkyv |
import java.math.BigInteger
fun main() {
println("Unsigned Stirling numbers of the first kind:")
val max = 12
print("n/k")
for (n in 0..max) {
print("%10d".format(n))
}
println()
for (n in 0..max) {
print("%-3d".format(n))
for (k in 0..n) {
print("%10s".f... | 195Stirling numbers of the first kind | 11kotlin | iw2o4 |
import Control.Monad.Trans.Resource (runResourceT)
import qualified Data.ByteString.Char8 as BS
import Data.Conduit (($$), (=$=))
import Data.Conduit.Binary (sinkHandle, sourceFile)
import qualified Data.Conduit.Binary as Conduit
import qualified Da... | 196Stream merge | 8haskell | v612k |
double mean(double* values, int n)
{
int i;
double s = 0;
for ( i = 0; i < n; i++ )
s += values[i];
return s / n;
}
double stddev(double* values, int n)
{
int i;
double average = mean(values,n);
double s = 0;
for ( i = 0; i < n; i++ )
s += (values[i] - average) * (val... | 197Statistics/Normal distribution | 5c | 23blo |
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class StreamMerge {
private static <T extends Comparable<T>> void merge2(Iterator<T> i1, Iterator<T> i2) {
T a = null, b = null;
while (i1.hasNext() || i2.hasNext()) {
if (null == a && i1.hasNext()) {
... | 196Stream merge | 9java | yn76g |
null | 194Straddling checkerboard | 11kotlin | oe28z |
use strict;
use warnings;
use bigint;
use feature 'say';
use feature 'state';
no warnings 'recursion';
use List::Util qw(max);
sub Stirling1 {
my($n, $k) = @_;
return 1 unless $n || $k;
return 0 unless $n && $k;
state %seen;
return ($seen{"{$n-1}|{$k-1}"} //= Stirling1($n-1, $k-1)) +
($s... | 195Stirling numbers of the first kind | 2perl | rlsgd |
null | 196Stream merge | 11kotlin | fsudo |
local brd = { "HOL MES RT", "ABCDFGIJKN", "PQUVWXYZ./" }
local dicE, dicD, s1, s2 = {}, {}, 0, 0
function dec( txt )
local i, numb, s, t, c = 1, false
while( i < #txt ) do
c = txt:sub( i, i )
if not numb then
if tonumber( c ) == s1 then
i = i + 1; s = string.format( ... | 194Straddling checkerboard | 1lua | iwvot |
s := "foo"
s += "bar" | 193String append | 0go | 1rzp5 |
class Append{
static void main(String[] args){
def c="Hello ";
def d="world";
def e=c+d;
println(e);
}
} | 193String append | 7groovy | jvi7o |
use strict;
use warnings;
use English;
use String::Tokenizer;
use Heap::Simple;
my $stream1 = <<"END_STREAM_1";
Integer vel neque ligula. Etiam a ipsum a leo eleifend viverra sit amet ac
arcu. Suspendisse odio libero, ullamcorper eu sem vitae, gravida dignissim
ipsum. Aenean tincidunt commodo feugiat. Nunc viverra dol... | 196Stream merge | 2perl | hu8jl |
main = putStrLn ("Hello" ++ "World") | 193String append | 8haskell | t0rf7 |
use strict;
use warnings;
use feature 'say';
use List::Util <min max>;
my(%encode,%decode,@table);
sub build {
my($u,$v,$alphabet) = @_;
my(@flat_board,%p2c,%c2p);
my $numeric_escape = '/';
@flat_board = split '', uc $alphabet;
splice @flat_board, min($u,$v), 0, undef;
splice @flat_board, max... | 194Straddling checkerboard | 2perl | gcs4e |
computed = {}
def sterling1(n, k):
key = str(n) + + str(k)
if key in computed.keys():
return computed[key]
if n == k == 0:
return 1
if n > 0 and k == 0:
return 0
if k > n:
return 0
result = sterling1(n - 1, k - 1) + (n - 1) * sterling1(n - 1, k)
computed[key] = result
return result
print()
MAX = 12
... | 195Stirling numbers of the first kind | 3python | 720rm |
String sa = "Hello";
sa += ", World!";
System.out.println(sa);
StringBuilder ba = new StringBuilder();
ba.append("Hello");
ba.append(", World!");
System.out.println(ba.toString()); | 193String append | 9java | 8a206 |
import heapq
import sys
sources = sys.argv[1:]
for item in heapq.merge(open(source) for source in sources):
print(item) | 196Stream merge | 3python | k5ohf |
var s1 = "Hello";
s1 += ", World!";
print(s1);
var s2 = "Goodbye"; | 193String append | 10javascript | fsgdg |
int icmp(const void *a, const void *b)
{
return *(const int*)a < *(const int*)b ? -1 : *(const int*)a > *(const int*)b;
}
void leaf_plot(int *x, int len)
{
int i, j, d;
qsort(x, len, sizeof(int), icmp);
i = x[0] / 10 - 1;
for (j = 0; j < len; j++) {
d = x[j] / 10;
while (d > i) printf(, j ? : , ++i);
pri... | 198Stem-and-leaf plot | 5c | nxci6 |
$key2val = [=>, =>, =>, =>, =>, =>, =>,
=>, =>, =>, =>, =>, =>, =>, =>,
=>, =>, =>, =>, =>, =>, =>,
=>, =>, =>, =>, =>, =>, =>,
=>, =>, =>, =>, =>, =>, =>,
=>, =>];
$val2key = array_flip($key2val);
function encode(string $s) : string {
global $key2val;
$callback = fun... | 194Straddling checkerboard | 12php | nxuig |
const char *states[] = {
, , , , ,
, , , ,
, , ,
,
, , ,
, , , ,
, , ,
, , , ,
, , , ,
, , , ,
, , , ,
, , ,
, ,
, , , ,
, , ,
, , ,
};
int n_states = sizeof(states)/sizeof(*states);
typedef struct { unsigned char c[26]; const char *name[2]; } letters;
void count_letters(letters *l, const char ... | 199State name puzzle | 5c | jvx70 |
int start
{
printf();
return 0;
} | 200Start from a main routine | 5c | a7o11 |
$cache = {}
def sterling1(n, k)
if n == 0 and k == 0 then
return 1
end
if n > 0 and k == 0 then
return 0
end
if k > n then
return 0
end
key = [n, k]
if $cache[key] then
return $cache[key]
end
value = sterling1(n - 1, k - 1) + (n - 1) * sterling1(n ... | 195Stirling numbers of the first kind | 14ruby | huojx |
fun main(args: Array<String>) {
var s = "a"
s += "b"
s += "c"
println(s)
println("a" + "b" + "c")
val a = "a"
val b = "b"
val c = "c"
println("$a$b$c")
} | 193String append | 11kotlin | whyek |
package main
import (
"fmt"
"math"
"math/rand"
"strings"
) | 197Statistics/Normal distribution | 0go | qb3xz |
def stream_merge(*files)
fio = files.map{|fname| open(fname)}
merge(fio.map{|io| [io, io.gets]})
end
def merge(fdata)
until fdata.empty?
io, min = fdata.min_by{|_,data| data}
puts min
if (next_data = io.gets).nil?
io.close
fdata.delete([io, min])
else
i = fdata.index{|x,_| x == ... | 196Stream merge | 14ruby | pgnbh |
MODULE MainProcedure
IMPORT StdLog
PROCEDURE Do*
BEGIN
StdLog.String("From Do")
END Do
PROCEDURE Main*
BEGIN
StdLog.String("From Main")
END Main
END MainProcedure. | 200Start from a main routine | 6clojure | sptqr |
T = [[, , , , , , , , , , ],
[, , , , , , , , , , ],
[, , , , , , , , , , ],
[, , , , , , , , , , ]]
def straddle(s):
return .join(L[0]+T[0][L.index(c)] for c in s.upper() for L in T if c in L)
def unstraddle(s):
s = iter(s)
for c in s:
if c in [T[2][0], T[3][0]]:
... | 194Straddling checkerboard | 3python | rl0gq |
import Data.Map (Map, empty, insert, findWithDefault, toList)
import Data.Maybe (fromMaybe)
import Text.Printf (printf)
import Data.Function (on)
import Data.List (sort, maximumBy, minimumBy)
import Control.Monad.Random (RandomGen, Rand, evalRandIO, getRandomR)
import Control.Monad (replicateM)
getNorm :: RandomGen g... | 197Statistics/Normal distribution | 8haskell | md7yf |
def mergeN[A : Ordering](is: Iterator[A]*): Iterator[A] = is.reduce((a, b) => merge2(a, b))
def merge2[A : Ordering](i1: Iterator[A], i2: Iterator[A]): Iterator[A] = {
merge2Buffered(i1.buffered, i2.buffered)
}
def merge2Buffered[A](i1: BufferedIterator[A], i2: BufferedIterator[A])(implicit ord: Ordering[A]): Itera... | 196Stream merge | 16scala | whzes |
(ns clojure-sandbox.statenames
(:require [clojure.data.csv:as csv]
[clojure.java.io:as io]
[clojure.string:refer [lower-case]]
[clojure.math.combinatorics:as c]
[clojure.pprint:as pprint]))
(def made-up-states ["New Kory" "Wen Kory" "York New" "Kory New" "New Kory"])
... | 199State name puzzle | 6clojure | 1ropy |
package main
import "fmt"
var count = 0
func foo() {
fmt.Println("foo called")
}
func init() {
fmt.Println("first init called")
foo()
}
func init() {
fmt.Println("second init called")
main()
}
func main() {
count++
fmt.Println("main called when count is", count)
} | 200Start from a main routine | 0go | md4yi |
function string:show ()
print(self)
end
function string:append (s)
self = self .. s
end
x = "Hi "
x:show()
x:append("there!")
x:show() | 193String append | 1lua | xkmwz |
import static java.lang.Math.*;
import static java.util.Arrays.stream;
import java.util.Locale;
import java.util.function.DoubleSupplier;
import static java.util.stream.Collectors.joining;
import java.util.stream.DoubleStream;
import static java.util.stream.IntStream.range;
public class Test implements DoubleSupplier ... | 197Statistics/Normal distribution | 9java | fsvdv |
(def data
[12 127 28 42 39 113 42 18 44 118 44 37 113 124 37 48 127 36 29 31 125
139 131 115 105 132 104 123 35 113 122 42 117 119 58 109 23 105 63 27
44 105 99 41 128 121 116 125 32 61 37 127 29 113 121 58 114 126 53 114
96 25 109 7 31 141 46 13 27 43 117 116 27 7 68 40 31 115 124 42 128 146
52 71 118 11... | 198Stem-and-leaf plot | 6clojure | 3o5zr |
Welcome to Kotlin version 1.1.1 (JRE 1.8.0_121-b13)
Type:help for help,:quit for quit
>>> println("Look no main!")
Look no main!
>>>:quit | 200Start from a main routine | 11kotlin | lz7cp |
typedef unsigned int uint;
uint f(uint n)
{
return n < 2 ? n : (n&1) ? f(n/2) + f(n/2 + 1) : f(n/2);
}
uint gcd(uint a, uint b)
{
return a ? a < b ? gcd(b%a, a) : gcd(a%b, b) : b;
}
void find(uint from, uint to)
{
do {
uint n;
for (n = 1; f(n) != from ; n++);
printf(, from, n);
} while (++from <= to);
}
... | 201Stern-Brocot sequence | 5c | iw6o2 |
void print_stack_trace()
{
void *buffer[MAX_BT];
int n;
n = backtrace(buffer, MAX_BT);
fprintf(stderr, , n);
backtrace_symbols_fd(buffer, n, STDERR_FILENO);
}
void inner(int k)
{
print_stack_trace();
}
void middle(int x, int y)
{
inner(x*y);
}
void outer(int a, int b, int c)
{
middle(a+b, b+c);
}
... | 202Stack traces | 5c | v672o |
package main
import (
"fmt"
"unicode"
)
var states = []string{"Alabama", "Alaska", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut",
"Delaware",
"Florida", "Georgia", "Hawaii",
"Idaho", "Illinois", "Indiana", "Iowa",
"Kansas", "Kentucky", "Louisiana",
"Maine", "Maryland",... | 199State name puzzle | 0go | fsld0 |
BEGIN {...}
CHECK {...}
INIT {...}
END {...} | 200Start from a main routine | 2perl | qbfx6 |
class StraddlingCheckerboard
EncodableChars =
SortedChars = + [*..].join
def initialize(board = nil)
if board.nil?
rest = .chars.shuffle
@board = [.chars.shuffle, rest[0..9], rest[10..19]]
elsif board.chars.sort.join == SortedChars
@board = board.chars.each_slice(10).to_a
e... | 194Straddling checkerboard | 14ruby | jvo7x |
null | 197Statistics/Normal distribution | 11kotlin | 8am0q |
(doall
(map println (.dumpAllThreads (java.lang.management.ManagementFactory/getThreadMXBean) false false))) | 202Stack traces | 6clojure | rlpg2 |
import Data.Char (isLetter, toLower)
import Data.Function (on)
import Data.List (groupBy, nub, sort, sortBy)
puzzle :: [String] -> [((String, String), (String, String))]
puzzle states =
concatMap
((filter isValid . pairs) . map snd)
( filter ((> 1) . length) $
groupBy ((==) `on` fst) $
so... | 199State name puzzle | 8haskell | 4915s |
object StraddlingCheckerboard extends App {
private val dictonary = Map("H" -> "0", "O" -> "1",
"L" -> "2", "M" -> "4", "E" -> "5", "S" -> "6", "R" -> "8", "T" -> "9",
"A" -> "30", "B" -> "31", "C" -> "32", "D" -> "33", "F" -> "34", "G" -> "35",
"I" -> "36", "J" -> "37", "K" -> "38", "N" -> "39", "P" -> ... | 194Straddling checkerboard | 16scala | pgfbj |
BEGIN {
}
END {
} | 200Start from a main routine | 14ruby | 8a301 |
object PrimaryMain extends App {
Console.println("Hello World: " + (args mkString ", "))
}
object MainTheSecond extends App {
Console.println("Goodbye, World: " + (args mkString ", "))
} | 200Start from a main routine | 16scala | dq9ng |
function gaussian (mean, variance)
return math.sqrt(-2 * variance * math.log(math.random())) *
math.cos(2 * math.pi * math.random()) + mean
end
function mean (t)
local sum = 0
for k, v in pairs(t) do
sum = sum + v
end
return sum / #t
end
function std (t)
local squares, avg... | 197Statistics/Normal distribution | 1lua | oe98h |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.