code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
<?php
$encoded = ;
$unencoded = rawurldecode($encoded);
echo ;
?> | 80URL decoding | 12php | 1h2pq |
DIGIT_F = {
=> 0,
=> 1,
=> 2,
=> 3,
=> 4,
=> 5,
=> 6,
=> 7,
=> 8,
=> 9,
}
DIGIT_R = {
=> 0,
=> 1,
=> 2,
=> 3,
=> 4,
=> 5,
=> 6,
=> 7,
=> 8,
=> 9,
}
END_SENTINEL =
MID_SENTINEL =
def decode_upc(s)
def decode_upc_... | 84UPC | 14ruby | n07it |
print('Enter a string: ')
s = io.stdin:read()
print('Enter a number: ')
i = tonumber(io.stdin:read()) | 83User input/Text | 1lua | v982x |
Vector = {}
function Vector.new( _x, _y, _z )
return { x=_x, y=_y, z=_z }
end
function Vector.dot( A, B )
return A.x*B.x + A.y*B.y + A.z*B.z
end
function Vector.cross( A, B )
return { x = A.y*B.z - A.z*B.y,
y = A.z*B.x - A.x*B.z,
z = A.x*B.y - A.y*B.x }
end
function Vector.scal... | 72Vector products | 1lua | c6392 |
import urllib
print urllib.unquote()
from urllib.parse import unquote
print(unquote('http%3A%2F%2Ffoo%20bar%2F')) | 80URL decoding | 3python | ytq6q |
require 'tk'
def main
root = TkRoot.new
l1 = TkLabel.new(root, => )
e1 = TkEntry.new(root)
l2 = TkLabel.new(root, => )
e2 = TkEntry.new(root) do
validate
validatecommand lambda {e2.value.to_i == 75_000}
invalidcommand lambda {focus_number_entry(e2)}
end
ok = TkButton.new(root) do
text... | 82User input/Graphical | 14ruby | mzxyj |
require 'cgi'
puts CGI.escape().gsub(, ) | 78URL encoding | 14ruby | ruygs |
URLdecode("http%3A%2F%2Ffoo%20bar%2F") | 80URL decoding | 13r | tiafz |
import swing.Dialog.{Message, showInput}
import scala.swing.Swing
object UserInput extends App {
def responce = showInput(null,
"Complete the sentence:\n\"Green eggs and...\"",
"Customized Dialog",
Message.Plain,
Swing.EmptyIcon,
Nil, "ham")
println(responce)
} | 82User input/Graphical | 16scala | 2m8lb |
const INPUT: &str = "http: | 78URL encoding | 15rust | 75mrc |
import java.net.{URLDecoder, URLEncoder}
import scala.compat.Platform.currentTime
object UrlCoded extends App {
val original = """http: | 78URL encoding | 16scala | krlhk |
require 'cgi'
puts CGI.unescape() | 80URL decoding | 14ruby | 930mz |
sub dofruit {
$fruit='apple';
}
dofruit;
print "The fruit is $fruit"; | 76Variables | 2perl | mziyz |
const INPUT1: &str = "http%3A%2F%2Ffoo%20bar%2F";
const INPUT2: &str = "google.com/search?q=%60Abdu%27l-Bah%C3%A1";
fn append_frag(text: &mut String, frag: &mut String) {
if!frag.is_empty() {
let encoded = frag.chars()
.collect::<Vec<char>>()
.chunks(2)
.map(|ch| {
... | 80URL decoding | 15rust | c689z |
import java.net.{URLDecoder, URLEncoder}
import scala.compat.Platform.currentTime
object UrlCoded extends App {
val original = """http: | 80URL decoding | 16scala | v9n2s |
<?php
$null = NULL; var_dump($null);
$boolean = true; var_dump($boolean);
$boolean = false; var_dump($boolean);
$boolean = (bool)1; var_dump($boolean);
$boolean = (boolean)1; var_dump($boolean);
$boolean = (bool)0; var_dump($boolean);
$boolean = (boolean)0; var_dump($boolean);
$int =... | 76Variables | 12php | ebra9 |
import Foundation
let encoded = "http%3A%2F%2Ffoo%20bar%2F"
if let normal = encoded.stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding) {
println(normal)
} | 80URL decoding | 17swift | mzsyk |
example1 = 3
example2 = 3.0
example3 = True
example4 =
example1 = | 76Variables | 3python | 93nmf |
foo <- 3.4
bar = "abc" | 76Variables | 13r | 3d0zt |
print "Enter a string: ";
my $string = <>;
print "Enter an integer: ";
my $integer = <>; | 83User input/Text | 2perl | se5q3 |
$a_global_var = 5
class Demo
@@a_class_var = 6
A_CONSTANT = 8
def initialize
@an_instance_var = 7
end
def incr(a_local_var)
@an_instance_var += a_local_var
end
end | 76Variables | 14ruby | lyfcl |
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN); | 83User input/Text | 12php | ucov5 |
$ include "seed7_05.s7i";
var integer: foo is 5; # foo is global
const proc: aFunc is func
local
var integer: bar is 10; # bar is local to aFunc
begin
writeln("foo + bar = " <& foo + bar);
end func;
const proc: main is func
begin
aFunc;
end func; | 76Variables | 16scala | 5l6ut |
import Foundation | 76Variables | 17swift | c6d9t |
package Vector;
use List::Util 'sum';
use List::MoreUtils 'pairwise';
sub new { shift; bless [@_] }
use overload (
'""' => sub { "(@{+shift})" },
'&' => sub { sum pairwise { $a * $b } @{+shift}, @{+shift} },
'^' => sub {
my @a = @{+shift};
... | 72Vector products | 2perl | wpbe6 |
string = raw_input() | 83User input/Text | 3python | 0w4sq |
stringval <- readline("String: ")
intval <- as.integer(readline("Integer: ")) | 83User input/Text | 13r | wp2e5 |
int main()
{
int junk, *junkp;
printf(, junk);
junkp = malloc(sizeof *junkp);
if (junkp)
printf(, *junkp);
return 0;
} | 85Undefined values | 5c | yt16f |
<?php
class Vector
{
private $values;
public function setValues(array $values)
{
if (count($values) != 3)
throw new Exception('Values must contain exactly 3 values');
foreach ($values as $value)
if (!is_int($value) && !is_float($value))
throw new Exception('Value has an invalid type');
$this->valu... | 72Vector products | 12php | ly6cj |
print
s = gets
printf
i = gets.to_i
printf
f = Float(gets) rescue nil
puts
puts
puts | 83User input/Text | 14ruby | oqr8v |
int cmpstr(const void *a, const void *b)
{
return strcmp(*(const char**)a, *(const char**)b);
}
int main(void)
{
DIR *basedir;
char path[PATH_MAX];
struct dirent *entry;
char **dirnames;
int diralloc = 128;
int dirsize = 0;
if (!(dirnames = malloc(diralloc * sizeof(char*)))) {
... | 86Unix/ls | 5c | v9q2o |
use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... | 83User input/Text | 15rust | is7od |
print("Enter a number: ")
val i=Console.readLong | 83User input/Text | 16scala | fokd4 |
package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println("Exercise nil objects:")
status() | 85Undefined values | 0go | 1hyp5 |
int main() {
int = 1;
++;
printf(,);
return 0;
} | 87Unicode variable names | 5c | ucqv4 |
(def files (sort (filter #(= "." (.getParent %)) (file-seq (clojure.java.io/file ".")))))
(doseq [n files] (println (.getName n))) | 86Unix/ls | 6clojure | ruig2 |
main = print $ "Incoming error | 85Undefined values | 8haskell | tihf7 |
(let [ 1]
(inc )) | 87Unicode variable names | 6clojure | 75ir0 |
String string = null; | 85Undefined values | 9java | 8x506 |
typedef struct bit_array_tag {
uint32_t size;
uint32_t* array;
} bit_array;
bool bit_array_create(bit_array* b, uint32_t size) {
uint32_t* array = calloc((size + 31)/32, sizeof(uint32_t));
if (array == NULL)
return false;
b->size = size;
b->array = array;
return true;
}
void bit_ar... | 88Unprimeable numbers | 5c | gv045 |
def crossp(a, b):
'''Cross product of two 3D vectors'''
assert len(a) == len(b) == 3, 'For 3D vectors only'
a1, a2, a3 = a
b1, b2, b3 = b
return (a2*b3 - a3*b2, a3*b1 - a1*b3, a1*b2 - a2*b1)
def dotp(a,b):
'''Dot product of two eqi-dimensioned vectors'''
assert len(a) == len(b), 'Vector siz... | 72Vector products | 3python | x1pwr |
var a;
typeof(a) === "undefined";
typeof(b) === "undefined";
var obj = {}; | 85Undefined values | 10javascript | fojdg |
package main
import (
"fmt"
big "github.com/ncw/gmp"
)
var two = big.NewInt(2)
func a(n uint) int {
one := big.NewInt(1)
p := new(big.Int).Lsh(one, 1 << n)
p.Sub(p, one)
for k := 1; ; k += 2 {
if p.ProbablyPrime(15) {
return k
}
p.Sub(p, two)
}
}
func ... | 89Ultra useful primes | 0go | qamxz |
int biased(int bias)
{
int r, rand_max = RAND_MAX - (RAND_MAX % bias);
while ((r = rand()) > rand_max);
return r < rand_max / bias;
}
int unbiased(int bias)
{
int a;
while ((a = biased(bias)) == biased(bias));
return a;
}
int main()
{
int b, n = 10000, cb, cu, i;
for (b = 3; b <= 6; b++) {
for (i = cb = c... | 90Unbias a random generator | 5c | n0vi6 |
package main
import "fmt"
func sumDivisors(n int) int {
sum := 1
k := 2
if n%2 == 0 {
k = 1
}
for i := 1 + k; i*i <= n; i += k {
if n%i == 0 {
sum += i
j := n / i
if j != i {
sum += j
}
}
}
return sum
}... | 91Untouchable numbers | 0go | foud0 |
print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
} | 83User input/Text | 17swift | 8xg0v |
null | 85Undefined values | 11kotlin | wpcek |
use strict;
use warnings;
use feature 'say';
use bigint;
use ntheory 'is_prime';
sub useful {
my @n = @_;
my @u;
for my $n (@n) {
my $p = 2**(2**$n);
LOOP: for (my $k = 1; $k < $p; $k += 2) {
is_prime($p-$k) and push @u, $k and last LOOP;
}
}
@u
}
say join ' ', u... | 89Ultra useful primes | 2perl | 42q5d |
a <- c(3, 4, 5)
b <- c(4, 3, 5)
c <- c(-5, -12, -13)
dotp <- function(x, y) {
if (length(x) == length(y)) {
sum(x*y)
}
}
crossp <- function(x, y) {
if (length(x) == 3 && length(y) == 3) {
c(x[2]*y[3] - x[3]*y[2], x[3]*y[1] - x[1]*y[3], x[1]*y[2] - x[2]*y[1])
}
}
scalartriplep <- function(... | 72Vector products | 13r | 1hjpn |
wchar_t poker[] = L;
wchar_t four_two[] = L;
int main() {
if (!setlocale(LC_CTYPE, )) {
fprintf(stderr, );
return 1;
}
printf(, 0x2708);
printf(, poker);
printf(, four_two);
printf();
printf();
printf();
return 0;
} | 92Unicode strings | 5c | akd11 |
print( a )
local b
print( b )
if b == nil then
b = 5
end
print( b ) | 85Undefined values | 1lua | x1lwz |
package main
import "fmt"
func main() {
:= 1
++
fmt.Println()
} | 87Unicode variable names | 0go | 0w2sk |
main = print
where = 1
= + 1 | 87Unicode variable names | 7groovy | ebyal |
(defn biased [n]
(if (< (rand 2) (/ n)) 0 1))
(defn unbiased [n]
(loop [a 0 b 0]
(if (= a b)
(recur (biased n) (biased n))
a)))
(for [n (range 3 7)]
[n
(double (/ (apply + (take 50000 (repeatedly #(biased n)))) 50000))
(double (/ (apply + (take 50000 (repeatedly #(unbiased n)))) 50000))])
... | 90Unbias a random generator | 6clojure | 3drzr |
main = print
where = 1
= + 1 | 87Unicode variable names | 8haskell | c6a94 |
use strict;
use warnings;
use enum qw(False True);
use ntheory qw/divisor_sum is_prime/;
sub sieve {
my($n) = @_;
my %s;
for my $k (0 .. $n+1) {
my $sum = divisor_sum($k) - $k;
$s{$sum} = True if $sum <= $n+1;
}
%s
}
my(%s,%c);
my($max, $limit, $cnt) = (2000, 1e5, 0);
%s = sieve 1... | 91Untouchable numbers | 2perl | pjnb0 |
package main
import (
"fmt"
"math/big"
"time"
)
var maxChar = 128
type Node struct {
children []*Node
suffixLink *Node
start int
end *int
suffixIndex int
}
var (
text string
root *Node
lastNewNode *Node
active... | 93Ukkonen’s suffix tree construction | 0go | gve4n |
package main
import (
"fmt"
"log"
"os"
"sort"
)
func main() {
f, err := os.Open(".")
if err != nil {
log.Fatal(err)
}
files, err := f.Readdirnames(0)
f.Close()
if err != nil {
log.Fatal(err)
}
sort.Strings(files)
for _, n := range files {
fmt.Println(n)
}
} | 86Unix/ls | 0go | se2qa |
int = 1;
double = 3.141592;
String = "hello";
++;
System.out.println(); | 87Unicode variable names | 9java | znjtq |
var = "something";
var = "hello";
var = "too less";
var = "javascript"; | 87Unicode variable names | 10javascript | 931ml |
import Control.Monad
import Data.List
import System.Directory
dontStartWith = flip $ (/=) . head
main = do
files <- getDirectoryContents "."
mapM_ putStrLn $ sort $ filter (dontStartWith '.') files | 86Unix/ls | 8haskell | 93amo |
var i int
var u rune
for i, u = range "voil" {
fmt.Println(i, u)
} | 92Unicode strings | 0go | mz7yi |
package main
import (
"fmt"
"strconv"
)
func isPrime(n int) bool {
switch {
case n < 2:
return false
case n%2 == 0:
return n == 2
case n%3 == 0:
return n == 3
default:
d := 5
for d*d <= n {
if n%d == 0 {
return false
... | 88Unprimeable numbers | 0go | isuog |
fun main(args: Array<String>) {
var = 1
++
print()
} | 87Unicode variable names | 11kotlin | is5o4 |
package rosetta;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class UnixLS {
public static void main(String[] args) throws IOException {
Files.list(Path.of("")).sorted().forEach(System.out::println);
}
} | 86Unix/ls | 9java | tijf9 |
const fs = require('fs');
fs.readdir('.', (err, names) => names.sort().map( name => console.log(name) )); | 86Unix/ls | 10javascript | mz1yv |
require 'matrix'
class Vector
def scalar_triple_product(b, c)
self.inner_product(b.cross_product c)
end
def vector_triple_product(b, c)
self.cross_product(b.cross_product c)
end
end
a = Vector[3, 4, 5]
b = Vector[4, 3, 5]
c = Vector[-5, -12, -13]
puts
puts
puts
puts | 72Vector products | 14ruby | seaqw |
''
| 92Unicode strings | 8haskell | kr8h0 |
--raw-input | -R:: each line of input is converted to a JSON string;
--ascii-output | -a:: every non-ASCII character that would otherwise
be sent to output is translated to an equivalent
ASCII escape sequence;
--raw-output | -r:: output strings as raw strings, e.g.... | 92Unicode strings | 9java | 42e58 |
import Control.Lens ((.~), ix, (&))
import Data.Numbers.Primes (isPrime)
import Data.List (find, intercalate)
import Data.Char (intToDigit)
import Data.Maybe (mapMaybe)
import Data.List.Split (chunksOf)
import Text.Printf (printf)
isUnprimable :: Int -> Bool
isUnprimable = all (not . isPrime) . swapdigits
swapdigits ... | 88Unprimeable numbers | 8haskell | v9w2k |
= 1
= + 1
print() | 87Unicode variable names | 1lua | n04i8 |
#[derive(Debug)]
struct Vector {
x: f64,
y: f64,
z: f64,
}
impl Vector {
fn new(x: f64, y: f64, z: f64) -> Self {
Vector {
x: x,
y: y,
z: z,
}
}
fn dot_product(&self, other: &Vector) -> f64 {
(self.x * other.x) + (self.y * other.y) + ... | 72Vector products | 15rust | 0wesl |
use strict;
our $var;
print "var contains an undefined value at first check\n" unless defined $var;
$var = "Chocolate";
print "var contains an undefined value at second check\n" unless defined $var;
$var = undef;
undef($var);
print "var contains an undefined value at third check\n" unless defined $var;
... | 85Undefined values | 2perl | lyxc5 |
null | 92Unicode strings | 11kotlin | lykcp |
static int nextInt(int size) {
return rand() % size;
}
static bool cylinder[6];
static void rshift() {
bool t = cylinder[5];
int i;
for (i = 4; i >= 0; i--) {
cylinder[i + 1] = cylinder[i];
}
cylinder[0] = t;
}
static void unload() {
int i;
for (i = 0; i < 6; i++) {
cy... | 94Two bullet roulette | 5c | v9k2o |
null | 86Unix/ls | 11kotlin | oq58z |
case class Vector3D(x:Double, y:Double, z:Double) {
def dot(v:Vector3D):Double=x*v.x + y*v.y + z*v.z;
def cross(v:Vector3D)=Vector3D(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x)
def scalarTriple(v1:Vector3D, v2:Vector3D)=this dot (v1 cross v2)
def vectorTriple(v1:Vector3D, v2:Vector3D)=this cross (v1 cross v2)
... | 72Vector products | 16scala | isqox |
<?php
if (!isset($var))
echo ;
$var = ;
if (!isset($var))
echo ;
unset($var);
if (!isset($var))
echo ;
$var = 42;
if (!isset($var))
echo ;
echo ;
?> | 85Undefined values | 12php | qa2x3 |
public class UnprimeableNumbers {
private static int MAX = 10_000_000;
private static boolean[] primes = new boolean[MAX];
public static void main(String[] args) {
sieve();
System.out.println("First 35 unprimeable numbers:");
displayUnprimeableNumbers(35);
int n = 600;
... | 88Unprimeable numbers | 9java | ytk6g |
require("lfs")
for file in lfs.dir(".") do print(file) end | 86Unix/ls | 1lua | is4ot |
bool isPrime(int64_t n) {
int64_t i;
if (n < 2) return false;
if (n % 2 == 0) return n == 2;
if (n % 3 == 0) return n == 3;
if (n % 5 == 0) return n == 5;
if (n % 7 == 0) return n == 7;
if (n % 11 == 0) return n == 11;
if (n % 13 == 0) return n == 13;
if (n % 17 == 0) retu... | 95Twin primes | 5c | 93gm1 |
Number.prototype.isPrime = function() {
let i = 2, num = this;
if (num == 0 || num == 1) return false;
if (num == 2) return true;
while (i <= Math.ceil(Math.sqrt(num))) {
if (num % i == 0) return false;
i++;
}
return true;
} | 88Unprimeable numbers | 10javascript | 2melr |
use utf8;
my $ = 1;
$++;
print $, "\n"; | 87Unicode variable names | 2perl | ruogd |
package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
var cylinder = [6]bool{}
func rshift() {
t := cylinder[5]
for i := 4; i >= 0; i-- {
cylinder[i+1] = cylinder[i]
}
cylinder[0] = t
}
func unload() {
for i := 0; i < 6; i++ {
cylinder[i] = false
}
}
fun... | 94Two bullet roulette | 0go | sezqa |
<?php
$ = 1;
++$;
echo $; | 87Unicode variable names | 12php | d8gn8 |
let Pistol = function(method) {
this.fired = false;
this.cylinder = new Array(6).fill(false);
this.trigger = 0;
this.rshift = function() {
this.trigger = this.trigger == 0 ? 5 : this.trigger-1;
}
this.load = function() {
while (this.cylinder[this.trigger]) this.rshift();
this.cylinder[this.trigg... | 94Two bullet roulette | 10javascript | mzgyv |
try: name
except NameError: print
name =
try: name
except NameError: print
del name
try: name
except NameError: print
name = 42
try: name
except NameError: print
print | 85Undefined values | 3python | 2mqlz |
>>> x = 1
>>> x += 1
>>> print(x)
2
>>> | 87Unicode variable names | 3python | 75irm |
f <- function(``=1) ``+1
f(1) | 87Unicode variable names | 13r | 5lsuy |
package main
import (
"fmt"
"math/rand"
)
const samples = 1e6
func main() {
fmt.Println("Generator 1 count 0 count % 1 count")
for n := 3; n <= 6; n++ { | 90Unbias a random generator | 0go | rusgm |
import kotlin.random.Random
val cylinder = Array(6) { false }
fun rShift() {
val t = cylinder[cylinder.size - 1]
for (i in (0 until cylinder.size - 1).reversed()) {
cylinder[i + 1] = cylinder[i]
}
cylinder[0] = t
}
fun unload() {
for (i in cylinder.indices) {
cylinder[i] = false
... | 94Two bullet roulette | 11kotlin | oqy8z |
opendir my $handle, '.' or die "Couldnt open current directory: $!";
while (readdir $handle) {
print "$_\n";
}
closedir $handle; | 86Unix/ls | 2perl | gvo4e |
exists("x") | 85Undefined values | 13r | mzay4 |
use utf8; | 92Unicode strings | 2perl | qa3x6 |
private const val MAX = 10000000
private val primes = BooleanArray(MAX)
fun main() {
sieve()
println("First 35 unprimeable numbers:")
displayUnprimeableNumbers(35)
val n = 600
println()
println("The ${n}th unprimeable number = ${nthUnprimeableNumber(n)}")
println()
val lowest = genLowes... | 88Unprimeable numbers | 11kotlin | fogdo |
import Control.Monad.Random
import Control.Monad
import Text.Printf
randN :: MonadRandom m => Int -> m Int
randN n = fromList [(0, fromIntegral n-1), (1, 1)] | 90Unbias a random generator | 8haskell | 0w9s7 |
use strict;
use warnings;
use feature 'say';
my @cyl;
my $shots = 6;
sub load {
push @cyl, shift @cyl while $cyl[1];
$cyl[1] = 1;
push @cyl, shift @cyl
}
sub spin { push @cyl, shift @cyl for 0 .. int rand @cyl }
sub fire { push @cyl, shift @cyl; $cyl[0] }
sub LSLSFSF {
@cyl = (0) x $shots;
lo... | 94Two bullet roulette | 2perl | gva4e |
<?php
foreach(scandir('.') as $fileName){
echo $fileName.;
} | 86Unix/ls | 12php | n0gig |
u = 'abcd'
print(ord(u[-1])) | 92Unicode strings | 3python | se6q9 |
null | 88Unprimeable numbers | 1lua | tirfn |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.