code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
function swap(arr) {
var tmp = arr[0];
arr[0] = arr[1];
arr[1] = tmp;
} | 786Generic swap | 10javascript | wz9e2 |
def gcdR
gcdR = { m, n -> m = m.abs(); n = n.abs(); n == 0 ? m: m%n == 0 ? n: gcdR(n, m%n) } | 787Greatest common divisor | 7groovy | mjpy5 |
#![feature(core)]
fn sumsqd(mut n: i32) -> i32 {
let mut sq = 0;
while n > 0 {
let d = n% 10;
sq += d*d;
n /= 10
}
sq
}
use std::num::Int;
fn cycle<T: Int>(a: T, f: fn(T) -> T) -> T {
let mut t = a;
let mut h = f(a);
while t!= h {
t = f(t);
h = f(f(... | 771Happy numbers | 15rust | korh5 |
import java.util.ArrayDeque
fun hailstone(n: Int): ArrayDeque<Int> {
val hails = when {
n == 1 -> ArrayDeque<Int>()
n% 2 == 0 -> hailstone(n / 2)
else -> hailstone(3 * n + 1)
}
hails.addFirst(n)
return hails
}
fun main(args: Array<String>) {
val hail27 = hailstone(27)
f... | 785Hailstone sequence | 11kotlin | t5hf0 |
gcd :: (Integral a) => a -> a -> a
gcd x y = gcd_ (abs x) (abs y)
where
gcd_ a 0 = a
gcd_ a b = gcd_ b (a `rem` b) | 787Greatest common divisor | 8haskell | etyai |
scala> def isHappy(n: Int) = {
| new Iterator[Int] {
| val seen = scala.collection.mutable.Set[Int]()
| var curr = n
| def next = {
| val res = curr
| curr = res.toString.map(_.asDigit).map(n => n * n).sum
| seen += res
| res
| }
| def hasNex... | 771Happy numbers | 16scala | 1dhpf |
null | 784Greatest element of a list | 1lua | etcac |
null | 786Generic swap | 11kotlin | rqigo |
public static long gcd(long a, long b){
long factor= Math.min(a, b);
for(long loop= factor;loop > 1;loop--){
if(a % loop == 0 && b % loop == 0){
return loop;
}
}
return 1;
} | 787Greatest common divisor | 9java | h8djm |
function gcd(a,b) {
a = Math.abs(a);
b = Math.abs(b);
if (b > a) {
var temp = a;
a = b;
b = temp;
}
while (true) {
a %= b;
if (a === 0) { return b; }
b %= a;
if (b === 0) { return a; }
}
} | 787Greatest common divisor | 10javascript | af610 |
function hailstone( n, print_numbers )
local n_iter = 1
while n ~= 1 do
if print_numbers then print( n ) end
if n % 2 == 0 then
n = n / 2
else
n = 3 * n + 1
end
n_iter = n_iter + 1
end
if print_numbers then print( n ) end
return... | 785Hailstone sequence | 1lua | z4kty |
tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) kotlin.math.abs(a) else gcd(b, a% b) | 787Greatest common divisor | 11kotlin | 4w057 |
func isHappyNumber(var n:Int) -> Bool {
var cycle = [Int]()
while n!= 1 &&!cycle.contains(n) {
cycle.append(n)
var m = 0
while n > 0 {
let d = n% 10
m += d * d
n = (n - d) / 10
}
n = m
}
return n == 1
}
var found = 0
var coun... | 771Happy numbers | 17swift | j0474 |
print "Hello world!" | 755Hello world/Text | 1lua | oll8h |
x, y = y, x | 786Generic swap | 1lua | 7snru |
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
function demo(a,b)
print("GCD of " .. a .. " and " .. b .. " is " .. gcd(a, b))
end
demo(100, 5)
demo(5, 100)
demo(7, 23) | 787Greatest common divisor | 1lua | gx84j |
sub max {
my $max = shift;
for (@_) { $max = $_ if $_ > $max }
return $max;
} | 784Greatest element of a list | 2perl | 9hwmn |
max($values) | 784Greatest element of a list | 12php | wzlep |
use warnings;
use strict;
my @h = hailstone(27);
print "Length of hailstone(27) = " . scalar @h . "\n";
print "[" . join(", ", @h[0 .. 3], "...", @h[-4 .. -1]) . "]\n";
my ($max, $n) = (0, 0);
for my $x (1 .. 99_999) {
@h = hailstone($x);
if (scalar @h > $max) {
($max, $n) = (scalar @h, $x);
}
}
... | 785Hailstone sequence | 2perl | kozhc |
max(values) | 784Greatest element of a list | 3python | ckx9q |
v <- c(1, 2, 100, 50, 0)
print(max(v)) | 784Greatest element of a list | 13r | 6r13e |
function hailstone($n,$seq=array()){
$sequence = $seq;
$sequence[] = $n;
if($n == 1){
return $sequence;
}else{
$n = ($n%2==0)? $n/2 : (3*$n)+1;
return hailstone($n, $sequence);
}
}
$result = hailstone(27);
echo count($result) . ' Elements.<br>';
echo 'Starting with: ' . implode(,array_slice($result,0,4)) .'... | 785Hailstone sequence | 12php | 3gbzq |
values.max | 784Greatest element of a list | 14ruby | 2pslw |
fn main() {
let nums = [1,2,39,34,20];
println!("{:?}", nums.iter().max());
println!("{}", nums.iter().max().unwrap());
} | 784Greatest element of a list | 15rust | v102t |
($y, $x) = ($x, $y); | 786Generic swap | 2perl | dvrnw |
def noSweat(list: Int*) = list.max | 784Greatest element of a list | 16scala | 4wi50 |
function swap(&$a, &$b) {
list($a, $b) = array($b, $a);
} | 786Generic swap | 12php | j0d7z |
sub gcd_iter($$) {
my ($u, $v) = @_;
while ($v) {
($u, $v) = ($v, $u % $v);
}
return abs($u);
} | 787Greatest common divisor | 2perl | il5o3 |
def hailstone(n):
seq = [n]
while n>1:
n = 3*n + 1 if n & 1 else n
seq.append(n)
return seq
if __name__ == '__main__':
h = hailstone(27)
assert len(h)==112 and h[:4]==[27, 82, 41, 124] and h[-4:]==[8, 4, 2, 1]
print(%
max((len(hailstone(i)), i) for i in range(1,100000)... | 785Hailstone sequence | 3python | bi3kr |
function gcdIter($n, $m) {
while(true) {
if($n == $m) {
return $m;
}
if($n > $m) {
$n -= $m;
} else {
$m -= $n;
}
}
} | 787Greatest common divisor | 12php | rqoge |
makeHailstone <- function(n){
hseq <- n
while (hseq[length(hseq)] > 1){
current.value <- hseq[length(hseq)]
if (current.value %% 2 == 0){
next.value <- current.value / 2
} else {
next.value <- (3 * current.value) + 1
}
hseq <- append(hseq, next.value)
}
return(list(hseq=hseq, s... | 785Hailstone sequence | 13r | 7sdry |
if let x = [4,3,5,9,2,3].maxElement() {
print(x) | 784Greatest element of a list | 17swift | lbqc2 |
a, b = b, a | 786Generic swap | 3python | fu7de |
swap <- function(name1, name2, envir = parent.env(environment()))
{
temp <- get(name1, pos = envir)
assign(name1, get(name2, pos = envir), pos = envir)
assign(name2, temp, pos = envir)
} | 786Generic swap | 13r | oc584 |
from fractions import gcd | 787Greatest common divisor | 3python | n24iz |
def hailstone n
seq = [n]
until n == 1
n = (n.even?)? (n / 2): (3 * n + 1)
seq << n
end
seq
end
puts
hs27 = hailstone 27
p [hs27.length, hs27[0..3], hs27[-4..-1]]
n = (1 ... 100_000).max_by{|n| hailstone(n).length}
puts
puts | 785Hailstone sequence | 14ruby | 1dypw |
"%gcd%" <- function(u, v) {
ifelse(u%% v!= 0, v%gcd% (u%%v), v)
} | 787Greatest common divisor | 13r | 0m2sg |
fn hailstone(start: u32) -> Vec<u32> {
let mut res = Vec::new();
let mut next = start;
res.push(start);
while next!= 1 {
next = if next% 2 == 0 { next/2 } else { 3*next+1 };
res.push(next);
}
res
}
fn main() {
let test_num = 27;
let test_hailseq = hailstone(test_num)... | 785Hailstone sequence | 15rust | afm14 |
struct gen64 {
cothread_t giver;
cothread_t taker;
int64_t given;
void (*free)(struct gen64 *);
void *garbage;
};
inline void
yield64(struct gen64 *gen, int64_t value)
{
gen->given = value;
co_switch(gen->taker);
}
inline int64_t
next64(struct gen64 *gen)
{
gen->taker = co_active();
co_switch(gen->giver)... | 788Generator/Exponential | 5c | ocv80 |
a, b = b, a | 786Generic swap | 14ruby | z4htw |
object HailstoneSequence extends App {
def hailstone(n: Int): Stream[Int] =
n #:: (if (n == 1) Stream.empty else hailstone(if (n % 2 == 0) n / 2 else n * 3 + 1))
val nr = args.headOption.map(_.toInt).getOrElse(27)
val collatz = hailstone(nr)
println(s"Use the routine to show that the hailstone sequence for... | 785Hailstone sequence | 16scala | x3lwg |
fn generic_swap<'a, T>(var1: &'a mut T, var2: &'a mut T) {
std::mem::swap(var1, var2)
} | 786Generic swap | 15rust | 3gkz8 |
40902.gcd(24140) | 787Greatest common divisor | 14ruby | furdr |
typedef int bool;
char grid[8][8];
void placeKings() {
int r1, r2, c1, c2;
for (;;) {
r1 = rand() % 8;
c1 = rand() % 8;
r2 = rand() % 8;
c2 = rand() % 8;
if (r1 != r2 && abs(r1 - r2) > 1 && abs(c1 - c2) > 1) {
grid[r1][c1] = 'K';
grid[r2][c2] = '... | 789Generate random chess position | 5c | 1dtpj |
def swap[A,B](a: A, b: B): (B, A) = (b, a) | 786Generic swap | 16scala | mj1yc |
(defn powers [m] (for [n (iterate inc 1)] (reduce * (repeat m n)))))
(def squares (powers 2))
(take 5 squares) | 788Generator/Exponential | 6clojure | t5rfv |
extern crate num;
use num::integer::gcd; | 787Greatest common divisor | 15rust | t57fd |
def gcd(a: Int, b: Int): Int = if (b == 0) a.abs else gcd(b, a % b) | 787Greatest common divisor | 16scala | 6rk31 |
char rank[9];
int pos[8];
void swap(int i,int j){
int temp = pos[i];
pos[i] = pos[j];
pos[j] = temp;
}
void generateFirstRank(){
int kPos,qPos,bPos1,bPos2,rPos1,rPos2,nPos1,nPos2,i;
for(i=0;i<8;i++){
rank[i] = 'e';
pos[i] = i;
}
do{
kPos = rand()%8;
rPos1 = rand()%8;
rPos2 = rand()%8;
}... | 790Generate Chess960 starting position | 5c | t54f4 |
package main
import (
"fmt"
"math/rand"
"strconv"
"strings"
"time"
)
var grid [8][8]byte
func abs(i int) int {
if i >= 0 {
return i
} else {
return -i
}
}
func createFen() string {
placeKings()
placePieces("PPPPPPPP", true)
placePieces("pppppppp", true)
... | 789Generate random chess position | 0go | y7h64 |
module RandomChess
( placeKings
, placePawns
, placeRemaining
, emptyBoard
, toFen
, ChessBoard
, Square (..)
, BoardState (..)
, getBoard
)
where
import Control.Monad.State (State, get, gets, put)
import Data.List (find, sortBy)
import System.Random (Random, RandomGen, StdGen, random, randomR)
type Pos = (Char, Int)... | 789Generate random chess position | 8haskell | h8iju |
(ns c960.core
(:gen-class)
(:require [clojure.string:as s]))
(def starting-rank [\ \ \ \ \ \ \ \])
(defn bishops-legal?
"True if Bishops are odd number of indicies apart"
[rank]
(odd? (apply - (cons 0 (sort > (keep-indexed #(when (= \ %2) %1) rank))))))
(defn king-legal?
"True if the king is between two... | 790Generate Chess960 starting position | 6clojure | mjhyq |
func hailstone(var n:Int) -> [Int] {
var arr = [n]
while n!= 1 {
if n% 2 == 0 {
n /= 2
} else {
n = (3 * n) + 1
}
arr.append(n)
}
return arr
}
let n = hailstone(27)
println("hailstone(27): \(n[0...3]) ... \(n[n.count-4...n.count-1]) for ... | 785Hailstone sequence | 17swift | pn6bl |
func swap<T>(inout a: T, inout b: T) {
(a, b) = (b, a)
} | 786Generic swap | 17swift | t5jfl |
import static java.lang.Math.abs;
import java.util.Random;
public class Fen {
static Random rand = new Random();
public static void main(String[] args) {
System.out.println(createFen());
}
static String createFen() {
char[][] grid = new char[8][8];
placeKings(grid);
p... | 789Generate random chess position | 9java | 5exuf |
Array.prototype.shuffle = function() {
for (let i = this.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[this[i], this[j]] = [this[j], this[i]];
}
}
function randomFEN() {
let board = [];
for (let x = 0; x < 8; x++) board.push('. . . . . . . .'.split(' '));
function getRandP... | 789Generate random chess position | 10javascript | j0o7n |
struct replace_info {
int n;
char *text;
};
int compare(const void *a, const void *b)
{
struct replace_info *x = (struct replace_info *) a;
struct replace_info *y = (struct replace_info *) b;
return x->n - y->n;
}
void generic_fizz_buzz(int max, struct replace_info *info, int info_length)
{
in... | 791General FizzBuzz | 5c | 2pplo |
DROP TABLE tbl;
CREATE TABLE tbl
(
u NUMBER,
v NUMBER
);
INSERT INTO tbl ( u, v ) VALUES ( 20, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 21, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 21, 51 );
INSERT INTO tbl ( u, v ) VALUES ( 22, 50 );
INSERT INTO tbl ( u, v ) VALUES ( 22, 55 );
commit;
WITH... | 787Greatest common divisor | 19sql | 9h1m6 |
null | 789Generate random chess position | 11kotlin | ckp98 |
int gjinv (double *a, int n, double *b)
{
int i, j, k, p;
double f, g, tol;
if (n < 1) return -1;
f = 0.;
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
g = a[j+i*n];
f += g * g;
}
}
f = sqrt(f);
tol = f * 2.2204460492503131e-016;
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
b[... | 792Gauss-Jordan matrix inversion | 5c | pniby |
null | 787Greatest common divisor | 17swift | dvgnh |
void generateGaps(unsigned long long int start,int count){
int counter = 0;
unsigned long long int i = start;
char str[100];
printf(,count,start);
while(counter<count){
sprintf(str,,i);
if((i%(10*(str[0]-'0') + i%10))==0L){
printf(,counter+1,i);
counter++;
... | 793Gapful numbers | 5c | wzfec |
use strict;
use warnings;
use feature 'say';
use utf8;
use List::AllUtils <shuffle any natatime>;
sub pick1 { return @_[rand @_] }
sub gen_FEN {
my $n = 1 + int rand 31;
my @n = (shuffle(0 .. 63))[1 .. $n];
my @kings;
KINGS: {
for my $a (@n) {
for my $b (@n) {
next unless $a !=... | 789Generate random chess position | 2perl | x3yw8 |
package main
import (
"fmt"
"math/rand"
)
type symbols struct{ k, q, r, b, n rune }
var A = symbols{'K', 'Q', 'R', 'B', 'N'}
var W = symbols{'', '', '', '', ''}
var B = symbols{'', '', '', '', ''}
var krn = []string{
"nnrkr", "nrnkr", "nrknr", "nrkrn",
"rnnkr", "rnknr", "rnkrn",
"rknnr", "rknrn"... | 790Generate Chess960 starting position | 0go | h8ojq |
(defn fix [pairs]
(map second pairs))
(defn getvalid [pairs n]
(filter (fn [p] (zero? (mod n (first p))))
(sort-by first pairs)))
(defn gfizzbuzz [pairs numbers]
(interpose "\n"
(map (fn [n] (let [f (getvalid pairs n)]
(if (empty? f)
... | 791General FizzBuzz | 6clojure | gxx4f |
import Data.List
import qualified Data.Set as Set
data Piece = K | Q | R | B | N deriving (Eq, Ord, Show)
isChess960 :: [Piece] -> Bool
isChess960 rank =
(odd . sum $ findIndices (== B) rank) && king > rookA && king < rookB
where
Just king = findIndex (== K) rank
[rookA, rookB] = findIndices (== R) r... | 790Generate Chess960 starting position | 8haskell | il2or |
import random
board = [[ for x in range(8)] for y in range(8)]
piece_list = [, , , , ]
def place_kings(brd):
while True:
rank_white, file_white, rank_black, file_black = random.randint(0,7), random.randint(0,7), random.randint(0,7), random.randint(0,7)
diff_list = [abs(rank_white - rank_black), abs(file_white ... | 789Generate random chess position | 3python | q6mxi |
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Chess960{
private static List<Character> pieces = Arrays.asList('R','B','N','Q','K','N','B','R');
public static List<Character> generateFirstRank(){
do{
Collections.shuffle(pieces);
}while(!check(pieces.toString().repl... | 790Generate Chess960 starting position | 9java | x36wy |
(defn first-digit [n] (Integer/parseInt (subs (str n) 0 1)))
(defn last-digit [n] (mod n 10))
(defn bookend-number [n] (+ (* 10 (first-digit n)) (last-digit n)))
(defn is-gapful? [n] (and (>= n 100) (zero? (mod n (bookend-number n)))))
(defn gapful-from [n] (filter is-gapful? (iterate inc n)))
(defn gapful [] (gap... | 793Gapful numbers | 6clojure | 89y05 |
void swap_row(double *a, double *b, int r1, int r2, int n)
{
double tmp, *p1, *p2;
int i;
if (r1 == r2) return;
for (i = 0; i < n; i++) {
p1 = mat_elem(a, r1, i, n);
p2 = mat_elem(a, r2, i, n);
tmp = *p1, *p1 = *p2, *p2 = tmp;
}
tmp = b[r1], b[r1] = b[r2], b[r2] = tmp;
}
void gauss_eliminate(double *a, do... | 794Gaussian elimination | 5c | ck79c |
place_kings <- function(brd){
while (TRUE) {
rank_white <- sample(1:8, 1) ; file_white <- sample(1:8, 1)
rank_black <- sample(1:8, 1) ; file_black <- sample(1:8, 1)
diff_vec <- c(abs(rank_white - rank_black), abs(file_white - file_black))
if (sum(diff_vec) > 2 | setequal(dif... | 789Generate random chess position | 13r | afz1z |
package main
import (
"fmt"
"math"
) | 788Generator/Exponential | 0go | 4ws52 |
function gcd(a: number, b: number) {
a = Math.abs(a);
b = Math.abs(b);
if (b > a) {
let temp = a;
a = b;
b = temp;
}
while (true) {
a %= b;
if (a === 0) { return b; }
b %= a;
if (b === 0) { return a; }
}
} | 787Greatest common divisor | 20typescript | 5esu4 |
function ch960startPos() {
var rank = new Array(8), | 790Generate Chess960 starting position | 10javascript | ocl86 |
int noargs(void);
int twoargs(int a,int b);
int twoargs(int ,int);
int anyargs();
int atleastoneargs(int, ...); | 795Function prototype | 5c | lb7cy |
int main() {
unsigned char lower[N];
for (size_t i = 0; i < N; i++) {
lower[i] = i + 'a';
}
return EXIT_SUCCESS;
} | 796Generate lower case ASCII alphabet | 5c | z4ltx |
import Data.List.Ordered
powers :: Int -> [Int]
powers m = map (^ m) [0..]
squares :: [Int]
squares = powers 2
cubes :: [Int]
cubes = powers 3
foo :: [Int]
foo = filter (not . has cubes) squares
main :: IO ()
main = print $ take 10 $ drop 20 foo | 788Generator/Exponential | 8haskell | q69x9 |
object Chess960 : Iterable<String> {
override fun iterator() = patterns.iterator()
private operator fun invoke(b: String, e: String) {
if (e.length <= 1) {
val s = b + e
if (s.is_valid()) patterns += s
} else {
for (i in 0 until e.length) {
in... | 790Generate Chess960 starting position | 11kotlin | pndb6 |
(declare foo) | 795Function prototype | 6clojure | 4wp5o |
package main
import "fmt"
type vector = []float64
type matrix []vector
func (m matrix) inverse() matrix {
le := len(m)
for _, v := range m {
if len(v) != le {
panic("Not a square matrix")
}
}
aug := make(matrix, le)
for i := 0; i < le; i++ {
aug[i] = make(vecto... | 792Gauss-Jordan matrix inversion | 0go | 6rg3p |
null | 790Generate Chess960 starting position | 1lua | 1dfpo |
package main
import "fmt"
type FCNode struct {
name string
weight int
coverage float64
children []*FCNode
parent *FCNode
}
func newFCN(name string, weight int, coverage float64) *FCNode {
return &FCNode{name, weight, coverage, nil, nil}
}
func (n *FCNode) addChildren(nodes []*FCNode)... | 797Functional coverage tree | 0go | pnqbg |
def hasNK( board, a, b )
for g in -1 .. 1
for f in -1 .. 1
aa = a + f; bb = b + g
if aa.between?( 0, 7 ) && bb.between?( 0, 7 )
p = board[aa + 8 * bb]
if p == || p == ; return true; end
end
end
end
return false
end
def gen... | 789Generate random chess position | 14ruby | 0mcsu |
isMatrix xs = null xs || all ((== (length.head $ xs)).length) xs
isSquareMatrix xs = null xs || all ((== (length xs)).length) xs
mult:: Num a => [[a]] -> [[a]] -> [[a]]
mult uss vss = map ((\xs -> if null xs then [] else foldl1 (zipWith (+)) xs). zipWith (\vs u -> map (u*) vs) vss) uss
matI::(Num a) => Int -> [[a]]
... | 792Gauss-Jordan matrix inversion | 8haskell | j0s7g |
(map char (range (int \a) (inc (int \z)))) | 796Generate lower case ASCII alphabet | 6clojure | 9h4ma |
import Data.Bifunctor (first)
import Data.Bool (bool)
import Data.Char (isSpace)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Tree (Forest, Tree (..), foldTree)
import Numeric (showFFloat)
import System.Directory (doesFileExist)
data Coverage = C... | 797Functional coverage tree | 8haskell | fumd1 |
int n, w, h = 45, *x, *y, cnt = 0;
char *b;
inline int rnd(int a) { return (rand()/(RAND_MAX/a))%a; }
void show_board()
{
int i, j;
for (puts(), i = 0; i < h; i++, putchar('\n'))
for (j = 0; j < w; j++, putchar(' '))
printf(B(i, j) == '*' ?
C(i - 1, j) ? :
: , B(i, j));
}
void init()
{
int i, j;... | 798Galton box animation | 5c | lb4cy |
use std::fmt::Write;
use rand::{Rng, distributions::{Distribution, Standard}};
const EMPTY: u8 = b'.';
#[derive(Clone, Debug)]
struct Board {
grid: [[u8; 8]; 8],
}
impl Distribution<Board> for Standard {
fn sample<R: Rng +?Sized>(&self, rng: &mut R) -> Board {
let mut board = Board::empty();
... | 789Generate random chess position | 15rust | 89l07 |
import scala.math.abs
import scala.util.Random
object RandomFen extends App {
val rand = new Random
private def createFen = {
val grid = Array.ofDim[Char](8, 8)
def placeKings(grid: Array[Array[Char]]): Unit = {
var r1, c1, r2, c2 = 0
do {
r1 = rand.nextInt(8)
c1 = rand.nextIn... | 789Generate random chess position | 16scala | n2uic |
import java.util.function.LongSupplier;
import static java.util.stream.LongStream.generate;
public class GeneratorExponential implements LongSupplier {
private LongSupplier source, filter;
private long s, f;
public GeneratorExponential(LongSupplier source, LongSupplier filter) {
this.source = sour... | 788Generator/Exponential | 9java | pntb3 |
(() => {
'use strict'; | 797Functional coverage tree | 10javascript | dvynu |
class Fen {
public createFen() {
let grid: string[][];
grid = [];
for (let r = 0; r < 8; r++) {
grid[r] = [];
for (let c = 0; c < 8; c++) {
grid[r][c] = "0";
}
}
this.placeKings(grid);
this.placePieces(grid, "PPP... | 789Generate random chess position | 20typescript | 9hbmb |
null | 792Gauss-Jordan matrix inversion | 9java | ua1vv |
package main
import (
"fmt"
)
const numbers = 3
func main() { | 791General FizzBuzz | 0go | q66xz |
function PowersGenerator(m) {
var n=0;
while(1) {
yield Math.pow(n, m);
n += 1;
}
}
function FilteredGenerator(g, f){
var value = g.next();
var filter = f.next();
while(1) {
if( value < filter ) {
yield value;
value = g.next();
} else if ( value > filter ) {
filter = f.next();
} else {
va... | 788Generator/Exponential | 10javascript | x3mw9 |
null | 797Functional coverage tree | 11kotlin | et8a4 |
struct functionInfo {
char* name;
int timesCalled;
char marked;
};
void addToList(struct functionInfo** list, struct functionInfo toAdd, \
size_t* numElements, size_t* allocatedSize)
{
static const char* keywords[32] = {, , , , , \
, , , , \
... | 799Function frequency | 5c | 7sbrg |
def log = ''
(1..40).each {Integer value -> log +=(value %3 == 0) ? (value %5 == 0)? 'FIZZBUZZ\n':(value %7 == 0)? 'FIZZBAXX\n':'FIZZ\n'
:(value %5 == 0) ? (value %7 == 0)? 'BUZBAXX\n':'BUZZ\n'
:(value %7 == 0) ?'BAXX\n'
... | 791General FizzBuzz | 7groovy | 1ddp6 |
sub rnd($) { int(rand(shift)) }
sub empties { grep !$_[0][$_], 0 .. 7 }
sub chess960 {
my @s = (undef) x 8;
@s[2*rnd(4), 1 + 2*rnd(4)] = qw/B B/;
for (qw/Q N N/) {
my @idx = empties \@s;
$s[$idx[rnd(@idx)]] = $_;
}
@s[empties \@s] = qw/R K R/;
@s
}
print "@{[chess960]}\n" for 0 .. 10; | 790Generate Chess960 starting position | 2perl | y7j6u |
func a() | 795Function prototype | 0go | x3dwf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.