code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
null | 797Functional coverage tree | 1lua | wzoea |
fizz :: (Integral a, Show a) => a -> [(a, String)] -> String
fizz a xs
| null result = show a
| otherwise = result
where result = concatMap (fizz' a) xs
fizz' a (factor, str)
| a `mod` factor == 0 = str
| otherwise = ""
main = do
line <- getLine
let... | 791General FizzBuzz | 8haskell | mjjyf |
int main(void)
{
netbuf *nbuf;
FtpInit();
FtpConnect(, &nbuf);
FtpLogin(, , nbuf);
FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, nbuf);
FtpChdir(, nbuf);
FtpDir((void*)0, , nbuf);
FtpGet(, , FTPLIB_ASCII, nbuf);
FtpQuit(nbuf);
return 0;
} | 800FTP | 5c | fu3d3 |
add :: Int -> Int -> Int
add x y = x+y | 795Function prototype | 8haskell | y7566 |
use strict;
use warnings;
sub walktree {
my @parts;
while( $_[0] =~ /(?<head> (\s*) \N+\n )
(?<body> (?:\2 \s\N+\n)*)/gx ) {
my($head, $body) = ($+{head}, $+{body});
$head =~ /^.*? \|
(\S*) \s* \|
(\S*) ... | 797Functional coverage tree | 2perl | ck49a |
null | 792Gauss-Jordan matrix inversion | 11kotlin | 9hjmh |
public class FizzBuzz {
public static void main(String[] args) {
Sound[] sounds = {new Sound(3, "Fizz"), new Sound(5, "Buzz"), new Sound(7, "Baxx")};
for (int i = 1; i <= 20; i++) {
StringBuilder sb = new StringBuilder();
for (Sound sound : sounds) {
sb.appe... | 791General FizzBuzz | 9java | fuudv |
null | 788Generator/Exponential | 11kotlin | 7sor4 |
null | 795Function prototype | 10javascript | 6ru38 |
package main
import (
"fmt"
"math/rand"
"time"
)
const boxW = 41 | 798Galton box animation | 0go | x3owf |
function fizz(d, e) {
return function b(a) {
return a ? b(a - 1).concat(a) : [];
}(e).reduce(function (b, a) {
return b + (d.reduce(function (b, c) {
return b + (a % c[0] ? "" : c[1]);
}, "") || a.toString()) + "\n";
}, "");
} | 791General FizzBuzz | 10javascript | y776r |
>>> from itertools import permutations
>>> pieces = 'KQRrBbNN'
>>> starts = {''.join(p).upper() for p in permutations(pieces)
if p.index('B')% 2 != p.index('b')% 2
and ( p.index('r') < p.index('K') < p.index('R')
or p.index('R') < p.index('K') < p... | 790Generate Chess960 starting position | 3python | mjhyh |
null | 795Function prototype | 11kotlin | 0mzsf |
from itertools import zip_longest
fc2 = '''\
cleaning,,
house1,40,
bedrooms,,.25
bathrooms,,
bathroom1,,.5
bathroom2,,
outside_lavatory,,1
attic,,.75
kitchen,,.1
living_rooms,,
lounge,,
dining_room,,
co... | 797Functional coverage tree | 3python | lbgcv |
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"sort"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("usage ff <go source filename>")
return
}
src, err := ioutil.ReadFile(os.Args[1])
if err != nil {
fmt.Println(err)
... | 799Function frequency | 0go | dv3ne |
import Data.Map hiding (map, filter)
import Graphics.Gloss
import Control.Monad.Random
data Ball = Ball { position :: (Int, Int), turns :: [Int] }
type World = ( Int
, [Ball]
, Map Int Int )
updateWorld :: World -> World
updateWorld (nRows, balls, bins)
| y < -nRows-5 ... | 798Galton box animation | 8haskell | y7266 |
package main
import (
"errors"
"fmt"
"log"
"math"
)
type testCase struct {
a [][]float64
b []float64
x []float64
}
var tc = testCase{ | 794Gaussian elimination | 0go | wzdeg |
fun main(args: Array<String>) { | 791General FizzBuzz | 11kotlin | 8990q |
null | 788Generator/Exponential | 1lua | j0i71 |
pieces <- c("R","B","N","Q","K","N","B","R")
generateFirstRank <- function() {
attempt <- paste0(sample(pieces), collapse = "")
while (!check_position(attempt)) {
attempt <- paste0(sample(pieces), collapse = "")
}
return(attempt)
}
check_position <- function(position) {
if (regexpr('.*R.*K.*R.*', positi... | 790Generate Chess960 starting position | 13r | z4gth |
package main
import (
"fmt"
"io"
"log"
"os"
"github.com/stacktic/ftp"
)
func main() { | 800FTP | 0go | j0b7d |
@Grab(group='commons-net', module='commons-net', version='2.0')
import org.apache.commons.net.ftp.FTPClient
println("About to connect....");
new FTPClient().with {
connect "ftp.easynet.fr"
enterLocalPassiveMode()
login "anonymous", "ftptest@example.com"
changeWorkingDirectory "/debian/"
def incomin... | 800FTP | 7groovy | 5eruv |
function Func() | 795Function prototype | 1lua | 8930e |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var (
gregorianStr = []string{"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"}
gregorian = []int{31, 28, 31, 30, 31, 30, 31, 3... | 801French Republican calendar | 0go | ua4vt |
import Language.Haskell.Parser (parseModule)
import Data.List.Split (splitOn)
import Data.List (nub, sortOn, elemIndices)
findApps src = freq $ concat [apps, comps]
where
ast = show $ parseModule src
apps = extract <$> splitApp ast
comps = extract <$> concat (splitComp <$> splitInfix ast)
splitApp = ... | 799Function frequency | 8haskell | 5e7ug |
double st_gamma(double x)
{
return sqrt(2.0*M_PI/x)*pow(x/M_E, x);
}
double sp_gamma(double z)
{
const int a = A;
static double c_space[A];
static double *c = NULL;
int k;
double accm;
if ( c == NULL ) {
double k1_factrl = 1.0;
c = c_space;
c[0] = sqrt(2.0*M_PI);
for(k=1; k < a; k++) {... | 802Gamma function | 5c | dvfnv |
package main
import "fmt"
func commatize(n uint64) string {
s := fmt.Sprintf("%d", n)
le := len(s)
for i := le - 3; i >= 1; i -= 3 {
s = s[0:i] + "," + s[i:]
}
return s
}
func main() {
starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
counts := []int{30, 15, 15, 10, 25}
for i := 0;... | 793Gapful numbers | 0go | ckj9g |
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
gauss::[[Double]] -> [[Double]... | 794Gaussian elimination | 8haskell | 6r53k |
function genFizz (param)
local response
print("\n")
for n = 1, param.limit do
response = ""
for i = 1, 3 do
if n % param.factor[i] == 0 then
response = response .. param.word[i]
end
end
if response == "" then print(n) else print(response) end
end
end
local param = {factor = ... | 791General FizzBuzz | 1lua | occ8h |
module Main (main) where
import Control.Exception (bracket)
import Control.Monad (void)
import Data.Foldable (for_)
import Network.FTP.Client
( cwd
, easyConnectFTP
, getbinary
, loginAnon
... | 800FTP | 8haskell | ocd8p |
null | 801French Republican calendar | 11kotlin | gx74d |
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
sum++;
}
... | 803Fusc sequence | 5c | eteav |
import Foundation
extension String {
func paddedLeft(totalLen: Int) -> String {
let needed = totalLen - count
guard needed > 0 else {
return self
}
return String(repeating: " ", count: needed) + self
}
}
class FCNode {
let name: String
let weight: Int
var coverage: Double {
didS... | 797Functional coverage tree | 17swift | 2prlj |
class GapfulNumbers {
private static String commatize(long n) {
StringBuilder sb = new StringBuilder(Long.toString(n))
int le = sb.length()
for (int i = le - 3; i >= 1; i -= 3) {
sb.insert(i, ',')
}
return sb.toString()
}
static void main(String[] args) {... | 793Gapful numbers | 7groovy | 3g5zd |
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
public class FTPconn {
public static void main(String... | 800FTP | 9java | wzsej |
use feature 'state';
use DateTime;
my @month_names = qw{
Vendmiaire Brumaire Frimaire Nivse Pluvise Ventse
Germinal Floral Prairial Messidor Thermidor Fructidor
};
my @intercalary = (
'Fte de la vertu', 'Fte du gnie', 'Fte du travail',
"Fte de l'opinion", 'Fte des rcompenses', 'Fte de l... | 801French Republican calendar | 2perl | n2fiw |
use PPI::Tokenizer;
my $Tokenizer = PPI::Tokenizer->new( '/path/to/your/script.pl' );
my %counts;
while (my $token = $Tokenizer->get_token) {
if ($token =~ /\A[\$\@\%*[:alpha:]]/) {
$counts{$token}++;
}
}
my @desc_by_occurrence =
sort {$counts{$b} <=> $counts{$a} || $a cmp $b}
keys(%co... | 799Function frequency | 2perl | biek4 |
import java.util.Random;
import java.util.List;
import java.util.ArrayList;
public class GaltonBox {
public static void main( final String[] args ) {
new GaltonBox( 8, 200 ).run();
}
private final int m_pinRows;
private final int m_startRow;
private final Position[] m_balls;
... | 798Galton box animation | 9java | dv6n9 |
gapful :: Int -> Bool
gapful n = n `rem` firstLastDigit == 0
where
firstLastDigit = read [head asDigits, last asDigits]
asDigits = show n
main :: IO ()
main = do
putStrLn $ "\nFirst 30 Gapful numbers >= 100:\n" ++ r 30 [100,101..]
putStrLn $ "\nFirst 15 Gapful numbers >= 1,000,000:\n" ++ r 15 [1_000_000,1_0... | 793Gapful numbers | 8haskell | pnobt |
import java.util.Locale;
public class GaussianElimination {
public static double solve(double[][] a, double[][] b) {
if (a == null || b == null || a.length == 0 || b.length == 0) {
throw new IllegalArgumentException("Invalid dimensions");
}
int n = b.length, p = b[0].length;
... | 794Gaussian elimination | 9java | n29ih |
sub rref {
our @m; local *m = shift;
@m or return;
my ($lead, $rows, $cols) = (0, scalar(@m), scalar(@{$m[0]}));
foreach my $r (0 .. $rows - 1) {
$lead < $cols or return;
my $i = $r;
until ($m[$i][$lead])
{++$i == $rows or next;
$i = $r;
++$lead == $cols and retur... | 792Gauss-Jordan matrix inversion | 2perl | wzte6 |
pieces = %i( )
regexes = [/(..)*/, /.*.*/]
row = pieces.shuffle.join until regexes.all?{|re| re.match(row)}
puts row | 790Generate Chess960 starting position | 14ruby | ckb9k |
use std::collections::BTreeSet;
struct Chess960 ( BTreeSet<String> );
impl Chess960 {
fn invoke(&mut self, b: &str, e: &str) {
if e.len() <= 1 {
let s = b.to_string() + e;
if Chess960::is_valid(&s) { self.0.insert(s); }
} else {
for (i, c) in e.char_indices() {
... | 790Generate Chess960 starting position | 15rust | lbpcc |
headers = /usr/include/ftplib.h
linkerOpts.linux = -L/usr/lib -lftp
---
#include <sys/time.h>
struct NetBuf {
char *cput,*cget;
int handle;
int cavail,cleft;
char *buf;
int dir;
netbuf *ctrl;
netbuf *data;
int cmode;
struct timeval idletime;
FtpCallback idlecb;
void *i... | 800FTP | 11kotlin | biakb |
sub noargs();
sub twoargs($$);
sub noargs :prototype();
sub twoargs :prototype($$); | 795Function prototype | 2perl | 5ebu2 |
import ast
class CallCountingVisitor(ast.NodeVisitor):
def __init__(self):
self.calls = {}
def visit_Call(self, node):
if isinstance(node.func, ast.Name):
fun_name = node.func.id
call_count = self.calls.get(fun_name, 0)
self.calls[fun_name] = call_count + 1... | 799Function frequency | 3python | pnwbm |
(defn gamma
"Returns Gamma(z + 1 = number) using Lanczos approximation."
[number]
(if (< number 0.5)
(/ Math/PI (* (Math/sin (* Math/PI number))
(gamma (- 1 number))))
(let [n (dec number)
c [0.99999999999980993 676.5203681218851 -1259.1392167224028
771.3234287776... | 802Gamma function | 6clojure | 6ry3q |
const readline = require('readline');
const galtonBox = (layers, balls) => {
const speed = 100;
const ball = 'o';
const peg = '.';
const result = [];
const sleep = ms => new Promise(resolve => {
setTimeout(resolve,ms)
});
const board = [...Array(layers)]
.map((e, i) => {
const sid... | 798Galton box animation | 10javascript | 6rl38 |
import java.util.List;
public class GapfulNumbers {
private static String commatize(long n) {
StringBuilder sb = new StringBuilder(Long.toString(n));
int le = sb.length();
for (int i = le - 3; i >= 1; i -= 3) {
sb.insert(i, ',');
}
return sb.toString();
}
... | 793Gapful numbers | 9java | rqwg0 |
null | 794Gaussian elimination | 10javascript | 3guz0 |
import scala.annotation.tailrec
object Chess960 extends App {
private val pieces = List('', '', '', '', '', '', '', '')
@tailrec
private def generateFirstRank(pieces: List[Char]): List[Char] = {
def check(rank: String) =
rank.matches(".*.*.*.*") && rank.matches(".*(..|....|......|).*")
val p = s... | 790Generate Chess960 starting position | 16scala | uaev8 |
use Net::FTP;
my $host = 'speedtest.tele2.net';
my $user = 'anonymous';
my $password = '';
my $f = Net::FTP->new($host) or die "Can't open $host\n";
$f->login($user, $password) or die "Can't login as $user\n";
$f->passive();
$f->cwd('upload');
@files = $f->ls();
printf "Currently%d files in the 'upload' ... | 800FTP | 2perl | 6r936 |
null | 798Galton box animation | 11kotlin | 0mdsf |
null | 793Gapful numbers | 10javascript | bi8ki |
double rand_fl(){
return (double)rand() / (double)RAND_MAX;
}
void draw_tree(SDL_Surface * surface, double offsetx, double offsety,
double directionx, double directiony, double size,
double rotation, int depth) {
cairo_surface_t *surf = cairo_image_surface_create_for_data( surface->p... | 804Fractal tree | 5c | xzewu |
program="1/1 455/33 11/13 1/11 3/7 11/2 1/3"
echo $program | tr " " "\n" | cut -d"/" -f1 | tr "\n" " " > "data"
read -a ns < "data"
echo $program | tr " " "\n" | cut -d"/" -f2 | tr "\n" " " > "data"
read -a ds < "data"
t=0
n=72
echo "steps of computation" > steps.csv
while [ $t -le 6 ]; do
if [ $(($n*${ns[$t]}%${ds[... | 805Fractran | 4bash | 34fzx |
$server = ;
$user = ;
$pass = ;
$conn = ftp_connect($server);
if (!$conn) {
die('unable to connect to: '. $server);
}
$login = ftp_login($conn, $user, $pass);
if (!$login) {
echo 'unable to log in to '. $server. ' with user: '.$user.' and pass: '. $pass;
} else{
echo 'connected successfully'.PHP_EOL;
$... | 800FTP | 12php | 1dwpq |
from ftplib import FTP
ftp = FTP('kernel.org')
ftp.login()
ftp.cwd('/pub/linux/kernel')
ftp.set_pasv(True)
print ftp.retrlines('LIST')
print ftp.retrbinary('RETR README', open('README', 'wb').write)
ftp.quit() | 800FTP | 3python | y7c6q |
import numpy as np
from numpy.linalg import inv
a = np.array([[1., 2., 3.], [4., 1., 6.],[ 7., 8., 9.]])
ainv = inv(a)
print(a)
print(ainv) | 792Gauss-Jordan matrix inversion | 3python | x3zwr |
sub gen_pow {
my $m = shift;
my $e = 0;
return sub { return $e++ ** $m; };
}
sub gen_filter {
my($g1, $g2) = @_;
my $v1;
my $v2 = $g2->();
return sub {
for (;;) {
$v1 = $g1->();
$v2 = $g2->() while $v1 > $v2;
return $v1 unless $v1 == $v2;
... | 788Generator/Exponential | 2perl | fugd7 |
typedef struct double_to_double {
double (*fn)(struct double_to_double *, double);
} double_to_double;
typedef struct compose_functor {
double (*fn)(struct compose_functor *, double);
double_to_double *f;
double_to_double *g;
} compose_functor;
double compose_call(compose_functor *this, double x) {
retu... | 806Function composition | 5c | vp92o |
Bitmap.render = function(self)
for y = 1, self.height do
print(table.concat(self.pixels[y], " "))
end
end | 798Galton box animation | 1lua | 89f0e |
private fun commatize(n: Long): String {
val sb = StringBuilder(n.toString())
val le = sb.length
var i = le - 3
while (i >= 1) {
sb.insert(i, ',')
i -= 3
}
return sb.toString()
}
fun main() {
val starts = listOf(1e2.toLong(), 1e6.toLong(), 1e7.toLong(), 1e9.toLong(), 7123.to... | 793Gapful numbers | 11kotlin | v1b21 |
use 5.020;
use strict;
use warnings;
say("Please enter the maximum possible multiple. ");
my $max = <STDIN>;
my @factors = ();
my $buffer;
say("Now enter the first factor and its associated word. Ex: 3 Fizz ");
chomp($buffer = <STDIN>);
push @factors, $buffer;
say("Now enter the second factor and its associated wor... | 791General FizzBuzz | 2perl | 4ww5d |
func isValid960Position(_ firstRank: String) -> Bool {
var rooksPlaced = 0
var bishopColor = -1
for (i, piece) in firstRank.enumerated() {
switch piece {
case "" where rooksPlaced!= 1:
return false
case "":
rooksPlaced += 1
case "" where bishopColor == -1:
bishopColor = i & 1
... | 790Generate Chess960 starting position | 17swift | 9hkmj |
(import '[java.awt Color Graphics]
'javax.swing.JFrame)
(defn deg-to-radian [deg] (* deg Math/PI 1/180))
(defn cos-deg [angle] (Math/cos (deg-to-radian angle)))
(defn sin-deg [angle] (Math/sin (deg-to-radian angle)))
(defn draw-tree [^Graphics g, x y angle depth]
(when (pos? depth)
(let [x2 (+ x (int (* depth ... | 804Fractal tree | 6clojure | o908j |
typedef struct IntArray_t {
int *ptr;
size_t length;
} IntArray;
IntArray make(size_t size) {
IntArray temp;
temp.ptr = calloc(size, sizeof(int));
temp.length = size;
return temp;
}
void destroy(IntArray *ia) {
if (ia->ptr != NULL) {
free(ia->ptr);
ia->ptr = NULL;
... | 807Fraction reduction | 5c | u19v4 |
require 'net/ftp'
Net::FTP.open('ftp.ed.ac.uk', , ) do |ftp|
ftp.passive = true
ftp.chdir('pub/courses')
puts ftp.list
ftp.getbinaryfile()
end | 800FTP | 14ruby | 9h2mz |
use std::{error::Error, fs::File, io::copy};
use ftp::FtpStream;
fn main() -> Result<(), Box<dyn Error>> {
let mut ftp = FtpStream::connect("ftp.easynet.fr:21")?;
ftp.login("anonymous", "")?;
ftp.cwd("debian")?;
for file in ftp.list(None)? {
println!("{}", file);
}
let mut stream = ftp.... | 800FTP | 15rust | ckv9z |
import java.io.{File, FileOutputStream, InputStream}
import org.apache.commons.net.ftp.{FTPClient, FTPFile, FTPReply}
import scala.util.{Failure, Try}
object FTPconn extends App {
val (server, pass) = ("ftp.ed.ac.uk", "-ftptest@example.com")
val (dir, filename, ftpClient) = ("/pub/cartonet/", "readme.txt", new F... | 800FTP | 16scala | v142s |
null | 794Gaussian elimination | 11kotlin | syzq7 |
func loweralpha() string {
p := make([]byte, 26)
for i := range p {
p[i] = 'a' + byte(i)
}
return string(p)
} | 796Generate lower case ASCII alphabet | 0go | koxhz |
def lower = ('a'..'z') | 796Generate lower case ASCII alphabet | 7groovy | gxp46 |
<?php
function powers($m) {
for ($n = 0; ; $n++) {
yield pow($n, $m);
}
}
function filtered($s1, $s2) {
while (true) {
list($v, $f) = [$s1->current(), $s2->current()];
if ($v > $f) {
$s2->next();
continue;
} else if ($v < $f) {
yield $v;
... | 788Generator/Exponential | 12php | h8njf |
use strict;
use warnings;
use List::Util 'any';
use Time::HiRes qw(sleep);
use List::AllUtils <pairwise pairs>;
use utf8;
binmode STDOUT, ':utf8';
my $coins = shift || 100;
my $peg_lines = shift || 13;
my $row_count = $peg_lines;
my $peg = '^';
my @coin_icons = ("\N{UPPER HALF BLOCK}", "\N{LOWER HALF B... | 798Galton box animation | 2perl | 5eju2 |
fn main() {
let mut a: Vec<Vec<f64>> = vec![vec![1.0, 2.0, 3.0],
vec![4.0, 1.0, 6.0],
vec![7.0, 8.0, 9.0]
];
let mut b: Vec<Vec<f64>> = vec![vec![2.0, -1.0, 0.0],
vec![-1.0, 2.0, -1.0]... | 792Gauss-Jordan matrix inversion | 15rust | 0mysl |
<?php
$max = 20;
$factor = array(3 => 'Fizz', 5 => 'Buzz', 7 => 'Jazz');
for ($i = 1 ; $i <= $max ; $i++) {
$matched = false;
foreach ($factor AS $number => $word) {
if ($i % $number == 0) {
echo $word;
$matched = true;
}
}
echo ($matched? '' : $i), PHP_EOL;
}
... | 791General FizzBuzz | 12php | illov |
lower = ['a' .. 'z']
main = print lower | 796Generate lower case ASCII alphabet | 8haskell | n2yie |
(defn compose [f g]
(fn [x]
(f (g x))))
(def inc2 (compose inc inc))
(println (inc2 5)) | 806Function composition | 6clojure | rxug2 |
function generateGaps(start, count)
local counter = 0
local i = start
print(string.format("First%d Gapful numbers >=%d:", count, start))
while counter < count do
local str = tostring(i)
local denom = 10 * tonumber(str:sub(1, 1)) + (i % 10)
if i % denom == 0 then
pri... | 793Gapful numbers | 1lua | uapvl |
typedef struct frac_s *frac;
struct frac_s {
int n, d;
frac next;
};
frac parse(char *s)
{
int offset = 0;
struct frac_s h = {0}, *p = &h;
while (2 == sscanf(s, , &h.n, &h.d, &offset)) {
s += offset;
p = p->next = malloc(sizeof *p);
*p = h;
p->next = 0;
}
return h.next;
}
int run(int v, char *s)
{
f... | 805Fractran | 5c | yrz6f |
package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... | 803Fusc sequence | 0go | 9h9mt |
public class LowerAscii {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder(26);
for (char ch = 'a'; ch <= 'z'; ch++)
sb.append(ch);
System.out.printf("lower ascii:%s, length:%s", sb, sb.length());
}
} | 796Generate lower case ASCII alphabet | 9java | q6dxa |
(function (cFrom, cTo) {
function cRange(cFrom, cTo) {
var iStart = cFrom.charCodeAt(0);
return Array.apply(
null, Array(cTo.charCodeAt(0) - iStart + 1)
).map(function (_, i) {
return String.fromCharCode(iStart + i);
});
}
return cRange(cFrom, cTo);
})('a', 'z'); | 796Generate lower case ASCII alphabet | 10javascript | il6ol |
from itertools import islice, count
def powers(m):
for n in count():
yield n ** m
def filtered(s1, s2):
v, f = next(s1), next(s2)
while True:
if v > f:
f = next(s2)
continue
elif v < f:
yield v
v = next(s1)
squares, cubes = powers(2), po... | 788Generator/Exponential | 3python | t5rfw |
class FuscSequence {
static void main(String[] args) {
println("Show the first 61 fusc numbers (starting at zero) in a horizontal format")
for (int n = 0; n < 61; n++) {
printf("%,d ", fusc[n])
}
println()
println()
println("Show the fusc number (and its ... | 803Fusc sequence | 7groovy | z4zt5 |
def genfizzbuzz(factorwords, numbers):
factorwords.sort(key=lambda factor_and_word: factor_and_word[0])
lines = []
for num in numbers:
words = ''.join(word for factor, word in factorwords if (num% factor) == 0)
lines.append(words if words else str(num))
return '\n'.join(lines)
if _... | 791General FizzBuzz | 3python | gxx4h |
print "Hello world!\n"; | 755Hello world/Text | 2perl | 4xx5d |
package main
import (
"fmt"
"time"
)
func indexOf(n int, s []int) int {
for i, j := range s {
if n == j {
return i
}
}
return -1
}
func getDigits(n, le int, digits []int) bool {
for n > 0 {
r := n % 10
if r == 0 || indexOf(r, digits) >= 0 {
... | 807Fraction reduction | 0go | 0yesk |
fusc :: Int -> Int
fusc i
| 1 > i = 0
| otherwise = fst $ go (pred i)
where
go n
| 0 == n = (1, 0)
| even n = (x + y, y)
| otherwise = (x, x + y)
where
(x, y) = go (div n 2)
main :: IO ()
main = do
putStrLn "First 61 terms:"
print $ fusc <$> [0 .. 60]
putStrLn "\n(Index... | 803Fusc sequence | 8haskell | bibk2 |
import sys, os
import random
import time
def print_there(x, y, text):
sys.stdout.write(% (x, y, text))
sys.stdout.flush()
class Ball():
def __init__(self):
self.x = 0
self.y = 0
def update(self):
self.x += random.randint(0,1)
self.y += 1
def fall(self):
... | 798Galton box animation | 3python | 4wh5k |
genFizzBuzz <- function(n, ...)
{
args <- list(...)
factors <- as.integer(sapply(args, "[[", 1))
words <- sapply(args, "[[", 2)
sortedPermutation <- sort.list(factors)
factors <- factors[sortedPermutation]
words <- words[sortedPermutation]
for(i in 1:n)
{
isFactor <- i %% factors == 0
pri... | 791General FizzBuzz | 13r | v1127 |
powers = function(m)
{n = -1
function()
{n <<- n + 1
n^m}}
noncubic.squares = local(
{squares = powers(2)
cubes = powers(3)
cube = cubes()
function()
{square = squares()
while (1)
{if (square > cube)
{cube <<- cubes()
next}
... | 788Generator/Exponential | 13r | iluo5 |
package main | 804Fractal tree | 0go | lk9cw |
class FractionReduction {
static void main(String[] args) {
for (int size = 2; size <= 5; size++) {
reduce(size)
}
}
private static void reduce(int numDigits) {
System.out.printf("Fractions with digits of length%d where cancellation is valid. Examples:%n", numDigits) | 807Fraction reduction | 7groovy | efkal |
use strict;
use warnings;
use feature 'say';
sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }
sub is_gapful { my $n = shift; 0 == $n % join('', (split //, $n)[0,-1]) }
use constant Inf => 1e10;
for ([1e2, 30], [1e6, 15], [1e9, 10], [7123, 25]) {
my($start, $count) = @$_;
printf "\nFirst ... | 793Gapful numbers | 2perl | 0m6s4 |
null | 796Generate lower case ASCII alphabet | 11kotlin | 1d0pd |
import Graphics.Gloss
type Model = [Picture -> Picture]
fractal :: Int -> Model -> Picture -> Picture
fractal n model pict = pictures $ take n $ iterate (mconcat model) pict
tree1 _ = fractal 10 branches $ Line [(0,0),(0,100)]
where branches = [ Translate 0 100 . Scale 0.75 0.75 . Rotate 30
, T... | 804Fractal tree | 8haskell | 1nbps |
import Control.Monad (guard)
import Data.List (intersect, unfoldr, delete, nub, group, sort)
import Text.Printf (printf)
type Fraction = (Int, Int)
type Reduction = (Fraction, Fraction, Int)
validIntegers :: [Int] -> [Int]
validIntegers xs = [x | x <- xs, not $ hasZeros x, hasUniqu... | 807Fraction reduction | 8haskell | ch394 |
public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nShow the ... | 803Fusc sequence | 9java | gxg4m |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.