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" "log" "math" "os" "path/filepath" ) func commatize(n int64) string { s := fmt.Sprintf("%d", n) if n < 0 { s = s[1:] } le := len(s) for i := le - 3; i >= 1; i -= 3 { s = s[0:i] + "," + s[i:] } if n >= 0 { return s }...
842File size distribution
0go
s3aqa
int common_len(const char *const *names, int n, char sep) { int i, pos; for (pos = 0; ; pos++) { for (i = 0; i < n; i++) { if (names[i][pos] != '\0' && names[i][pos] == names[0][pos]) continue; while (pos > 0 && names[0][--pos] != sep); return pos; } } return 0; } int main() { const ch...
843Find common directory path
5c
upmv4
(() => { 'use strict';
840Find palindromic numbers in both binary and ternary bases
10javascript
pohb7
import Control.Concurrent (forkIO, setNumCapabilities) import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan, writeList2Chan) import Control.Exception (IOException, catch) import Control.Monad ...
842File size distribution
8haskell
97zmo
import kotlin.math.max import kotlin.math.min private const val EPS = 0.001 private const val EPS_SQUARE = EPS * EPS private fun test(t: Triangle, p: Point) { println(t) println("Point $p is within triangle? ${t.within(p)}") } fun main() { var p1 = Point(1.5, 2.4) var p2 = Point(5.1, -3.1) var p3...
839Find if a point is within a triangle
11kotlin
2kcli
null
840Find palindromic numbers in both binary and ternary bases
11kotlin
uplvc
const char *filename = ; int main() { struct stat foo; time_t mtime; struct utimbuf new_times; if (stat(filename, &foo) < 0) { perror(filename); return 1; } mtime = foo.st_mtime; new_times.actime = foo.st_atime; new_times.modtime = time(NULL); if (utime(filename, &new_times) < 0) { ...
844File modification time
5c
gec45
null
842File size distribution
11kotlin
omx8z
EPS = 0.001 EPS_SQUARE = EPS * EPS function side(x1, y1, x2, y2, x, y) return (y2 - y1) * (x - x1) + (-x2 + x1) * (y - y1) end function naivePointInTriangle(x1, y1, x2, y2, x3, y3, x, y) local checkSide1 = side(x1, y1, x2, y2, x, y) >= 0 local checkSide2 = side(x2, y2, x3, y3, x, y) >= 0 local checkSi...
839Find if a point is within a triangle
1lua
vbl2x
use File::Find; use List::Util qw(max); my %fsize; $dir = shift || '.'; find(\&fsize, $dir); $max = max($max,$fsize{$_}) for keys %fsize; $total += $size while (undef,$size) = each %fsize; print "File size distribution in bytes for directory: $dir\n"; for (0 .. max(keys %fsize)) { printf " histogram( $max...
842File size distribution
2perl
ge24e
(use '[clojure.string:only [join,split]]) (defn common-prefix [sep paths] (let [parts-per-path (map #(split % (re-pattern sep)) paths) parts-per-position (apply map vector parts-per-path)] (join sep (for [parts parts-per-position:while (apply = parts)] (first parts))))) (println (common...
843Find common directory path
6clojure
7xvr0
(import '(java.io File) '(java.util Date)) (Date. (.lastModified (File. "output.txt"))) (Date. (.lastModified (File. "docs"))) (.setLastModified (File. "output.txt") (.lastModified (File. "docs")))
844File modification time
6clojure
k05hs
use strict; use warnings; use List::AllUtils qw(min max natatime); use constant EPSILON => 0.001; use constant EPSILON_SQUARE => EPSILON*EPSILON; sub side { my ($x1, $y1, $x2, $y2, $x, $y) = @_; return ($y2 - $y1)*($x - $x1) + (-$x2 + $x1)*($y - $y1); } sub naivePointInTriangle { my ($x1, $...
839Find if a point is within a triangle
2perl
s3xq3
use ntheory qw/fromdigits todigitstring/; print "0 0 0\n"; for (0..2e5) { my $pal = todigitstring($_, 3); my $b3 = $pal . "1" . reverse($pal); my $b2 = todigitstring(fromdigits($b3, 3), 2); print fromdigits($b2,2)," $b3 $b2\n" if $b2 eq reverse($b2); }
840Find palindromic numbers in both binary and ternary bases
2perl
8yq0w
import sys, os from collections import Counter def dodir(path): global h for name in os.listdir(path): p = os.path.join(path, name) if os.path.islink(p): pass elif os.path.isfile(p): h[os.stat(p).st_size] += 1 elif os.path.isdir(p): dodir(p)...
842File size distribution
3python
rwvgq
package main import ( "flag" "fmt" "runtime/debug" ) func main() { stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default") flag.Parse() if *stack > 0 { debug.SetMaxStack(*stack) } r(1) } func r(l int) { if l%1000 == 0 { fmt.Println(l) } r(l + 1) }
841Find limit of recursion
0go
1ihp5
long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, ); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf(, getFileSize()); printf(, getFileSize()); return 0; }
845File size
5c
2kzlo
int main(void) { puts( ); char i; for (i = 'c'; i <= 'z'; i++) printf(, i, i-1, i-2); puts(); return 0; }
846Fibonacci word/fractal
5c
ncei6
from sympy.geometry import Point, Triangle def sign(pt1, pt2, pt3): return (pt1.x - pt3.x) * (pt2.y - pt3.y) - (pt2.x - pt3.x) * (pt1.y - pt3.y) def iswithin(point, pt1, pt2, pt3): zval1 = sign(point, pt1, pt2) zval2 = sign(point, pt2, pt3) zval3 = sign(point, pt3, pt1) notanyneg = zval...
839Find if a point is within a triangle
3python
06qsq
def recurse; recurse = { try { recurse (it + 1) } catch (StackOverflowError e) { return it } } recurse(0)
841Find limit of recursion
7groovy
jq47o
import Debug.Trace (trace) recurse :: Int -> Int recurse n = trace (show n) recurse (succ n) main :: IO () main = print $ recurse 1
841Find limit of recursion
8haskell
tvif7
int checkFileExtension(char* fileName, char* fileExtensions) { char* fileExtension = fileExtensions; if ( *fileName ) { while ( *fileExtension ) { int fileNameLength = strlen(fileName); int extensionLength = strlen(fileExtension); if ( fileNameLength >= e...
847File extension is in extensions list
5c
jqc70
from itertools import islice digits = def baseN(num,b): if num == 0: return result = while num != 0: num, d = divmod(num, b) result += digits[d] return result[::-1] def pal2(num): if num == 0 or num == 1: return True based = bin(num)[2:] return based == based[::-1] def pal_23(): ...
840Find palindromic numbers in both binary and ternary bases
3python
oms81
(require '[clojure.java.io:as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
845File size
6clojure
ge94f
use std::error::Error; use std::marker::PhantomData; use std::path::{Path, PathBuf}; use std::{env, fmt, io, time}; use walkdir::{DirEntry, WalkDir}; fn main() -> Result<(), Box<dyn Error>> { let start = time::Instant::now(); let args: Vec<String> = env::args().collect(); let root = parse_path(&args).expe...
842File size distribution
15rust
hs4j2
(defn matches-extension [ext s] (re-find (re-pattern (str "\\." ext "$")) (clojure.string/lower-case s))) (defn matches-extension-list [ext-list s] (some #(matches-extension % s) ext-list))
847File extension is in extensions list
6clojure
1i5py
EPS = 0.001 EPS_SQUARE = EPS * EPS def side(x1, y1, x2, y2, x, y) return (y2 - y1) * (x - x1) + (-x2 + x1) * (y - y1) end def naivePointInTriangle(x1, y1, x2, y2, x3, y3, x, y) checkSide1 = side(x1, y1, x2, y2, x, y) >= 0 checkSide2 = side(x2, y2, x3, y3, x, y) >= 0 checkSide3 = side(x3, y3, x1, y1, x...
839Find if a point is within a triangle
14ruby
om08v
package main import ( "fmt" "os" "syscall" "time" ) var filename = "input.txt" func main() { foo, err := os.Stat(filename) if err != nil { fmt.Println(err) return } fmt.Println("mod time was:", foo.ModTime()) mtime := time.Now() atime := mtime
844File modification time
0go
i9wog
public class RecursionTest { private static void recurse(int i) { try { recurse(i+1); } catch (StackOverflowError e) { System.out.print("Recursion depth on this system is " + i + "."); } } public static void main(String[] args) { recurse(0); } }
841Find limit of recursion
9java
8yx06
function recurse(depth) { try { return recurse(depth + 1); } catch(ex) { return depth; } } var maxRecursion = recurse(1); document.write("Recursion depth on this system is " + maxRecursion);
841Find limit of recursion
10javascript
f2odg
pal23 = Enumerator.new do |y| y << 0 y << 1 for i in 1 .. 1.0/0.0 n3 = i.to_s(3) n = (n3 + + n3.reverse).to_i(3) n2 = n.to_s(2) y << n if n2.size.odd? and n2 == n2.reverse end end puts 6.times do |i| n = pal23.next puts % [i, n, n.to_s(3).center(25), n.to_s(2).center(39...
840Find palindromic numbers in both binary and ternary bases
14ruby
nc8it
import System.Posix.Files import System.Posix.Time do status <- getFileStatus filename let atime = accessTime status mtime = modificationTime status curTime <- epochTime setFileTimes filename atime curTime
844File modification time
8haskell
vb62k
package main import ( "fmt" "os" "path" ) func CommonPrefix(sep byte, paths ...string) string {
843Find common directory path
0go
06ask
import scala.annotation.tailrec import scala.compat.Platform.currentTime object Palindrome23 extends App { private val executionStartTime = currentTime private val st: Stream[(Int, Long)] = (0, 1L) #:: st.map(xs => nextPalin3(xs._1)) @tailrec private def nextPalin3(n: Int): (Int, Long) = { @inline de...
840Find palindromic numbers in both binary and ternary bases
16scala
zudtr
package main import ( "fmt" "strings" ) var extensions = []string{"zip", "rar", "7z", "gz", "archive", "A##", "tar.bz2"} func fileExtInList(filename string) (bool, string) { filename2 := strings.ToLower(filename) for _, ext := range extensions { ext2 := "." + strings.ToLower(ext) if s...
847File extension is in extensions list
0go
f2wd0
package main import ( "github.com/fogleman/gg" "strings" ) func wordFractal(i int) string { if i < 2 { if i == 1 { return "1" } return "" } var f1 strings.Builder f1.WriteString("1") var f2 strings.Builder f2.WriteString("0") for j := i - 2; j >=...
846Fibonacci word/fractal
0go
rw9gm
def commonPath = { delim, Object[] paths -> def pathParts = paths.collect { it.split(delim) } pathParts.transpose().inject([match:true, commonParts:[]]) { aggregator, part -> aggregator.match = aggregator.match && part.every { it == part [0] } if (aggregator.match) { aggregator.commonParts << pa...
843Find common directory path
7groovy
edhal
null
841Find limit of recursion
11kotlin
wfpek
void feigenbaum() { int i, j, k, max_it = 13, max_it_j = 10; double a, x, y, d, a1 = 1.0, a2 = 0.0, d1 = 3.2; printf(); for (i = 2; i <= max_it; ++i) { a = a1 + (a1 - a2) / d1; for (j = 1; j <= max_it_j; ++j) { x = 0.0; y = 0.0; for (k = 1; k <= 1 << i...
848Feigenbaum constant calculation
5c
an511
import Data.List import qualified Data.Char as Ch toLower :: String -> String toLower = map Ch.toLower isExt :: String -> [String] -> Bool isExt filename extensions = any (`elem` (tails . toLower $ filename)) $ map toLower extensions
847File extension is in extensions list
8haskell
4a65s
import java.io.File; import java.util.Date; public class FileModificationTimeTest { public static void test(String type, File file) { long t = file.lastModified(); System.out.println("The following " + type + " called " + file.getPath() + (t == 0 ? " does not exist." : " was modified at " +...
844File modification time
9java
ygn6g
var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.GetFile('input.txt'); var mtime = f.DateLastModified;
844File modification time
10javascript
2k3lr
import Foundation func isPalin2(n: Int) -> Bool { var x = 0 var n = n guard n & 1!= 0 else { return n == 0 } while x < n { x = x << 1 | n & 1 n >>= 1 } return n == x || n == x >> 1 } func reverse3(n: Int) -> Int { var x = 0 var n = n while n > 0 { x = x * 3 + (n% 3) n /= 3 ...
840Find palindromic numbers in both binary and ternary bases
17swift
i90o0
gcc -o fermat fermat.c -lgmp
849Fermat numbers
5c
i9bo2
import java.util.Arrays; import java.util.Comparator; public class FileExt{ public static void main(String[] args){ String[] tests = {"text.txt", "text.TXT", "test.tar.gz", "test/test2.exe", "test\\test2.exe", "test", "a/b/c\\d/foo"}; String[] exts = {".txt",".gz","",".bat"}; System.out.println("Extensions: " ...
847File extension is in extensions list
9java
cjn9h
import Data.List (unfoldr) import Data.Bool (bool) import Data.Semigroup (Sum(..), Min(..), Max(..)) import System.IO (writeFile) fibonacciWord :: a -> a -> [[a]] fibonacciWord a b = unfoldr (\(a,b) -> Just (a, (b, a <> b))) ([a], [b]) toPath :: [Bool] -> ((Min Int, Max Int, Min Int, Max Int), String) toPath = foldMa...
846Fibonacci word/fractal
8haskell
06bs7
import Data.List commonPrefix2 (x:xs) (y:ys) | x == y = x: commonPrefix2 xs ys commonPrefix2 _ _ = [] commonPrefix (xs:xss) = foldr commonPrefix2 xs xss commonPrefix _ = [] splitPath = groupBy (\_ c -> c /= '/') commonDirPath = concat . commonPrefix . map splitPath main = putStrLn $ commonDirPath [ "...
843Find common directory path
8haskell
cjz94
local c = 0 function Tail(proper) c = c + 1 if proper then if c < 9999999 then return Tail(proper) else return c end else return 1/c+Tail(proper)
841Find limit of recursion
1lua
xt1wz
int main(int argc, char **argv) { FILE *in, *out; int c; in = fopen(, ); if (!in) { fprintf(stderr, ); return 1; } out = fopen(, ); if (!out) { fprintf(stderr, ); fclose(in); return 1; } while ((c = fgetc(in)) != EOF) { fputc(c, out); } fclose(out); fclose(in); retu...
850File input/output
5c
vbn2o
void print_headings() { printf(, ); printf(, ); printf(, ); printf(, ); printf(); } double calculate_entropy(int ones, int zeros) { double result = 0; int total = ones + zeros; result -= (double) ones / total * log2((double) ones / total); result -= (double) zeros / total * log2((double) zeros / total); if...
851Fibonacci word
5c
97sm1
null
844File modification time
11kotlin
f2sdo
require "lfs" local attributes = lfs.attributes("input.txt") if attributes then print(path .. " was last modified " .. os.date("%c", attributes.modification) .. ".")
844File modification time
1lua
tv0fn
import java.awt.*; import javax.swing.*; public class FibonacciWordFractal extends JPanel { String wordFractal; FibonacciWordFractal(int n) { setPreferredSize(new Dimension(450, 620)); setBackground(Color.white); wordFractal = wordFractal(n); } public String wordFractal(int n)...
846Fibonacci word/fractal
9java
ang1y
package main import ( "fmt" "github.com/jbarham/primegen" "math" "math/big" "math/rand" "sort" "time" ) const ( maxCurves = 10000 maxRnd = 1 << 31 maxB1 = uint64(43 * 1e7) maxB2 = uint64(2 * 1e10) ) var ( zero = big.NewInt(0) one = big.NewInt(1) t...
849Fermat numbers
0go
ge34n
null
847File extension is in extensions list
11kotlin
35sz5
null
847File extension is in extensions list
1lua
64039
null
846Fibonacci word/fractal
10javascript
s3kqz
public class CommonPath { public static String commonPath(String... paths){ String commonPath = ""; String[][] folders = new String[paths.length][]; for(int i = 0; i < paths.length; i++){ folders[i] = paths[i].split("/");
843Find common directory path
9java
zuotq
(use 'clojure.java.io) (copy (file "input.txt") (file "output.txt"))
850File input/output
6clojure
rw3g2
import Data.Numbers.Primes (primeFactors) import Data.Bool (bool) fermat :: Integer -> Integer fermat = succ . (2 ^) . (2 ^) fermats :: [Integer] fermats = fermat <$> [0 ..] main :: IO () main = mapM_ putStrLn [ fTable "First 10 Fermats:" show show fermat [0 .. 9] , fTable "Factors of first 7:...
849Fermat numbers
8haskell
s37qk
package main import "fmt" func feigenbaum() { maxIt, maxItJ := 13, 10 a1, a2, d1 := 1.0, 0.0, 3.2 fmt.Println(" i d") for i := 2; i <= maxIt; i++ { a := a1 + (a1-a2)/d1 for j := 1; j <= maxItJ; j++ { x, y := 0.0, 0.0 for k := 1; k <= 1<<uint(i); k++ { ...
848Feigenbaum constant calculation
0go
mr8yi
null
846Fibonacci word/fractal
11kotlin
hs2j3
const splitStrings = (a, sep = '/') => a.map(i => i.split(sep)); const elAt = i => a => a[i]; const rotate = a => a[0].map((e, i) => a.map(elAt(i))); const allElementsEqual = arr => arr.every(e => e === arr[0]); const commonPath = (input, sep = '/') => rotate(splitStrings(input, sep)) .filter(allElementsEqu...
843Find common directory path
10javascript
97tml
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
845File size
0go
qzkxz
println new File('index.txt').length(); println new File('/index.txt').length();
845File size
7groovy
1igp6
(defn entropy [s] (let [len (count s), log-2 (Math/log 2)] (->> (frequencies s) (map (fn [[_ v]] (let [rf (/ v len)] (-> (Math/log rf) (/ log-2) (* rf) Math/abs)))) (reduce +)))) (defn fibonacci [cat a b] (lazy-seq (cons a (fibonacci b (cat a b))))) (p...
851Fibonacci word
6clojure
upnvi
import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class FermatNumbers { public static void main(String[] args) { System.out.println("First 10 Fermat numbers:"); for ( int i = 0 ...
849Fermat numbers
9java
1ivp2
class Feigenbaum { static void main(String[] args) { int max_it = 13 int max_it_j = 10 double a1 = 1.0 double a2 = 0.0 double d1 = 3.2 double a println(" i d") for (int i = 2; i <= max_it; i++) { a = a1 + (a1 - a2) / d1 f...
848Feigenbaum constant calculation
7groovy
tvwfh
import Data.List (mapAccumL) feigenbaumApprox :: Int -> [Double] feigenbaumApprox mx = snd $ mitch mx 10 where mitch :: Int -> Int -> ((Double, Double, Double), [Double]) mitch mx mxj = mapAccumL (\(a1, a2, d1) i -> let a = iterate (\a -> ...
848Feigenbaum constant calculation
8haskell
k0lh0
RIGHT, LEFT, UP, DOWN = 1, 2, 4, 8 function drawFractals( w ) love.graphics.setCanvas( canvas ) love.graphics.clear() love.graphics.setColor( 255, 255, 255 ) local dir, facing, lineLen, px, py, c = RIGHT, UP, 1, 10, love.graphics.getHeight() - 20, 1 local x, y = 0, -lineLen local pts = {} ta...
846Fibonacci word/fractal
1lua
k0vh2
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
845File size
8haskell
mrnyf
int binomial(int n, int k) { int num, denom, i; if (n < 0 || k < 0 || n < k) return -1; if (n == 0 || k == 0) return 1; num = 1; for (i = k + 1; i <= n; ++i) { num = num * i; } denom = 1; for (i = 2; i <= n - k; ++i) { denom *= i; } return num / denom; } int ...
852Faulhaber's formula
5c
mrxys
public class Feigenbaum { public static void main(String[] args) { int max_it = 13; int max_it_j = 10; double a1 = 1.0; double a2 = 0.0; double d1 = 3.2; double a; System.out.println(" i d"); for (int i = 2; i <= max_it; i++) { a = a...
848Feigenbaum constant calculation
9java
4a358
null
843Find common directory path
11kotlin
i9xo4
int even_sel(int x) { return !(x & 1); } int tri_sel(int x) { return x % 3; } int* grep(int *in, int len, int *outlen, int (*sel)(int), int inplace) { int i, j, *out; if (inplace) out = in; else out = malloc(sizeof(int) * len); for (i = j = 0; i < len; i++) if (sel(in[i])) out[j++] = in[i]; if (!inplace...
853Filter
5c
4an5t
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt: " + new File("/input.txt").length() + " bytes"); } }
845File size
9java
f2qdv
void main() { FILE * fp; char * line = NULL; size_t len = 0; ssize_t read; fp = fopen(, ); if (fp == NULL) exit(EXIT_FAILURE); int state = 0; while ((read = getline(&line, &len, fp)) != -1) { if (line[read - 1] == '\n') line[read - 1] = 0; if (line[0] == '>') { if (state == 1) printf(); ...
854FASTA format
5c
51ouk
import java.math.BigInteger import kotlin.math.pow fun main() { println("First 10 Fermat numbers:") for (i in 0..9) { println("F[$i] = ${fermat(i)}") } println() println("First 12 Fermat numbers factored:") for (i in 0..12) { println("F[$i] = ${getString(getFactors(i, fermat(i))...
849Fermat numbers
11kotlin
jqm7r
null
848Feigenbaum constant calculation
11kotlin
lhncp
sub check_extension { my ($filename, @extensions) = @_; my $extensions = join '|', map quotemeta, @extensions; scalar $filename =~ / \. (?: $extensions ) $ /xi }
847File extension is in extensions list
2perl
poub0
$allowed = ['zip', 'rar', '7z', 'gz', 'archive', 'A $lc_allowed = array_map('strtolower', $allowed); $tests = [ ['MyData.a ['MyData.tar.Gz',true], ['MyData.gzip',false], ['MyData.7z.backup',false], ['MyData...',false], ['MyData',false], ['archive.tar.gz', true] ]; foreach ($tests as $test)...
847File extension is in extensions list
12php
yg861
var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.GetFile('input.txt').Size; fso.GetFile('c:/input.txt').Size;
845File size
10javascript
ygi6r
int binomial(int n, int k) { int num, denom, i; if (n < 0 || k < 0 || n < k) return -1; if (n == 0 || k == 0) return 1; num = 1; for (i = k + 1; i <= n; ++i) { num = num * i; } denom = 1; for (i = 2; i <= n - k; ++i) { denom *= i; } return num / denom; } int ...
855Faulhaber's triangle
5c
qz2xc
use strict; use warnings; use GD; my @fword = ( undef, 1, 0 ); sub fword { my $n = shift; return $fword[$n] if $n<3; return $fword[$n] //= fword($n-1).fword($n-2); } my $size = 3000; my $im = new GD::Image($size,$size); my $white = $im->colorAllocate(255,255,255); my $black = $im->colorAllocate(0,0,0); $im...
846Fibonacci word/fractal
2perl
zustb
null
845File size
11kotlin
8y10q
use strict; use warnings; use feature 'say'; use bigint try=>"GMP"; use ntheory qw<factor>; my @Fermats = map { 2**(2**$_) + 1 } 0..9; my $sub = 0; say 'First 10 Fermat numbers:'; printf "F%s =%s\n", $sub++, $_ for @Fermats; $sub = 0; say "\nFactors of first few Fermat numbers:"; for my $f (map { [factor($_)] } @Fer...
849Fermat numbers
2perl
tvefg
function leftShift(n,p) local r = n while p>0 do r = r * 2 p = p - 1 end return r end
848Feigenbaum constant calculation
1lua
2kdl3
def isExt(fileName, extensions): return True in map(fileName.lower().endswith, ( + e.lower() for e in extensions))
847File extension is in extensions list
3python
1i5pc
my $mtime = (stat($file))[9]; use File::stat qw(stat); my $mtime = stat($file)->mtime; utime(stat($file)->atime, time, $file);
844File modification time
2perl
hsujl
(defn fasta [pathname] (with-open [r (clojure.java.io/reader pathname)] (doseq [line (line-seq r)] (if (= (first line) \>) (print (format "%n%s: " (subs line 1))) (print line)))))
854FASTA format
6clojure
jqt7m
<?php $filename = 'input.txt'; $mtime = filemtime($filename); touch($filename, time(), fileatime($filename)); ?>
844File modification time
12php
zu8t1
from functools import wraps from turtle import * def memoize(obj): cache = obj.cache = {} @wraps(obj) def memoizer(*args, **kwargs): key = str(args) + str(kwargs) if key not in cache: cache[key] = obj(*args, **kwargs) return cache[key] return memoizer @memoize def f...
846Fibonacci word/fractal
3python
350zc
(filter even? (range 0 100)) (vec (filter even? (vec (range 0 100))))
853Filter
6clojure
hs3jr
my $x = 0; recurse($x); sub recurse ($x) { print ++$x,"\n"; recurse($x); }
841Find limit of recursion
2perl
lhyc5
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
845File size
1lua
oma8h
def factors(x): factors = [] i = 2 s = int(x ** 0.5) while i < s: if x% i == 0: factors.append(i) x = int(x / i) s = int(x ** 0.5) i += 1 factors.append(x) return factors print() for i in range(10): fermat = 2 ** 2 ** i + 1 print(.form...
849Fermat numbers
3python
zuwtt
use strict; use warnings; use Math::AnyNum 'sqr'; my $a1 = 1.0; my $a2 = 0.0; my $d1 = 3.2; print " i \n"; for my $i (2..13) { my $a = $a1 + ($a1 - $a2)/$d1; for (1..10) { my $x = 0; my $y = 0; for (1 .. 2**$i) { $y = 1 - 2 * $y * $x; $x = $a - sqr($x)...
848Feigenbaum constant calculation
2perl
qz7x6
def is_ext(filename, extensions) if filename.respond_to?(:each) filename.each do |fn| is_ext(fn, extensions) end else fndc = filename.downcase extensions.each do |ext| bool = fndc.end_with?(?. + ext.downcase) puts % [filename, bool] if bool end end end
847File extension is in extensions list
14ruby
edgax
import os modtime = os.path.getmtime('filename') os.utime('path', (actime, mtime)) os.utime('path', (os.path.getatime('path'), mtime)) os.utime('path', None)
844File modification time
3python
k05hf
fibow <- function(n) { t2="0"; t1="01"; t=""; if(n<2) {n=2} for (i in 2:n) {t=paste0(t1,t2); t2=t1; t1=t} return(t) } pfibofractal <- function(n, w, h, d, clr) { dx=d; x=y=x2=y2=tx=dy=nr=0; if(n<2) {n=2} fw=fibow(n); nf=nchar(fw); pf = paste0("FiboFractR", n, ".png"); ttl=paste0("Fibonacci word/frac...
846Fibonacci word/fractal
13r
dlwnt