code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
(show . (+1) . read) "1234"
727Increment a numerical string
8haskell
5xhug
import java.io.BufferedReader; import java.io.FileReader; public class IbeforeE { public static void main(String[] args) { IbeforeE now=new IbeforeE(); String wordlist="unixdict.txt"; if(now.isPlausibleRule(wordlist)) System.out.println("Rule is plausible."); else System.out.println("Rule is not plaus...
728I before E except after C
9java
w68ej
import java.math.BigInteger; import java.util.*; public class IBAN { private static final String DEFSTRS = "" + "AL28 AD24 AT20 AZ28 BE16 BH22 BA20 BR29 BG22 " + "HR21 CY28 CZ24 DK18 DO28 EE20 FO18 FI18 FR27 GE22 DE22 GI23 " + "GL18 GT28 HU28 IS26 IE22 IL23 IT27 KZ20 KW30 LV21 L...
729IBAN
9java
knahm
def humble?(i) while i % 2 == 0; i /= 2 end while i % 3 == 0; i /= 3 end while i % 5 == 0; i /= 5 end while i % 7 == 0; i /= 7 end i == 1 end count, num = 0, 0 digits = 10 limit = 10 ** digits humble = Array.new(digits + 1, 0) while (num += 1) < limit if humble?(num)...
726Humble numbers
14ruby
r01gs
require 'file'
723Include a file
14ruby
r0wgs
mod test; fn main() { test::some_function(); }
723Include a file
15rust
78xrc
var ibanLen = { NO:15, BE:16, DK:18, FI:18, FO:18, GL:18, NL:18, MK:19, SI:19, AT:20, BA:20, EE:20, KZ:20, LT:20, LU:20, CR:21, CH:21, HR:21, LI:21, LV:21, BG:22, BH:22, DE:22, GB:22, GE:22, IE:22, ME:22, RS:22, AE:23, GI:23, IL:23, AD:24, CZ:24, ES:24, MD:24, PK:24, RO:24, SA:24, SE:24, SK:24, VG:24, TN:24, PT:...
729IBAN
10javascript
e3sao
null
728I before E except after C
11kotlin
bdwkb
(load "filename")
723Include a file
16scala
kn0hk
my $i = 0; print ++$i, "\n" while 1;
714Integer sequence
2perl
d5jnw
null
728I before E except after C
1lua
pfxbw
String s = "12345"; s = String.valueOf(Integer.parseInt(s) + 1);
727Increment a numerical string
9java
9b5mu
let s = '9999'; let splusplus = (+s+1)+"" console.log([splusplus, typeof splusplus])
727Increment a numerical string
10javascript
uwjvb
null
729IBAN
11kotlin
gsh4d
null
727Increment a numerical string
11kotlin
zrcts
package main import ( "fmt" "log" ) func main() { var n1, n2 int fmt.Print("enter number: ") if _, err := fmt.Scan(&n1); err != nil { log.Fatal(err) } fmt.Print("enter number: ") if _, err := fmt.Scan(&n2); err != nil { log.Fatal(err) } switch { case n1 < n2: fmt.Println(n1, "less than", n2) case n1...
725Integer comparison
0go
pf0bg
local length= { AL=28, AD=24, AT=20, AZ=28, BH=22, BE=16, BA=20, BR=29, BG=22, CR=21, HR=21, CY=28, CZ=24, DK=18, DO=28, EE=20, FO=18, FI=18, FR=27, GE=22, DE=22, GI=23, GR=27, GL=18, GT=28, HU=28, IS=26, IE=22, IL=23, IT=27, JO=30, KZ=20, KW=30, LV=21, LB=28, LI=21, LT=20, LU=20, MK=19, MT=31, MR=27, MU=30, ...
729IBAN
1lua
r0kga
i=1 while i: print(i) i += 1
714Integer sequence
3python
f4hde
def comparison = { a, b -> println "a? b = ${a}? ${b} = a ${a < b? '<': a > b? '>': a == b? '==': '?'} b" }
725Integer comparison
7groovy
78erz
z <- 0 repeat { print(z) z <- z + 1 }
714Integer sequence
13r
o2g84
myCompare :: Integer -> Integer -> String myCompare a b | a < b = "A is less than B" | a > b = "A is greater than B" | a == b = "A equals B" main = do a <- readLn b <- readLn putStrLn $ myCompare a b
725Integer comparison
8haskell
f4cd1
use warnings; use strict; sub result { my ($support, $against) = @_; my $ratio = sprintf '%.2f', $support / $against; my $result = $ratio >= 2; print "$support / $against = $ratio. ", 'NOT ' x !$result, "PLAUSIBLE\n"; return $result; } my @keys = qw(ei cei ie cie); my %count; while (<>) { f...
728I before E except after C
2perl
6jl36
1.step{|n| puts n}
714Integer sequence
14ruby
zrbtw
fn main() { for i in 0.. { println!("{}", i); } }
714Integer sequence
15rust
37pz8
package main import ( "fmt" "gonum.org/v1/gonum/mat" ) func eye(n int) *mat.Dense { m := mat.NewDense(n, n, nil) for i := 0; i < n; i++ { m.Set(i, i, 1) } return m } func main() { fmt.Println(mat.Formatted(eye(3))) }
730Identity matrix
0go
78kr2
Stream from 1 foreach println
714Integer sequence
16scala
mkeyc
>
727Increment a numerical string
1lua
37lzo
def makeIdentityMatrix = { n -> (0..<n).collect { i -> (0..<n).collect { j -> (i == j) ? 1: 0 } } }
730Identity matrix
7groovy
uwgv9
import java.io.*; public class compInt { public static void main(String[] args) { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int nbr1 = Integer.parseInt(in.readLine()); int nbr2 = Integer.parseInt(in.readLine()); if(nbr1<nbr2)...
725Integer comparison
9java
0czse
use strict ; use warnings ; use Math::BigInt ; my %countrycodelengths = ( "AL" => 28, "AD" => 24, "AT" => 20, "AZ" => 28, "BE" => 16, "BH" => 22, "BA" => 20, "BR" => 29, "BG" => 22, "CR" => 21, "HR" => 21, "CY" => 28, "CZ" => 24, "DK" => 18, "DO...
729IBAN
2perl
nuziw
matI n = [ [fromEnum $ i == j | i <- [1..n]] | j <- [1..n]]
730Identity matrix
8haskell
8ln0z
null
725Integer comparison
10javascript
d59nu
package main import ( "crypto/tls" "io/ioutil" "log" "net/http" ) func main() {
731HTTPS/Client-authenticated
0go
9blmt
import urllib.request import re PLAUSIBILITY_RATIO = 2 def plausibility_check(comment, x, y): print('\n Checking plausibility of:%s'% comment) if x > PLAUSIBILITY_RATIO * y: print(' PLAUSIBLE. As we have counts of%i vs%i, a ratio of%4.1f times' % (x, y, x / y)) else: if x ...
728I before E except after C
3python
yh26q
null
731HTTPS/Client-authenticated
11kotlin
2auli
<?php function piece_wise($iban_all_digits) { $remainder = NULL; $slice = 9; for ($i=0; $i<strlen($iban_all_digits); $i=$i+$slice) { if ($i>0) { $slice = 7; } $part = $remainder . substr($iban_all_digits, $i, $slice); $remainder...
729IBAN
12php
78brp
var i = 0 while true { println(i++) }
714Integer sequence
17swift
tgkfl
use 5.018_002; use warnings; use LWP; our $VERSION = 1.000_000; my $ua = LWP::UserAgent->new( ssl_opts => { SSL_cert_file => 'certificate.pem', SSL_key_file => 'key.pem', verify_hostname => 1, } ); my $req = HTTP::Request->new( GET => 'https://www.example.com' ); my $res = $ua->re...
731HTTPS/Client-authenticated
2perl
s98q3
int main(void) { CURL *curl; char buffer[CURL_ERROR_SIZE]; if ((curl = curl_easy_init()) != NULL) { curl_easy_setopt(curl, CURLOPT_URL, ); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer); ...
732HTTPS/Authenticated
5c
xyqwu
words = tolower(readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")) ie.npc = sum(grepl("(?<!c)ie", words, perl = T)) ei.npc = sum(grepl("(?<!c)ei", words, perl = T)) ie.pc = sum(grepl("cie", words, fixed = T)) ei.pc = sum(grepl("cei", words, fixed = T)) p1 = ie.npc > 2 * ei.npc p2 = ei.pc > 2 * ie.pc me...
728I before E except after C
13r
tgmfz
fun main(args: Array<String>) { val n1 = readLine()!!.toLong() val n2 = readLine()!!.toLong() println(when { n1 < n2 -> "$n1 is less than $n2" n1 > n2 -> "$n1 is greater than $n2" n1 == n2 -> "$n1 is equal to $n2" else -> "" }) }
725Integer comparison
11kotlin
e3ia4
(clj-http.client/get "https://somedomain.com" {:basic-auth ["user" "pass"]})
732HTTPS/Authenticated
6clojure
o2i8j
public class PrintIdentityMatrix { public static void main(String[] args) { int n = 5; int[][] array = new int[n][n]; IntStream.range(0, n).forEach(i -> array[i][i] = 1); Arrays.stream(array) .map((int[] a) -> Arrays.toString(a)) .forEach(System.out...
730Identity matrix
9java
e3qa5
import httplib connection = httplib.HTTPSConnection('www.example.com',cert_file='myCert.PEM') connection.request('GET','/index.html') response = connection.getresponse() data = response.read()
731HTTPS/Client-authenticated
3python
0cosq
package main import ( "encoding/base64" "io" "log" "net/http" "strings" ) const userPass = "rosetta:code" const unauth = http.StatusUnauthorized func hw(w http.ResponseWriter, req *http.Request) { auth := req.Header.Get("Authorization") if !strings.HasPrefix(auth, "Basic ") { log....
732HTTPS/Authenticated
0go
l12cw
function idMatrix(n) { return Array.apply(null, new Array(n)) .map(function (x, i, xs) { return xs.map(function (_, k) { return i === k ? 1 : 0; }) }); }
730Identity matrix
10javascript
0cisz
require 'uri' require 'net/http' uri = URI.parse('https: pem = File.read() cert = OpenSSL::X509::Certificate.new(pem) key = OpenSSL::PKey::RSA.new(pem) response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, cert: cert, key: key) do |http| request = Net::HTTP::Get.new uri http.requ...
731HTTPS/Client-authenticated
14ruby
o2n8v
reqwest = {version = "0.11", features = ["native-tls", "blocking"]}
731HTTPS/Client-authenticated
15rust
ivdod
import java.io.FileInputStream import java.net.URL import java.security.KeyStore import javax.net.ssl.{HttpsURLConnection, KeyManagerFactory, SSLContext} import scala.io.BufferedSource object ClientAuthenticated extends App { val con: HttpsURLConnection = new URL("https:
731HTTPS/Client-authenticated
16scala
f4zd4
module Main (main) where import Data.Aeson (Value) import Data.Default.Class (def) import Network.HTTP.Req ( (/:) , GET(..) , NoReqBody(..) , basicAuth , https , jsonRes...
732HTTPS/Authenticated
8haskell
1taps
null
732HTTPS/Authenticated
11kotlin
uw5vc
import re _country2length = dict( AL=28, AD=24, AT=20, AZ=28, BE=16, BH=22, BA=20, BR=29, BG=22, CR=21, HR=21, CY=28, CZ=24, DK=18, DO=28, EE=20, FO=18, FI=18, FR=27, GE=22, DE=22, GI=23, GR=27, GL=18, GT=28, HU=28, IS=26, IE=22, IL=23, IT=27, KZ=20, KW=30, LV=21, LB=28, LI=21, LT=20, LU=20, MK=19,...
729IBAN
3python
d53n1
local requests = require('requests') local auth = requests.HTTPBasicAuth('admin', 'admin') local resp, e = requests.get({ url = 'https://httpbin.org/basic-auth/admin/admin', auth = auth }) io.write(string.format('Status:%d', resp.status_code))
732HTTPS/Authenticated
1lua
5x4u6
use LWP::UserAgent qw(); my $ua = LWP::UserAgent->new; my $netloc = 'http://www.buddhism-dict.net/cgi-bin/xpr-dealt.pl:80'; $ua->credentials( $netloc, 'CJK-E and Buddhist Dictionaries', 'guest', '', ); my $response = $ua->get($netloc); use WWW::Mechanize qw(); my $mech = WWW::Mechanize->new; $mec...
732HTTPS/Authenticated
2perl
8lo0w
require 'open-uri' plausibility_ratio = 2 counter = Hash.new(0) path = 'http: rules = [['I before E when not preceded by C:', 'ie', 'ei'], ['E before I when preceded by C:', 'cei', 'cie']] open(path){|f| f.each{|line| line.scan(/ie|ei|cie|cei/){|match| counter[match] += 1 }}} overall_plausible = rules.all? ...
728I before E except after C
14ruby
9bumz
from mechanize import Browser USER_AGENT = br = Browser() br.addheaders = [(, USER_AGENT)] br.open() br.select_form() br['email'] = br['pass'] = br['persistent'] = [] response = br.submit() print response.read()
732HTTPS/Authenticated
3python
o2i81
CURL *curl; char buffer[CURL_ERROR_SIZE]; int main(void) { if ((curl = curl_easy_init()) != NULL) { curl_easy_setopt(curl, CURLOPT_URL, ); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer); if (curl_easy_perform(curl) != CURLE_OK) ...
733HTTPS
5c
yhy6f
import std.math, grayscale_image; Image!Gray houghTransform(in Image!Gray im, in size_t hx=460, in size_t hy=360) pure nothrow in { assert(im !is null); assert(hx > 0 && hy > 0); assert((hy & 1) == 0, ); } body { auto result = new Image!Gray(hx, hy); result.clear(Gray.whit...
734Hough transform
5c
val2o
null
730Identity matrix
11kotlin
kn1h3
use std::default::Default; use std::ops::AddAssign; use itertools::Itertools; use reqwest::get; #[derive(Default, Debug)] struct Feature<T> { pub cie: T, pub xie: T, pub cei: T, pub xei: T, } impl AddAssign<Feature<bool>> for Feature<u64> { fn add_assign(&mut self, rhs: Feature<bool>) { s...
728I before E except after C
15rust
cp59z
print('Enter the first number: ') a = tonumber(io.stdin:read()) print('Enter the second number: ') b = tonumber(io.stdin:read()) if a < b then print(a .. " is less than " .. b) end if a > b then print(a .. " is greater than " .. b) end if a == b then print(a .. " is equal to " .. b) end
725Integer comparison
1lua
w6nea
require 'uri' require 'net/http' uri = URI.parse('https: response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| request = Net::HTTP::Get.new uri request.basic_auth('username', 'password') http.request request end
732HTTPS/Authenticated
14ruby
nudit
(use '[clojure.contrib.duck-streams:only (slurp*)]) (print (slurp* "https://sourceforge.net"))
733HTTPS
6clojure
2a2l1
object I_before_E_except_after_C extends App { val testIE1 = "(^|[^c])ie".r
728I before E except after C
16scala
ver2s
extern crate reqwest; use reqwest::blocking::Client; use reqwest::header::CONNECTION; fn main() { let client = Client::new();
732HTTPS/Authenticated
15rust
d5fny
import java.net.{Authenticator, PasswordAuthentication, URL} import javax.net.ssl.HttpsURLConnection import scala.io.BufferedSource object Authenticated extends App { val con: HttpsURLConnection = new URL("https:
732HTTPS/Authenticated
16scala
zr3tr
int main() { int one = 1; printf(, (int)(CHAR_BIT * sizeof(size_t))); if (*(char *)&one) printf(); else printf(); return 0; }
735Host introspection
5c
uelv4
def valid_iban? iban len = { AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16, BH: 22, BA: 20, BR: 29, BG: 22, CR: 21, HR: 21, CY: 28, CZ: 24, DK: 18, DO: 28, EE: 20, FO: 18, FI: 18, FR: 27, GE: 22, DE: 22, GI: 23, GR: 27, GL: 18, GT: 28, HU: 28, IS: 26, IE: 22, IL: 23, IT: 27, KZ: 20, KW: 30, LV: 21, LB: 2...
729IBAN
14ruby
tgyf2
package main import ( "fmt" "image" "image/color" "image/draw" "image/png" "math" "os" ) func hough(im image.Image, ntx, mry int) draw.Image { nimx := im.Bounds().Max.X mimy := im.Bounds().Max.Y him := image.NewGray(image.Rect(0, 0, ntx, mry)) draw.Draw(him, him.Bounds(), ...
734Hough transform
0go
smxqa
fn main() { for iban in [ "", "x", "QQ82", "QQ82W", "GB82 TEST 1234 5698 7654 322", "gb82 WEST 1234 5698 7654 32", "GB82 WEST 1234 5698 7654 32", "GB82 TEST 1234 5698 7654 32", "GB81 WEST 1234 5698 7654 32", "SA03 8000 0000 6080 1016 75...
729IBAN
15rust
zrmto
import Control.Monad (forM_, when) import Data.Array ((!)) import Data.Array.ST (newArray, writeArray, readArray, runSTArray) import qualified Data.Foldable as F (maximum) import System.Environment (getArgs, getProgName) import Codec.Picture (DynamicImage(ImageRGB8, ImageRGBA8), Image, PixelRGB8(PixelRGB8), ...
734Hough transform
8haskell
9kymo
import Foundation let request = NSURLRequest(URL: NSURL(string: "http:
728I before E except after C
17swift
mkvyk
struct huffcode { int nbits; int code; }; typedef struct huffcode huffcode_t; struct huffheap { int *h; int n, s, cs; long *f; }; typedef struct huffheap heap_t; static heap_t *_heap_create(int s, long *f) { heap_t *h; h = malloc(sizeof(heap_t)); h->h = malloc(sizeof(int)*s); h->s = h->cs = s; h-...
736Huffman coding
5c
gqv45
(.. java.net.InetAddress getLocalHost getHostName)
737Hostname
6clojure
gq24f
import scala.collection.immutable.SortedMap class Iban(val iban: String) {
729IBAN
16scala
yhl63
import java.awt.image.*; import java.io.File; import java.io.IOException; import javax.imageio.*; public class HoughTransform { public static ArrayData houghTransform(ArrayData inputData, int thetaAxisSize, int rAxisSize, int minContrast) { int width = inputData.width; int height = inputData.height; in...
734Hough transform
9java
t4df9
package main import ( "io" "log" "net/http" "os" ) func main() { r, err := http.Get("https:
733HTTPS
0go
1t1p5
(println "word size: " (System/getProperty "sun.arch.data.model")) (println "endianness: " (System/getProperty "sun.cpu.endian"))
735Host introspection
6clojure
704r0
import java.awt.image.BufferedImage import java.io.File import javax.imageio.ImageIO internal class ArrayData(val dataArray: IntArray, val width: Int, val height: Int) { constructor(width: Int, height: Int) : this(IntArray(width * height), width, height) operator fun get(x: Int, y: Int) = dataArray[y * width...
734Hough transform
11kotlin
ol08z
function identity_matrix (size) local m = {} for i = 1, size do m[i] = {} for j = 1, size do m[i][j] = i == j and 1 or 0 end end return m end function print_matrix (m) for i = 1, #m do print(...
730Identity matrix
1lua
bdaka
my $s = "12345"; $s++;
727Increment a numerical string
2perl
bdxk4
new URL("https:
733HTTPS
7groovy
joj7o
#!/usr/bin/runhaskell import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as L import Network (withSocketsDo) main = withSocketsDo $ simpleHttp "https://sourceforge.net/" >>= L.putStr
733HTTPS
8haskell
tgtf7
$s = ; $s++;
727Increment a numerical string
12php
6j23g
URL url = new URL("https:
733HTTPS
9java
8l806
(require '[clojure.pprint:refer:all]) (defn probs [s] (let [freqs (frequencies s) sum (apply + (vals freqs))] (into {} (map (fn [[k v]] [k (/ v sum)]) freqs)))) (defn init-pq [weighted-items] (let [comp (proxy [java.util.Comparator] [] (compare [a b] (compare (:priority a) (:priority b)))) ...
736Huffman coding
6clojure
kirhs
fetch("https:
733HTTPS
10javascript
f4fdg
null
733HTTPS
11kotlin
w6wek
use strict; use warnings; use Imager; use constant pi => 3.14159265; sub hough { my($im) = shift; my($width) = shift || 460; my($height) = shift || 360; $height = 2 * int $height/2; $height = 2 * int $height/2; my($xsize, $ysize) = ($im->getwidth, $im->getheight); my $ht = Imager->n...
734Hough transform
2perl
gq54e
local request = require('http.request') local headers, stream = request.new_from_uri("https://sourceforge.net/"):go() local body = stream:get_body_as_string() local status = headers:get(':status') io.write(string.format('Status:%d\nBody:%s\n', status, body)
733HTTPS
1lua
xyxwz
package main import ( "fmt" "io/ioutil" "runtime" "strconv" "strings" "unsafe" ) func main() { fmt.Println(runtime.Version(), runtime.GOOS, runtime.GOARCH)
735Host introspection
0go
09xsk
from math import hypot, pi, cos, sin from PIL import Image def hough(im, ntx=460, mry=360): pim = im.load() nimx, mimy = im.size mry = int(mry/2)*2 him = Image.new(, (ntx, mry), 255) phim = him.load() rmax = hypot(nimx, mimy) dr = rmax / (mry/2) dth = pi / ntx for ...
734Hough transform
3python
rs4gq
package main import ( "fmt" "math/big" "rcu" "sort" ) var zero = new(big.Int) var one = big.NewInt(1) var two = big.NewInt(2) var three = big.NewInt(3) var four = big.NewInt(4) var five = big.NewInt(5) var six = big.NewInt(6)
738Home primes
0go
rs2gm
println "word size: ${System.getProperty('sun.arch.data.model')}" println "endianness: ${System.getProperty('sun.cpu.endian')}"
735Host introspection
7groovy
ezpal
import Data.Bits import ADNS.Endian main = do putStrLn $ "Word size: " ++ bitsize putStrLn $ "Endianness: " ++ show endian where bitsize = show $ bitSize (undefined :: Int)
735Host introspection
8haskell
cby94
package main import ( "fmt" "os" ) func main() { fmt.Println(os.Hostname()) }
737Hostname
0go
qy1xz
println InetAddress.localHost.hostName
737Hostname
7groovy
1fjp6
import Network.BSD main = do hostName <- getHostName putStrLn hostName
737Hostname
8haskell
mhtyf
use strict; use warnings; use ntheory 'factor'; for my $m (2..20, 65) { my (@steps, @factors) = $m; push @steps, join '_', @factors while (@factors = factor $steps[-1] =~ s/_//gr) > 1; my $step = $ if ($step >= 1) { print 'HP' . $_ . "($step) = " and --$step or last for @steps } else { p...
738Home primes
2perl
zgotb
import java.nio.ByteOrder; public class ShowByteOrder { public static void main(String[] args) {
735Host introspection
9java
zgdtq