code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
package main
import (
"fmt"
"math/big"
"rcu"
"sort"
)
func main() {
primes := rcu.Primes(379)
primorial := big.NewInt(1)
var fortunates []int
bPrime := new(big.Int)
for _, prime := range primes {
bPrime.SetUint64(uint64(prime))
primorial.Mul(primorial, bPrime)
... | 809Fortunate numbers | 0go | q3bxz |
import Data.Numbers.Primes (primes)
import Math.NumberTheory.Primes.Testing (isPrime)
import Data.List (nub)
primorials :: [Integer]
primorials = 1: scanl1 (*) primes
nextPrime :: Integer -> Integer
nextPrime n
| even n = head $ dropWhile (not . isPrime) [n+1, n+3..]
| even n = nextPrime (n+1)
fortunateNumbers :... | 809Fortunate numbers | 8haskell | m7dyf |
use strict;
use warnings;
use List::Util <first uniq>;
use ntheory qw<pn_primorial is_prime>;
my $upto = 50;
my @candidates;
for my $p ( map { pn_primorial($_) } 1..2*$upto ) {
push @candidates, first { is_prime($_ + $p) } 2..100*$upto;
}
my @fortunate = sort { $a <=> $b } uniq grep { is_prime $_ } @candidates;
... | 809Fortunate numbers | 2perl | 4e95d |
from sympy.ntheory.generate import primorial
from sympy.ntheory import isprime
def fortunate_number(n):
'''Return the fortunate number for positive integer n.'''
i = 3
primorial_ = primorial(n)
while True:
if isprime(primorial_ + i):
return i
i += 2
fortunate_numb... | 809Fortunate numbers | 3python | gwc4h |
require
primorials = Enumerator.new do |y|
cur = prod = 1
loop {y << prod *= (cur = GMP::Z(cur).nextprime)}
end
limit = 50
fortunates = []
while fortunates.size < limit*2 do
prim = primorials.next
fortunates << (GMP::Z(prim+2).nextprime - prim)
fortunates = fortunates.uniq.sort
end
p fortunates[0, limit] | 809Fortunate numbers | 14ruby | 7q2ri |
puts | 755Hello world/Text | 14ruby | 700ri |
fn main() {
print!("Hello world!");
} | 755Hello world/Text | 15rust | j8872 |
println("Hello world!") | 755Hello world/Text | 16scala | bnnk6 |
func multiply(a, b float64) float64 {
return a * b
} | 808Function definition | 0go | icxog |
def multiply = { x, y -> x * y } | 808Function definition | 7groovy | q3pxp |
multiply x y = x * y | 808Function definition | 8haskell | vpy2k |
SELECT 'Hello world!' text FROM dual; | 755Hello world/Text | 19sql | att1t |
public class Math
{
public static int multiply( int a, int b) { return a*b; }
public static double multiply(double a, double b) { return a*b; }
} | 808Function definition | 9java | yrd6g |
int main()
{
pid_t pid;
if (!(pid = fork())) {
usleep(10000);
printf();
} else if (pid < 0) {
err(1, );
} else {
printf(, (int)pid);
printf(, (int)wait(0));
}
return 0;
} | 810Fork | 5c | nlwi6 |
function multiply(a, b) {
return a*b;
} | 808Function definition | 10javascript | 2b6lr |
print("Hello world!") | 755Hello world/Text | 17swift | rssgg |
(require '[clojure.java.shell:as shell])
(shell/sh "echo" "foo") | 810Fork | 6clojure | 348zr |
null | 808Function definition | 11kotlin | fv0do |
package main
import (
"fmt"
"os"
)
func main() {
fmt.Printf("PID:%v\n", os.Getpid())
if len(os.Args) < 2 {
fmt.Println("Done.")
return
}
cp, err := os.StartProcess(os.Args[0], nil,
&os.ProcAttr{Files: []*os.File{nil, os.Stdout}},
)
if err != nil {
fmt.Pr... | 810Fork | 0go | rxcgm |
println "BEFORE PROCESS"
Process p = Runtime.runtime.exec('''
C:/cygwin/bin/sh -c "
/usr/bin/date +'BEFORE LOOP:%T';
for i in 1 2 3 4; do
/usr/bin/sleep 1;
/usr/bin/echo \$i;
done;
/usr/bin/date +'AFTER LOOP:%T'"
''')
p.consumeProcessOutput(System.out, System.err)
(0..<8).each {
Thread.sleep(500)
print ... | 810Fork | 7groovy | vp328 |
import System.Posix.Process
main = do
forkProcess (putStrLn "This is the new process")
putStrLn "This is the original process" | 810Fork | 8haskell | 0yps7 |
typedef uint64_t integer;
typedef struct number_names_tag {
const char* cardinal;
const char* ordinal;
} number_names;
const number_names small[] = {
{ , }, { , }, { , },
{ , }, { , }, { , },
{ , }, { , }, { , },
{ , }, { , }, { , },
{ , }, { , },
{ , }, { , },
{ , ... | 811Four is the number of letters in the ... | 5c | jsl70 |
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class RFork {
public static void main(String[] args) {
ProcessBuilder pb;
Process pp;
List<String> command;
Map<String, String> en... | 810Fork | 9java | adr1y |
package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
f := NewFourIsSeq()
fmt.Print("The lengths of the first 201 words are:")
for i := 1; i <= 201; i++ {
if i%25 == 1 {
fmt.Printf("\n%3d: ", i)
}
_, n := f.WordLen(i)
fmt.Printf("%2d", n)
}
fmt.Println()
fmt.Println("Length of sentence s... | 811Four is the number of letters in the ... | 0go | fvxd0 |
null | 810Fork | 11kotlin | h0vj3 |
import Data.Char
sentence = start ++ foldMap add (zip [2..] $ tail $ words sentence)
where
start = "Four is the number of letters in the first word of this sentence, "
add (i, w) = unwords [spellInteger (alphaLength w), "in the", spellOrdinal i ++ ", "]
alphaLength w = fromIntegral $ length $ filter isAlpha... | 811Four is the number of letters in the ... | 8haskell | 4ey5s |
function multiply( a, b )
return a * b
end | 808Function definition | 1lua | tu8fn |
import java.util.HashMap;
import java.util.Map;
public class FourIsTheNumberOfLetters {
public static void main(String[] args) {
String [] words = neverEndingSentence(201);
System.out.printf("Display the first 201 numbers in the sequence:%n%3d: ", 1);
for ( int i = 0 ; i < words.length ; i... | 811Four is the number of letters in the ... | 9java | chd9h |
local posix = require 'posix'
local pid = posix.fork()
if pid == 0 then
print("child process")
elseif pid > 0 then
print("parent process")
else
error("unable to fork")
end | 810Fork | 1lua | k8uh2 |
null | 811Four is the number of letters in the ... | 11kotlin | 340z5 |
enum fps_type {
FPS_CONST = 0,
FPS_ADD,
FPS_SUB,
FPS_MUL,
FPS_DIV,
FPS_DERIV,
FPS_INT,
};
typedef struct fps_t *fps;
typedef struct fps_t {
int type;
fps s1, s2;
double a0;
} fps_t;
fps fps_new()
{
fps x = malloc(sizeof(fps_t));
... | 812Formal power series | 5c | ad411 |
(defn ps+ [ps0 ps1]
(letfn [(+zs [ps] (concat ps (repeat:z)))
(notz? [a] (not=:z a))
(nval [a] (if (notz? a) a 0))
(z+ [a0 a1] (if (=:z a0 a1):z (+ (nval a0) (nval a1))))]
(take-while notz? (map z+ (+zs ps0) (+zs ps1)))))
(defn ps- [ps0 ps1] (ps+ ps0 (map - ps1))) | 812Formal power series | 6clojure | s6hqr |
use feature 'state';
use Lingua::EN::Numbers qw(num2en num2en_ordinal);
my @sentence = split / /, 'Four is the number of letters in the first word of this sentence, ';
sub extend_to {
my($last) = @_;
state $index = 1;
until ($
push @sentence, split ' ', num2en(alpha($sentence[$index])) . ' in the ... | 811Four is the number of letters in the ... | 2perl | pi5b0 |
FORK:
if ($pid = fork()) {
} elsif (defined($pid)) {
setsid;
close(STDOUT);
close(STDIN);
close(STDERR);
open(STDOUT, '>/dev/null');
open(STDIN, '>/dev/null');
open(STDERR, '>>/home/virtual/logs/err.log');
exit;
} elsif($! =~ /emporar/){
warn '[' . localti... | 810Fork | 2perl | z50tb |
import inflect
def count_letters(word):
count = 0
for letter in word:
if letter != ',' and letter !='-' and letter !=' ':
count += 1
return count
def split_with_spaces(sentence):
sentence_list = []
curr_word =
for c in sentence:
if c == and curr_word !=... | 811Four is the number of letters in the ... | 3python | 1n4pc |
<?php
$pid = pcntl_fork();
if ($pid == 0)
echo ;
else if ($pid > 0)
echo ;
else
echo ;
?> | 810Fork | 12php | bo5k9 |
import os
pid = os.fork()
if pid > 0:
else: | 810Fork | 3python | 348zc |
package main
import (
"fmt"
"math"
) | 812Formal power series | 0go | m7oyi |
struct NumberNames {
cardinal: &'static str,
ordinal: &'static str,
}
impl NumberNames {
fn get_name(&self, ordinal: bool) -> &'static str {
if ordinal {
return self.ordinal;
}
self.cardinal
}
}
const SMALL_NAMES: [NumberNames; 20] = [
NumberNames {
card... | 811Four is the number of letters in the ... | 15rust | wt7e4 |
p <- parallel::mcparallel({
Sys.sleep(1)
cat("\tChild pid: ", Sys.getpid(), "\n")
TRUE
})
cat("Main pid: ", Sys.getpid(), "\n")
parallel::mccollect(p)
p <- parallel:::mcfork()
if (inherits(p, "masterProcess")) {
Sys.sleep(1)
cat("\tChild pid: ", Sys.getpid(), "\n")
paral... | 810Fork | 13r | d2xnt |
newtype Series a = S { coeffs :: [a] } deriving (Eq, Show)
instance Num a => Num (Series a) where
fromInteger n = S $ fromInteger n: repeat 0
negate (S fs) = S $ map negate fs
S fs + S gs = S $ zipWith (+) fs gs
S (f:ft) * S gs@(g:gt) = S $ f*g: coeffs (S ft * S gs + S (map (f*) gt))
instance Fractional a ... | 812Formal power series | 8haskell | k82h0 |
main(){
float r=7.125;
printf(,-r);
printf(,r);
printf(,r);
printf(,-r);
printf(,r);
printf(,r);
return 0;
} | 813Formatted numeric output | 5c | icpo2 |
pid = fork
if pid
else
end | 810Fork | 14ruby | yri6n |
1/(1+.) | 812Formal power series | 9java | 4e658 |
(cl-format true "~9,3,,,'0F" 7.125) | 813Formatted numeric output | 6clojure | z5xtj |
use nix::unistd::{fork, ForkResult};
use std::process::id;
fn main() {
match fork() {
Ok(ForkResult::Parent { child, .. }) => {
println!(
"This is the original process(pid: {}). New child has pid: {}",
id(),
child
);
}
... | 810Fork | 15rust | m7nya |
import java.io.IOException
object Fork extends App {
val builder: ProcessBuilder = new ProcessBuilder()
val currentUser: String = builder.environment.get("USER")
val command: java.util.List[String] = java.util.Arrays.asList("ps", "-f", "-U", currentUser)
builder.command(command)
try {
val lines = scala.i... | 810Fork | 16scala | lktcq |
typedef char pin_t;
void halfadder(IN a, IN b, OUT s, OUT c)
{
V(s) = XOR(V(a), V(b));
V(c) = V(a) & V(b);
}
void fulladder(IN a, IN b, IN ic, OUT s, OUT oc)
{
PIN(ps); PIN(pc); PIN(tc);
halfadder(a, b, ps, pc);
halfadder(ps, ic, s, tc);
V(oc) = V(tc) | V(pc);
}
void fourbitsadder(IN a0, IN a1... | 814Four bit adder | 5c | vpd2o |
null | 812Formal power series | 11kotlin | lkdcp |
powerseries = setmetatable({
__add = function(z1, z2) return powerseries(function(n) return z1.coeff(n) + z2.coeff(n) end) end,
__sub = function(z1, z2) return powerseries(function(n) return z1.coeff(n) - z2.coeff(n) end) end,
__mul = function(z1, z2) return powerseries(function(n)
local ret = 0
for i = 0, n do
... | 812Formal power series | 1lua | 2bfl3 |
(ns rosettacode.adder
(:use clojure.test))
(defn xor-gate [a b]
(or (and a (not b)) (and b (not a))))
(defn half-adder [a b]
"output: (S C)"
(cons (xor-gate a b) (list (and a b))))
(defn full-adder [a b c]
"output: (C S)"
(let [HA-ca (half-adder c a)
HA-ca->sb (half-adder (first HA-ca) b)]
(c... | 814Four bit adder | 6clojure | rx6g2 |
double* fwd_diff(double* x, unsigned int len, unsigned int order)
{
unsigned int i, j;
double* y;
if (order >= len) return 0;
y = malloc(sizeof(double) * len);
if (!order) {
memcpy(y, x, sizeof(double) * len);
return y;
}
for (j = 0; j < order; j++, x = y)
for (i = 0, len--; i < len; i++)
y[i] = ... | 815Forward difference | 5c | 9j0m1 |
typedef struct named_number_tag {
const char* name;
uint64_t number;
} named_number;
const named_number named_numbers[] = {
{ , 100 },
{ , 1000 },
{ , 1000000 },
{ , 1000000000 },
{ , 1000000000000 },
{ , 1000000000000000ULL },
{ , 1000000000000000000ULL }
};
const named_number* ge... | 816Four is magic | 5c | m7qys |
package FPS;
use strict;
use warnings;
use Math::BigRat;
sub new {
my $class = shift;
return bless {@_}, $class unless @_ == 1;
my $arg = shift;
return bless { more => $arg }, $class if 'CODE' eq ref $arg;
return bless { coeff => $arg }, $class if 'ARRAY' eq ref $arg;
bless { coeff => [$arg] }, $clas... | 812Formal power series | 2perl | q3jx6 |
(require '[clojure.edn:as edn])
(def names { 0 "zero" 1 "one" 2 "two" 3 "three" 4 "four" 5 "five"
6 "six" 7 "seven" 8 "eight" 9 "nine" 10 "ten" 11 "eleven"
12 "twelve" 13 "thirteen" 14 "fourteen" 15 "fifteen"
16 "sixteen" ... | 816Four is magic | 6clojure | vpi2f |
(defn fwd-diff [nums order]
(nth (iterate #(map - (next %) %) nums) order)) | 815Forward difference | 6clojure | u1dvi |
''' \
For a discussion on pipe() and head() see
http:
'''
from itertools import islice
from fractions import Fraction
from functools import reduce
try:
from itertools import izip as zip
except:
pass
def head(n):
''' return a generator that passes through at most n items
'''
return lambda seq: i... | 812Formal power series | 3python | s6hq9 |
fmt.Printf("%09.3f", 7.125) | 813Formatted numeric output | 0go | gw64n |
printf ("%09.3f", 7.125) | 813Formatted numeric output | 7groovy | 2bdlv |
import Text.Printf
main =
printf "%09.3f" 7.125 | 813Formatted numeric output | 8haskell | s6jqk |
List forwardDifference(List _list) {
for (int i = _list.length - 1; i > 0; i--) {
_list[i] = _list[i] - _list[i - 1];
}
_list.removeRange(0, 1);
return _list;
}
void mainAlgorithms() {
List _intList = [90, 47, 58, 29, 22, 32, 55, 5, 55, 73];
for (int i = _intList.length - 1; i >= 0; i--) {
List _... | 815Forward difference | 18dart | tuafa |
class Fps
def initialize(const: nil, delta: nil, iota: nil, init: nil, enum: nil)
case
when const
@coeffenum = make_const(const)
when delta
@coeffenum = make_delta(delta)
when iota
@coeffenum = make_iota(iota)
when init
@coeffenum ... | 812Formal power series | 14ruby | 8mb01 |
package main
import (
"fmt"
"math"
"strings"
)
func main() {
for _, n := range [...]int64{
0, 4, 6, 11, 13, 75, 100, 337, -164,
math.MaxInt64,
} {
fmt.Println(fourIsMagic(n))
}
}
func fourIsMagic(n int64) string {
s := say(n)
s = strings.ToUpper(s[:1]) + s[1:]
t := s
for n != 4 {
n = int64(len(s))
... | 816Four is magic | 0go | ad21f |
module Main where
import Data.List (find)
import Data.Char (toUpper)
firstNums :: [String]
firstNums =
[ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
]
tens :: [Stri... | 816Four is magic | 8haskell | z5at0 |
sub multiply { return $_[0] * $_[1] } | 808Function definition | 2perl | h05jl |
public class Printing{
public static void main(String[] args){
double value = 7.125;
System.out.printf("%09.3f",value); | 813Formatted numeric output | 9java | 1nup2 |
var n = 123;
var str = ("00000" + n).slice(-5);
alert(str); | 813Formatted numeric output | 10javascript | q37x8 |
package main
import "fmt"
func xor(a, b byte) byte {
return a&(^b) | b&(^a)
}
func ha(a, b byte) (s, c byte) {
return xor(a, b), a & b
}
func fa(a, b, c0 byte) (s, c1 byte) {
sa, ca := ha(a, c0)
s, cb := ha(sa, b)
c1 = ca | cb
return
}
func add4(a3, a2, a1, a0, b3, b2, b1, b0 byte) (v, s3, ... | 814Four bit adder | 0go | s67qa |
class Main {
static void main(args) {
def bit1, bit2, bit3, bit4, carry
def fourBitAdder = new FourBitAdder(
{ value -> bit1 = value },
{ value -> bit2 = value },
{ value -> bit3 = value },
{ value -> bit4 = value },
{... | 814Four bit adder | 7groovy | adu1p |
public class FourIsMagic {
public static void main(String[] args) {
for ( long n : new long[] {6, 60, 89, 300, 670, 2000, 2467, 20000, 24500,200000, 230000, 246571, 2300000, 2465712, 20000000, 24657123, 230000000, 245000000, -246570000, 123456789712345l, 8777777777777777777L, Long.MAX_VALUE}) {
... | 816Four is magic | 9java | o9j8d |
null | 813Formatted numeric output | 11kotlin | js97r |
import Control.Arrow
import Data.List (mapAccumR)
bor, band :: Int -> Int -> Int
bor = max
band = min
bnot :: Int -> Int
bnot = (1-) | 814Four bit adder | 8haskell | 9j8mo |
Object.getOwnPropertyNames(this).includes('BigInt') | 816Four is magic | 10javascript | tu1fm |
typedef struct{
int sourceVertex, destVertex;
int edgeWeight;
}edge;
typedef struct{
int vertices, edges;
edge* edgeMatrix;
}graph;
graph loadGraph(char* fileName){
FILE* fp = fopen(fileName,);
graph G;
int i;
fscanf(fp,,&G.vertices,&G.edges);
G.edgeMatrix = (edge*)malloc(G.edge... | 817Floyd-Warshall algorithm | 5c | 4ed5t |
function multiply( $a, $b )
{
return $a * $b;
} | 808Function definition | 12php | z5ot1 |
null | 816Four is magic | 11kotlin | xz5ws |
function digits(n) return math.floor(math.log(n) / math.log(10))+1 end
function fixedprint(num, digs) | 813Formatted numeric output | 1lua | h0cj8 |
null | 816Four is magic | 1lua | q34x0 |
package main
import (
"fmt"
"log"
"os"
"os/exec"
)
func reverseBytes(bytes []byte) {
for i, j := 0, len(bytes)-1; i < j; i, j = i+1, j-1 {
bytes[i], bytes[j] = bytes[j], bytes[i]
}
}
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
in, err ... | 818Fixed length records | 0go | 8mg0g |
package main
import "fmt"
func main() {
a := []int{90, 47, 58, 29, 22, 32, 55, 5, 55, 73}
fmt.Println(a)
fmt.Println(fd(a, 9))
}
func fd(a []int, ord int) []int {
for i := 0; i < ord; i++ {
for j := 0; j < len(a)-i-1; j++ {
a[j] = a[j+1] - a[j]
}
}
return a[:len(a)... | 815Forward difference | 0go | efua6 |
public class GateLogic
{ | 814Four bit adder | 9java | tuef9 |
null | 818Fixed length records | 1lua | d2hnq |
forwardDifference :: Num a => [a] -> [a]
forwardDifference = tail >>= zipWith (-)
nthForwardDifference :: Num a => [a] -> Int -> [a]
nthForwardDifference = (!!) . iterate forwardDifference
main :: IO ()
main =
mapM_ print $
take 10 (iterate forwardDifference [90, 47, 58, 29, 22, 32, 55, 5, 55, 73]) | 815Forward difference | 8haskell | 34wzj |
function acceptedBinFormat(bin) {
if (bin == 1 || bin === 0 || bin === '0')
return true;
else
return bin;
}
function arePseudoBin() {
var args = [].slice.call(arguments), len = args.length;
while(len--)
if (acceptedBinFormat(args[len]) !== true)
throw new Error('argu... | 814Four bit adder | 10javascript | m70yv |
int main()
{
int i,j;
for (j=1; j<1000; j++) {
for (i=0; i<j, i++) {
if (exit_early())
goto out;
}
}
out:
return 0;
} | 819Flow-control structures | 5c | q3vxc |
use Lingua::EN::Numbers qw(num2en);
sub cardinal {
my($n) = @_;
(my $en = num2en($n)) =~ s/\ and|,//g;
$en;
}
sub magic {
my($int) = @_;
my $str;
while () {
$str .= cardinal($int) . " is ";
if ($int == 4) {
$str .= "magic.\n";
last
} else {
... | 816Four is magic | 2perl | 2bolf |
int i, j;
void fliprow(int **b, int sz, int n)
{
for(i = 0; i < sz; i++)
b[n+1][i] = !b[n+1][i];
}
void flipcol(int **b, int sz, int n)
{
for(i = 1; i <= sz; i++)
b[i][n] = !b[i][n];
}
void initt(int **t, int sz)
{
for(i = 1; i <= sz; i++)
for(j = 0; j < sz; j++)
t[i][j] = rand()%2;
}
void initb(int **t... | 820Flipping bits game | 5c | 34bza |
import random
from collections import OrderedDict
numbers = {
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
10: 'ten',
11: 'eleven',
12: 'twelve',
13: 'thirteen',
14: 'fourteen',
15: 'fifteen',
16: 's... | 816Four is magic | 3python | vpi29 |
open $in, '<', 'flr-infile.dat';
open $out, '>', 'flr-outfile.dat';
while ($n=sysread($in, $record, 80)) {
syswrite $out, reverse $record;
print reverse($record)."\n"
}
close $out; | 818Fixed length records | 2perl | 7qtrh |
infile = open('infile.dat', 'rb')
outfile = open('outfile.dat', 'wb')
while True:
onerecord = infile.read(80)
if len(onerecord) < 80:
break
onerecordreversed = bytes(reversed(onerecord))
outfile.write(onerecordreversed)
infile.close()
outfile.close() | 818Fixed length records | 3python | jsz7p |
import java.util.Arrays;
public class FD {
public static void main(String args[]) {
double[] a = {90, 47, 58, 29, 22, 32, 55, 5, 55, 73};
System.out.println(Arrays.toString(dif(a, 1)));
System.out.println(Arrays.toString(dif(a, 2)));
System.out.println(Arrays.toString(dif(a, 9)));
... | 815Forward difference | 9java | ickos |
null | 814Four bit adder | 11kotlin | o9k8z |
uint8_t *field[2], swapu;
double prob_f = PROB_F, prob_p = PROB_P, prob_tree = PROB_TREE;
enum cell_state {
VOID, TREE, BURNING
};
double prand()
{
return (double)rand() / (RAND_MAX + 1.0);
}
void init_field(void)
{
int i, j;
swapu = 0;
for(i = 0; i < WIDTH; i++)
{
for(j = 0; j < HEIGHT; j++)
... | 821Forest fire | 5c | rxig7 |
(defn cols [board]
(mapv vec (apply map list board)))
(defn flipv [v]
(mapv #(if (> % 0) 0 1) v))
(defn flip-row [board n]
(assoc board n (flipv (get board n))))
(defn flip-col [board n]
(cols (flip-row (cols board) n)))
(defn play-rand [board n]
(if (= n 0)
board
(let [f (if (= (rand-int 2) 0) fl... | 820Flipping bits game | 6clojure | chw9b |
integerToText <- function(value_n_1) {
english_words_for_numbers <- list(
simples = c(
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'
),
tens = c('twent... | 816Four is magic | 13r | 9jsmg |
open(, ) do |out_f|
open() do |in_f|
while record = in_f.read(80)
out_f << record.reverse
end
end
end | 818Fixed length records | 14ruby | k86hg |
(() => {
'use strict'; | 815Forward difference | 10javascript | z5et2 |
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
fn reverse_file(
input_filename: &str,
output_filename: &str,
record_len: usize,
) -> std::io::Result<()> {
let mut input = BufReader::new(File::open(input_filename)?);
let mut output = BufWriter::new(File::create(outp... | 818Fixed length records | 15rust | boykx |
def multiply(a, b):
return a * b | 808Function definition | 3python | k84hf |
int p(int l, int n) {
int test = 0;
double logv = log(2.0) / log(10.0);
int factor = 1;
int loop = l;
while (loop > 10) {
factor *= 10;
loop /= 10;
}
while (n > 0) {
int val;
test++;
val = (int)(factor * pow(10.0, fmod(test * logv, 1)));
if (v... | 822First power of 2 that has leading decimal digits of 12 | 5c | 8mv04 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.