Skip to content

Instantly share code, notes, and snippets.

@markasoftware
Created April 20, 2017 17:17
Show Gist options
  • Save markasoftware/9360f27167a5948dd04a23bdcad9c194 to your computer and use it in GitHub Desktop.
Save markasoftware/9360f27167a5948dd04a23bdcad9c194 to your computer and use it in GitHub Desktop.
Old Clash of Code bot
#!/bin/bash
code_size () {
sed -r 's/\\n/T/g;s/\\\"/S/g;s/\\u[0-9]{4}/K/g' <<< $1 | wc -m;
}
# authenticate
bash check-block.bash
bash authenticate.bash
source user-info.conf
# backup stuff
foopyap=$(date +%s)
cp solutions "solutions$foopyap"
cp handles "handles$foopyap"
curl_opts="--socks5-hostname 127.0.0.1:9050 -s -b cookies -A \"$(bash gen-string.bash)\""
while read cur_handle
do
read cur_title
echo "processing $cur_title"
stuff=$(curl $curl_opts --data "[$cur_handle]" https://www.codingame.com/services/ClashOfCodeRemoteService/findClashReportInfoByHandle | jq '.success.players')
for i in $(seq 0 $[$(jq -r '. | length' <<< $stuff)-1])
do
old_code=$(grep -F -A2 "$cur_title" < solutions | awk 'NR==3')
echo "checking solution $i..."
cur_solution=$(jq --argjson i $i '.[$i]' <<< $stuff)
if [[ $(jq '.solutionShared' <<< $cur_solution) == "true" && $(jq '.score' <<< $cur_solution) == "100" ]]
then
echo "solution shared and 100%"
subid=$(jq '.submissionId' <<< $cur_solution)
blop=$(curl $curl_opts --data "[$user_id,$subid]" https://www.codingame.com/services/SolutionRemoteService/findSolution | jq '.success')
s_lang=$(jq '.programmingLanguageId' <<< $blop)
s_code=$(jq '.code' <<< $blop)
if [[ $blop == "null" || $s_lang == "null" || $s_code == "null" ]]
then
echo "ERROR: something was null"
echo "subid: $subid"
echo "blop: $blop"
continue;
fi
echo "current code size: $(code_size "$s_code")"
if [[ -z "$old_code" || $(code_size "$s_code") -lt $(code_size "$old_code") ]]
then
echo "is shortest"
if [[ -n $old_code ]]
then
old_ln=$(grep -n -F "$cur_title" < solutions | cut -d : -f 1)
awk "NR<$old_ln
NR>$[$old_ln+2]" < solutions > tmpsolutions
cp tmpsolutions solutions
rm -f tmpsolutions
fi
echo "$cur_title" >> solutions
echo "$s_lang" >> solutions
echo "$s_code" >> solutions
fi
fi
done
done < handles
#!/bin/bash
echo "authenticating..."
source user-info.conf
curl --socks5-hostname 127.0.0.1:9050 -s -c cookies -A "$(bash gen-string.bash)" --data "[\"$user_email\",\"$user_password\",true]" https://www.codingame.com/services/CodingamerRemoteService/loginSiteV2 > /dev/null
echo "authentication complete"
#!/bin/bash
source user-info.conf
curl --socks5-hostname 127.0.0.1:9050 -s -A "$(bash gen-string.bash)" https://www.codingame.com/services/ClashOfCodeRemoteService/playClash | grep -F 403
if [[ $? == 0 ]]
then
echo "Blocked! Restarting tor..."
systemctl restart tor
echo "Restarted, sleeping..."
sleep 2m
else
echo "Not blocked!"
fi
#!/bin/bash
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 | cut -c2-10
#!/bin/bash
bash analyze.bash >> analyze.log
truncate -s 0 handles
for i in $(seq $1)
do
echo "Starting loop $i out of $1" >> run.log
for i in $(seq 20)
do
sleep 15
bash win.bash >> win.log
done
sleep 15m
bash analyze.bash >> analyze.log
truncate -s 0 handles
done
"Parentheses"
"Python3"
"s = input()\nopened = 0\n\nfor c in s:\n if c == \"(\":\n opened += 1\n elif c == \")\":\n opened -= 1\n \n if opened < 0:\n break\n\nif opened == 0:\n print(\"true\")\nelse:\n print(\"false\")"
"A strange calendar"
"Javascript"
"[Y,M,D]=readline().split` `\nl=M==7||M==10?25:18\nif(++D==l){\nD=1\nif(++M==12){\nM=1\nif(++Y==0)Y=1}}\nprint(Y+` `+M+' '+D)"
"The Elvita Network"
"Python3"
"n = int(input())\nnames = [v for v in input().split()]\n\nbest = \"conspiracy\"\n\nfor name in names:\n if names.count(name) > len(names) / 2:\n best = name\n\nprint(best)"
"Distinct letters"
"Bash"
"fold -1|sort|uniq -i|wc -l"
"Alphabet"
"Bash"
"tr -dC a-zA-Z|wc -m"
"Material advantage in chess"
"Javascript"
"r=readline\nfor(r(i='');c=r();)i+=c\nprint(i.split``.reduce((a,b)=>a+({'P':1,'p':-1,'N':3,'n':-3,'B':3,'b':-3,'R':5,'r':-5,'Q':9,'q':-9}[b]||0),0)||'equal')"
"Nicely formatted table of numbers"
"Python3"
"h=int(input())\nw=int(input())\nc=0\nfor y in range(h):\n print(''.join([str(x).rjust(len(str(h*w-1))+1) for x in range(c,c+w)]))\n c+=w"
"Reshape String"
"Bash"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nread sentence\nread col\n\n# Write an action using echo\n# To debug: echo \"Debug messages...\" >&2\n\nfold -$col <<< `echo $sentence | tr -d ' '`"
"Parallel Lines"
"C++"
"#include <iostream>\n#include <string>\n#include <vector>\n#include <algorithm>\n\nusing namespace std;\n\n\nint main()\n{\n int width;\n int height;\n cin >> width >> height; cin.ignore();\n vector<string> t;\n for (int i = 0; i < height; i++) {\n string buf;\n getline(cin, buf);\n t.push_back(buf);\n }\n \n int h = 0, v = 0;\n bool b = true;\n for(int y = 0; y < t.size(); ++y){\n for(int x = 0; x < t[y].size(); ++x){\n if(t[y][x] == '-'){\n h++;\n if(x+1 < width && t[y][x+1] != '-')\n b = false;\n\n }\n if(t[y][x] == '|'){\n v++;\n if(y+1 < height && t[y+1][x] != '|')\n b = false;\n }\n \n } \n }\n\n cout << ((h/2 == width || v/2 == height) && b ? \"VALID\" : \"INVALID\") << endl; \n}"
"Remove duplicates"
"Bash"
"read\nawk '{if(a[$1])next;else{print$1;a[$1]=1}}'"
"Average character"
"Python3"
"s=input()\nprint(chr(int(sum(map(ord,s.upper()))/len(s))))"
"High and Low"
"C#"
"using é=System.Console;class s{static void Main(){var S=é.ReadLine();int a=S.Length,i=0;var s=\"\";for(;i<a;i++){if(i%2==a%2)s+=S[i].ToString().ToUpper();else s+=S[i].ToString().ToLower();}é.Write(s);}}"
"English programming language"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\ncommand = input()\nstart=0\nstop=0\nfor i in range(len(command)):\n if command[i] == \".\":\n stop = i\ntext=\"\"\nfor i in range(stop,0,-1):\n if command[i-4:i+1]==\"write\":\n break\n text+=command[i]\ntext=text[::-1]\nif \".\" not in command:\n print(\"Syntax Error\")\nelif \"times\" in command.split():\n \n for i in range(int(command.split()[command.split().index(\"times\")-1])):\n print(text[1:-1])\nelse:\n print(text[1:-1])\n"
"Objects 2D Map Reader"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar S = readline();\nvar N = parseInt(readline());\nvar map = [];\nfor (var i = 0; i < N; i++) {\n map.push(readline());\n}\n\nvar result = [];\nfor (var i = 0; i < S.length; i++) {\n var str = S[i] + \":\";\n for (var j = 0; j < N; j++) {\n for (var k = 0; k < map[j].length; k++)\n if (map[j][k] == S[i])\n str += \" \" + k + \" \" + j + \",\";\n }\n if (str !== S[i] + \":\")\n result.push(str.substr(0, str.length-1));\n}\nprint(result.join('\\n'));"
"Anagrams"
"Javascript"
"var S = readline().split(' ');\r\nprint(S[0].replace(/\\W+/g, '').toLowerCase().split(\"\").sort().join(\"\") === \r\nS[1].replace(/\\W+/g, '').toLowerCase().split(\"\").sort().join(\"\") ? 1 : 0)"
"Symmetrical substring"
"PHP"
"<?php\n$S = strtolower(stream_get_line(STDIN, 99 + 1, \"\\n\"));\n\n$length = strlen($S);\n$output = '';\n\nfor($i = 0; $i < floor($length/2); $i++) {\n if($S[$i] != $S[($length-1) - $i]) break;\n $output .= $S[$i]; \n}\n\necho ($output == '' ? 'Nothing' : $output) . \"\\n\";"
"IPv4"
"PHP"
"<?php\n\n$ipv4 = stream_get_line(STDIN, 15 + 1, \"\\n\");\n$splitIp = array_map(function($item) {\n return str_pad(decbin($item), 8, '0', STR_PAD_LEFT);\n}, explode('.', $ipv4));\n\n$long = implode('', $splitIp);\n\necho(bindec($long) . \"\\n\");"
"How many bits do we need?"
"Bash"
"awk 'NR>1{for(i=1;2^i++<=$1;);print i-1}'"
"Missing Digit"
"PHP"
"<?php\n\n$numbers = str_split(\"1234567890\");\n\nfscanf(STDIN, \"%d\", $n);\nfor ($i = 0; $i < $n; $i++)\n{\n fscanf(STDIN, \"%s\", $line);\n $line = str_split($line);\n $value = array_filter($numbers, function($item) use ($line) {\n return !in_array($item, $line);\n });\n \n echo implode('', $value) . PHP_EOL;\n}\n"
"Divisors of a number"
"Python3"
"n = int(input())\ns = '1'\nfor div in range(2,n+1):\n if n%div is 0:\n s += \" \" + str(div)\nprint(s)"
"Palindromes"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline());\nfor (var i = 0; i < N; i++) {\n var W = readline();\n print(W.split``.reverse().join``==W)\n}\n\n"
"Squares between two numbers"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar a = parseInt(readline());\nvar b = parseInt(readline());\nt=0\nk=Math.max(a,b)\nz=Math.min(a,b)\nfor(i=k;i>=z;--i)if(Math.sqrt(i)%1==0)t++\nprint(t)"
"Bouncy Numbers"
"Python3"
"n=input()\nc=sorted\nprint(str(n!=''.join(c(n))and n!=''.join(c(n))[::-1]).lower())\n"
"XOR 'em all"
"Bash"
"read\necho $[`grep -o 1|wc -l`%2]"
"Print the pattern"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar k = parseInt(readline());\nb=''\nfor(i=1;i<=k;++i)b+=i.toString()\nfor(i=0;i<b.length;++i)print('+'.repeat(i)+b.slice(0,b.length-i))"
"Closest point to origin"
"PHP"
"<?php\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n$closest = '';\n$shortest = 999999999;\n\nfscanf(STDIN, \"%d\",$N);\nfor ($i = 0; $i < $N; $i++)\n{\n fscanf(STDIN, \"%d %d\", $x, $y);\n $length = sqrt(($x*$x) + ($y*$y));\n \n if($length < $shortest) {\n $shortest = $length;\n $closest = \"$x $y\";\n }\n}\n\n// Write an action using echo(). DON'T FORGET THE TRAILING \\n\n// To debug (equivalent to var_dump): error_log(var_export($var, true));\n\necho(\"$closest\\n\");\n?>"
"GCD"
"Python"
"import fractions\na,b=[int(i)for i in raw_input().split()]\nprint fractions.gcd(a,b)\n\n \n"
"Muffins! CodeBoy Saga-1"
"PHP"
"<?php\n\nfscanf(STDIN, \"%d %d %d %d\", $n, $m, $r, $t);\n\n$M = $m - ($r * $t);\n\necho ($M >= $n ? \"\" : \"NOT \") . \"HAPPY\\n\";"
"Bus routes"
"Bash"
"read a\nawk \"NR>1{t+=\\$1}END{k=t/$a;print FNR*(k%1?int(k+1):k)}\""
"Biggest number, level 1"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline());\nvar inputs = readline().split(' ');\nprint(parseInt(inputs.sort((a,b)=>b-a).join``))"
"Lowest number"
"Bash"
"tr 5-9 43210"
"Zero Strike"
"Bash"
"grep -oP 0+|wc -L"
"Dentist"
"Bash"
"read\ntr 0 -"
"Histogram"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = int(input())\nl = [0 for i in range(10)]\nfor i in input().split():\n k = int(i)\n l[k] += 1\n\nfor i in range(1,10):\n print(str(i) + ':' + '*'*l[i])"
"Fibonacci"
"C++"
"#include <iostream>\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n int n, t1 = 0, t2 = 1, nextTerm = 0;\r\n\r\n\r\n cin >> n;\r\n\r\n \r\n \r\n for (int i = 1; i <= n; ++i)\r\n {\r\n \r\n if(i == 1)\r\n {\r\n if(i+1>n)\r\n cout <<t1;\r\n else\r\n cout<<t1<<\" \";\r\n continue;\r\n }\r\n if(i == 2)\r\n {\r\n if(i+1>n)\r\n cout <<t2;\r\n else\r\n cout<<t2<<\" \";\r\n continue;\r\n }\r\n nextTerm = t1 + t2;\r\n t1 = t2;\r\n t2 = nextTerm;\r\n if(i+1>n)\r\n cout << nextTerm;\r\n else\r\n cout<<nextTerm<<\" \";\r\n }\r\n return 0;\r\n}"
"Reverse sort"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = int(input())\nx = []\nfor i in range(n):\n x += [int(input())]\n \n\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n\nprint(*sorted(x)[::-1])\n"
"stretchy animals"
"Python3"
"d = dict()\nx = input()\ns = \"\"\nfor l in x:\n d[l] = d.get(l, 0) + 1\n s += l*d[l]\nprint(s)\n"
"Range sum"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = int(input())\nx = []\nfor i in input().split():\n x += [int(i)]\nm = int(input())\nfor i in range(m):\n s, e = [int(j) for j in input().split()]\n print(sum(x[s:e+1]))\n\n\n"
"Outer Ring"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline()), count = 0;\nif(N == 1){\n count = readline();\n}else{\nfor (var i = 0; i < N; i++) {\n var l = readline().split(' ');\n if(i == 0 || i == N-1){\n count += l.reduce((a,b)=>+a+(+b));\n }else{\n count += +l[0] + +l[N-1];\n }\n}\n}\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\n\nprint(count);"
"Rick Grimes"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar inputs = readline().split(' ');\nprintErr(inputs);\nvar B = parseInt(inputs[0]);\nvar W = parseInt(inputs[1]);\nvar X = parseInt(inputs[2]);\nvar Y = parseInt(inputs[3]);\nvar Z = parseInt(inputs[4]);\n\nvar lowB = Math.min(X, Z+Y), lowW = Math.min(Y, Z+X);\nprint(B*lowB + W*lowW);"
"Resistance - level 1"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar n = parseInt(readline());\nr=0\nfor (var i = 0; i < n; i++) {\n readline().replace(/\\|\\d+\\|/g,a=>r++);\n}\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\n\nprint(r);"
"Min prime de N"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\ndef primes(n):\n primfac = []\n d = 2\n while d*d <= n:\n while (n % d) == 0:\n primfac.append(d) # supposing you want multiple factors repeated\n n //= d\n d += 1\n if n > 1:\n primfac.append(n)\n return primfac\n\nn = int(input())\n\nif n is 0 or n is 1: \n print(\"NONE\")\nelse:\n print(primes(n)[0])"
"Most frequent letter"
"C++"
"#include<bits/stdc++.h>\nusing namespace std;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\nint main()\n{\n string words;\n getline(cin, words);\n char x[30];\n memset(x,0,sizeof(x));\n for(int i=0; i<words.length(); i++){\n if(words[i]>='a') x[words[i]-'a']++;\n }\n int tmp=0;\n for(int i=0; i<30; i++){\n if(tmp<x[i]) tmp=x[i];\n }\n cout << tmp << endl;\n}"
"XOR"
"Java"
"import java.util.*;\nimport java.io.*;\nimport java.math.*;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\nclass Solution {\n\n public static void main(String args[]) {\n Scanner in = new Scanner(System.in);\n String n1 = in.next();\n String n2 = in.next();\n String result = \"\";\n for(int i = 0; i < n1.length(); i++) {\n result += ((n1.charAt(i)) ^ (n2.charAt(i)));\n }\n\n // Write an action using System.out.println()\n // To debug: System.err.println(\"Debug messages...\");\n\n System.out.println(result);\n }\n}"
"Combination of Progression"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nl = int(input())\nm = int(input())\nn = int(input())\n\na = []\nb = []\nfor i in range(n):\n a.append(l + m * i)\n q = m ** i\n if l % q == 0:\n b.append(l // q)\n\nprint(*a)\nprint(*b)"
"The Prevailing Element"
"Python3"
"c=int(input())\na=[int(input())for i in range(c)]\nn=max(a,key=a.count)\nprint(n if a.count(n)>c//2else'N')"
"Find the Largest Prime"
"Ruby"
"n = gets.to_i\nr = 0\nf = true\nn.times do\n m = gets.to_i\n f = true\n for j in 2...m\n if m % j == 0\n f = false\n break\n end\n end\n if f\n if m > r\n r = m\n end\n end\nend\np r"
"Striped words"
"Javascript"
"S=readline(a=0).toLowerCase().split(' ')\nc=\"aeiou\"\nfor(let s of S)for(i=1;i<s.length;i++)\n{b=c.indexOf(s[i]);d=c.indexOf(s[i-1]);if((b>=0&&d>=0)||b==d){a++;break}}\nprint(S.length-a);"
"Candle problem"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nc = int(input())\ne = int(input())\ntot = 0\nif e == 0:\n print(c)\n exit()\nelif e == 1:\n print('IMPOSSIBLE')\n exit()\n \nwhile c >= 1:\n tot += c\n c = c / e\ntot += c\nprint(int(tot))"
"Maximum 2^k divisor"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = int(input())\n\nx = 0\nm = x\nwhile 2 ** x <= n:\n if n % (2 ** x) == 0:\n m = x\n x += 1\n\nprint(2**m)"
"Maximum or minimum speed"
"Java"
"import java.util.*;\nimport java.io.*;\nimport java.math.*;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\nclass Solution {\n\n public static void main(String args[]) {\n Scanner in = new Scanner(System.in);\n int vStart = in.nextInt();\n int p = in.nextInt();\n float d = in.nextFloat();\n float last = 0;\n int V = vStart;\n do {\n last = V;\n V = (int)((V + p)*(1-d));\n } while(Math.abs(last - V) > 0.001);\n // Write an action using System.out.println()\n // To debug: System.err.println(\"Debug messages...\");\n\n System.out.println(V);\n }\n}"
"Clean city names"
"Java"
"import java.util.*;\nimport java.io.*;\nimport java.math.*;\n\n/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\nclass Solution {\n\n public static void main(String args[]) {\n Scanner in = new Scanner(System.in);\n int N = in.nextInt();\n in.nextLine();\n String[] c=new String[N];\n for (int i = 0; i < N; i++) {\n c[i] = in.nextLine();\n }\n int M = in.nextInt();\n in.nextLine();\n for (int i = 0; i < M; i++) {\n String uncleanedCityName = in.nextLine();\n for (int j = 0; j < N; j++) {\n String tmp=c[j].toLowerCase().replace(\" \",\"\");\n String tmp2=uncleanedCityName.toLowerCase().replace(\" \",\"\");\n if(tmp.equals(tmp2)){\n System.out.println(c[j]); \n }\n }\n }\n \n }\n}"
"Weak Prime"
"C++"
"#include <iostream>\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n\nusing namespace std;\n\nbool isPrime(int n){\n if(n < 2)\n return false;\n \n int sq = sqrt(n);\n for(int i = 2; i <= sq; ++i)\n if(n%i == 0)\n return false;\n \n return true;\n}\n\nint main()\n{\n int n;\n cin >> n; cin.ignore();\n\n bool w = false, b = false;\n int sW = 0, bW = 0;\n for(int i = n-1; i > 1; --i)\n if(isPrime(i)){\n sW = i;\n break;\n }\n \n for(int i = n+1; ; ++i)\n if(isPrime(i)){\n bW = i;\n break;\n }\n \n cerr << sW << \" \" << n << \" \" << bW << endl;\n if((sW + bW) /2 > n)\n w = true;\n \n if((sW + bW) / 2 == n)\n b = true;\n \n \n \n \n if(w)\n cout << \"WEAK\" << endl;\n if(b)\n cout << \"BALANCED\" << endl;\n if(!w && !b)\n cout << \"STRONG\" << endl;\n}"
"Lychrel number testing"
"Javascript"
"N=readline(),v=N,b=\"\";\nwhile(1){\n t=true;\n b=\"\";\n for(var i=0;i<N.length;i++){\n b+=N[N.length-i-1]\n if(N[i]!=N[N.length-i-1]){t=false}\n }\n if(t){\n print(v);break\n }\n else{\n N=(parseInt(b)+parseInt(N)).toString();\n v=v+\" \"+N;\n }\n}\n"
"Find the Key"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\ns = input()[::-1]\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\nt = 0\n\nfor i in range(1,len(s)):\n a = int(s[i])\n if i%2 : t+=(2*a)//10+(2*a)%10\n else : t+=a\nprint((10-t)%10)\n"
"Prime in factorial"
"Javascript"
"n=readline(c=0);p=readline(i=0)\nfor(;i++<=n;){a=i;while(a%p==0){a=a/p;c++}}\nprint(c)"
"Linear function 2"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar inputs = readline().split(' ');\nvar x1 = parseInt(inputs[0]);\nvar y1 = parseInt(inputs[1]);\nvar inputs = readline().split(' ');\nvar x2 = parseInt(inputs[0]);\nvar y2 = parseInt(inputs[1]);\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\nvar a = (y1-y2)/(x1-x2);\nvar b = y1-a*x1;\nprint(a+'*x'+(b>=0?'+':'')+b);"
"Primes"
"C"
"main(){int n,p,c,i,j;scanf(\"%d\",&n);for(i=2;i<n;i++){p=0;for(j=2;j<=sqrt(i);j++)if(i%j==0)p=1;if(!p)c++;}printf(\"%d\",c);}"
"Shadok counting"
"C++"
"#include<iostream>\nmain(){int N;std::cin>>N;std::string s[4]={\"GA\",\"BU\",\"ZO\",\"MEU\"},a;do a=s[N%4]+a;while((N/=4)>0);std::cout<<a;}"
"Prime Power Sequence Term"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nc_term = int(input())\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\ndef primes(n):\n primfac = []\n d = 2\n while True:\n if n%d==0:\n return d\n d = d + 1\n\np = primes(c_term)\n\nd = int(math.log(c_term) / math.log(p))\n\nprint(p ** (d + 1))\n"
"I just peel the stickers off!"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar chars = ['U', 'L', 'F', 'R', 'B', 'D'];\nvar lines = '';\n\nfor (var i = 0; i < 11; i++) {\n lines += readline();\n}\n\nsolvable = true;\nfor (var i in chars) {\n var c = chars[i];\n if (lines.split(c).length - 1 != 9) {\n solvable = false;\n }\n}\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\n\nprint(solvable? 'SOLVABLE' : 'UNSOLVABLE');"
"Numbers in boxes"
"Ruby"
"gets\nt=gets.split.map(&:to_i)\ngets\nb=gets.split.map(&:to_i)\nputs b.map{|x|\ni=1\nc=x\nwhile(t[x-1]!=c)\ni+=1\nx=t[x-1]\nend\ni\n}*' '\n"
"Inverse of opposite"
"PHP"
"<?$n=fgets(STDIN);$o=r(-$n);$i=$n?r(1/$n):\"error\";$r=$n?r(-1/$n):$i;echo(\"$o\\n$i\\n$r\");function r($n){if($n==$x=round($n,2))return$n;return\"$x...\";}"
"Radix Possibilities"
"Javascript"
"for(k=readline(i=1);i<16;)if(t=parseInt(k,++i))print(i,t)\n"
"String transformation"
"Javascript"
"R=readline,P=print,s=R(),t=R(),E=\"\",P(s);for(i=0;i<s.length;i++)c=s.charAt(i),d=t.charAt(i),p=!1,d!=c&&(p=!0,c=d),E+=c,p&&P(E+s.substring(i+1))"
"Hofstadter–Conway sequence"
"Ruby"
"a=[0,1,1];(3..k=gets.to_i).map{|x|a[x]=a[w=a[x-1]]+a[x-w]};$><<a[1,k]*' '"
"Distribution"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@x = gets.to_i\n@n = gets.to_i\nh=Hash.new\n@n.times do\n f, t, category = gets.split(\" \")\n f = f.to_i\n t = t.to_i\n h[(f..t)] = category\nend\n\nputs h.detect{|k,v| k === @x}.last"
"Sum of arithmetic progression"
"Python3"
"import sys\nimport math\n\nm, d, n = [int(i) for i in input().split()]\nanswer = 0\nfor i in range(n):\n answer += m+i*d\n\n\n\n\nprint(answer)\n"
"ASCII Decoder"
"Python3"
"s=input()\na=len(s)\nprint('ERROR'if a%3else''.join(chr(int(s[i:i+3]))for i in range(0,a,3)))"
"Prime number"
"Ruby"
"require 'prime'\nx = gets.to_i\nz=x+1\n\nz+=1 until z.prime?\n\n\n\nputs z"
"Tiles"
"Python3"
"def p(a,b):\n while b>0:\n r=a%b\n a,b=b,r\n return a*a\nn,m=map(int,input().split())\nprint((n*m)//p(n,m))"
"Last guess"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@n = gets.to_i\nk = []\n@n.times do\n a = gets.chomp\n k << a\nend\n\nr = (0..100).select{|x|\n k.all?{|prop|\n y,s = prop.split\n case s\n when ?+\n x.to_i > y.to_i\n when ?-\n x.to_i < y.to_i\n when ?=\n x.to_i == y.to_i\n end\n }\n}\n\nputs r.size == 1 ? r[0] : \"Impossible\""
"The Legend of the Odd Sevens"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline());\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\n\nprint(N%7==0&&N%2!=0);"
"Sum of vectors"
"Javascript"
"f=n=>readline().split` `\nfor([D,N]=f(a=[]),i=0;i<N;i++)for(p=f(j=0);j<D;i%2?a[j]-=x:a[j]?a[j]+=x:a[j]=x,j++)x=+p[j]\nprint(...a)"
"ASCII Charts"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nchart=[]\nhh = []\nn = int(input())\nfor i in range(n):\n chart.append(input())\nm = int(input())\nfor i in input().split():\n hh.append(int(i))\n\nfor k,line in enumerate(chart):\n for h in hh:\n line += '.' if n-k>h else '#'\n print(line)"
"Problem with Doors"
"Perl"
"print int<>**.5"
"Sum of Char Codes"
"Ruby"
"p gets.sum"
"Add space between each pair of letters"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nl = input()\np = \"\"\nfirst = True\nfor c in l:\n if c == \"\":\n first = True\n continue\n if not first and c.isalpha():\n p+=\" \"\n p+= c\n if c.isalpha():\n first = False\n else:\n first = True\n \nprint (p)\n"
"Win Rock Paper Scissors"
"Javascript"
"[o,u]=readline(k={'SCISSORS':'ROCK','PAPER':'SCISSORS','ROCK':'PAPER'}).split` `\nprint((n=k[u]&&k[o]?o==u||k[u]==o?o:k[u]:'CHEATER')+(k[n]?' '+k[n]:''))"
"The Bank"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = float(input())\nbills = [500, 200, 20, 10, 2, 1, 0.5]\ni=0\nout = \"\"\nwhile n != 0:\n if n < 0:\n print(\"IMPOSSIBLE\")\n exit()\n try:\n b = bills[i]\n except:\n print(\"IMPOSSIBLE\")\n exit()\n res = int(n // b)\n if res != 0:\n out += str(res) + \" x \" + str(b) + \", \"\n n = n % b\n i+= 1\nout=out[:-2]+\"€\"\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n\nprint(out)\n"
"Angles"
"Bash"
"awk '{print 180-$1-$2}'"
"Simple cypher"
"Bash"
"dd conv=swab"
"O Christmas Tree"
"Ruby"
"n=gets.to_i\nputs a=n.times.map{|i|?.*(n-i)+?**(2*i+1)+?.*(n-i)},a[0]"
"Square Squared"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar n = parseInt(readline());\nt=0\nfor(n--;n>0;--n)t+=n**2\nprint(t)"
"Double letter"
"Javascript"
"print(/(.)\\1/i.test(readline()))"
"Sum of squares"
"Bash"
"read\nbc<<<`sed 's/ /^2+/g'`^2"
"Happy Number"
"Javascript"
"f=(c,i)=>i>1000?' IS UNHAPPY':c==1?' IS HAPPY':f(c.toString().split``.map(c=>c**2).reduce((a,b)=>a+b,0),i+1)\nk=readline()\nprint(k+f(k,0))"
"Factorial"
"Bash"
"seq -s* `dd`|bc"
"Duration to minutes"
"Bash"
"bc<<<60*`tr : +`"
"Long story"
"Python3"
"print(min(int(input()),int(input())))"
"Odd Numbers"
"Bash"
"seq 1 2 `dd`"
"Mixed up"
"Javascript"
"var N = parseInt(readline());\nvar numbers = readline().split` `\nfor(i=1;i<numbers.length;i+=2){\n k=[numbers[i-1],numbers[i]].sort((a,b)=>a-b)\n numbers[i-1]=k[0]\n numbers[i]=k[1];\n}\nprint(...numbers)"
"Easy math"
"Bash"
"awk '{print$1-$2$1+$2}'"
"Awesome ball"
"Perl"
"print<>*64"
"FooBar"
"Python3"
"f,s=\"Foo\",\"Bar\"\n\nfor i in range(1,int(input())+1):r=[i%5,i%7];print(i if 0 not in r else(f+s if sum(r)<1 else(f if i%5<1 else s)))"
"Even numbers"
"Python3"
"for i in range(int(input())):print(str(int(input())%2==0).lower())"
"Construct a square"
"Python3"
"s=int(input())\nfor i in range(s):print(\"+\"*s)"
"Arithmetic Mean"
"Bash"
"read a\nbc<<<\"(`tr ' ' +`)/$a\""
"Addition"
"Bash"
"read\nbc<<<`tr '\n' +`"
"Collatz conjecture"
"Javascript"
"f=c=>c-1&&1+f(c%2?c*3+1:c/2)\nprint(f(readline()))"
"Cobweb digits"
"Python3"
"n=int(input())\nfor i in range(n):print(str(n)*(n-i))"
"Arithmetic sequence"
"Bash"
"awk '{for(;i<$1;)printf\" \"$2*i++}'|cut -c2-"
"Modulo 10"
"Bash"
"bc<<<`dd`%10"
"Repetition"
"Bash"
"read a\nawk \"{for(;i++<$a;)print\\$1}\""
"ROT13 cipher"
"PHP"
"<?php echo str_rot13(fgets(STDIN));"
"Atbash Cipher"
"Javascript"
"w=readline()\ns=\"\"\nfor(i=0;i<w.length;)s+=String.fromCharCode(219-w.charCodeAt(i++))\nprint(s)"
"Geometric sequence"
"Bash"
"read a b\nseq $a|sed -r \"s/[0-9]+/$b^(&-1)/g\"|bc|tr '\n' ' '|rev|cut -c2-|rev"
"#square"
"Python3"
"n=int(input())\nprint(\"#\"*n)\nif n>1:\n for i in range(n-2):print(\"#\"+\" \"*(n-2)+\"#\")\n print(\"#\"*n)"
"Partial Binary"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline());\nnum=[]\nfor (var i = 0; i < N; i++) {\n num[i] = parseInt(readline());\n}\n\n// Write an action using print()\n// To debug: printErr('Debug messages...');\nfor (var i = 0; i < N; i++) {\nprint(parseInt(num[i].toString(2).replace(1,0),2));\n}"
"Find the middle number"
"Bash"
"awk 'NR>1{print($1<$2?$2<$3?$2:$3:$3>$1?$1:$3)}'"
"Binary to Hex"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nt = input()\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n\nprint(hex(int(t[2:],2)))\n"
"Not quite sudoku"
"Python3"
"print(492-sum(map(ord,input())))"
"Shifty Strings"
"Python3"
"l=input()\nr=[l]\nfor t in range(len(l)-1,-1,-1):\n o=l[t:]+l[:t]\n r+=[o]\n if o==l:break\nprint(*r,sep='\\n')"
"Lowest Common Multiple"
"Javascript"
"gcd=(a,b)=>!b?a:gcd(b, a%b)\nvar N = parseInt(readline());\nvar inputs = readline().split(' ');\nc=0\nfor (var i = 0; i < N; i++) {\n var m = parseInt(inputs[i]);\n if(c==0){\n c=m\n }else{\n c= c*m/gcd(c,m)\n }\n \n}\nprint(c);"
"Lucky Tickets"
"Python3"
"for i in range(int(input())):k=[int(z)for z in input()];print('true'if sum(k[:3])==sum(k[3:])else 'false')"
"2D Pyramids"
"Haskell"
"import System.IO\nimport Control.Monad\n\nmain :: IO ()\nmain = do\n hSetBuffering stdout NoBuffering -- DO NOT REMOVE\n \n -- Auto-generated code below aims at helping you parse\n -- the standard input according to the problem statement.\n \n input_line <- getLine\n let n = read input_line :: Int\n (xs, _) = span (<= n) [sum [0 .. n] | n <- [0 ..]]\n x = last xs\n \n -- hPutStrLn stderr \"Debug messages...\"\n \n -- Write answer to stdout\n putStrLn (show (length xs - 1) ++ \" \" ++ show (n - x))\n return ()"
"Sum Of Powers"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar n = parseInt(readline());\nt=0\nfor(i=0;i<n;i++)t+=2**i\nprint(t)"
"Find the right angle"
"Python3"
"l=[]\nfor i in[0]*3:p,x,y=input().split();l+=[(p,int(x),int(y))]\nfor i in[-1,0,1]:\n a,X,Y=l[i-1];b,A,B=l[i+1];o,x,y=l[i]\n if(x-X)*(x-A)+(y-Y)*(y-B)==0:print(o);break\nelse:print('_')"
"Duration formatting"
"Python3"
"d=int(input())//1000\na=[]\nfor k in[60,60,24,9**9]:a+=[d%k];d//=k\nf=[]\nfor l in'dhms':o=a.pop();f+=[str(o)+l]*(o>0)\nif not f:f=[str(d)+'s']\nprint(*f)"
"Angle between vectors"
"Python3"
"a, b = [int(i) for i in input().split()]\n\n\nprint(min(abs(a%360-b%360),360-a%360+b%360,360-b%360+a%360))\n"
"ASCII conversion"
"Perl"
"<>;print chr for split/ /,<>"
"Run length encoding"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@s = gets.chomp\n\n# Write an action using puts\n# To debug: STDERR.puts \"Debug messages...\"\n\nputs @s.scan(/((.)\\2*)/).map(&:first).map{|x|x.size.to_s+x[0]}.join"
"24 to 12 Hours time conversion"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\ns=gets.to_i\nif s>12\n p s-12\nelse\n p s\nend"
"Increment until different"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@n = gets.to_i\n\n# Write an action using puts\n# To debug: STDERR.puts \"Debug messages...\"\n@c=@n\nwhile @n.to_s.chars & @c.to_s.chars != [] do\n @c += 1\nend\nputs @c"
"Even Digits"
"Ruby"
"s=gets.tr(\"13579\",\"\")\np s.sum-48*s.size"
"Parametric sequence"
"Perl"
"($a,$A,$b,$B,$r)=map split,<>;print$a++%10x$A,$b++%10x$B for 1..$r"
"Counting Nucleotides"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\ns = input()\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n\nprint(\" \".join(map(lambda e: str(s.count(e)), 'ACGT')))"
"Sum of the multiples of 3, 5 or 7"
"Javascript"
"N=+readline(),s=0;while(N--)!(N%3&&N%5&&N%7)&&(s+=N);print(s)"
"Bitcount"
"Python"
"input()\nwhile 1:print(bin(input()).count(\"1\"))\n"
"1337"
"Python3"
"h={'OLZEASGTBQ'[i]:str(i)for i in range(10)}\nprint(''.join(h[c.upper()]if c.upper()in h else c for c in input()))"
"rEVERSED cASE"
"Python3"
"print(input().swapcase())"
"Alphabet order"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n\n\n\n\nw = input()\nlast=ord(\"@\")\nfor l in w:\n if ord(l)<last:\n print(l)\n break\n last=ord(l)\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n"
"Title Case"
"Python3"
"print(input().title())"
"Midpoint"
"Python3"
"a, b = [int(i) for i in input().split()]\nc, d = [int(i) for i in input().split()]\na = a+c\nb = b+d\nif a % 2 != 0 and b % 2 !=0:\n print(round(a/2,1),round(b/2,1))\nelif a % 2 == 0 and b % 2 !=0:\n print(a//2,round(b/2,1))\nelif a % 2 != 0 and b % 2 ==0:\n print(round(a/2,1),b//2)\nelse:\n print(a//2,b//2)\n"
"Adventurers dueling"
"Javascript"
"var inputs = readline().split(' ');\nvar HP1 = parseInt(inputs[0]);\nvar D1 = parseInt(inputs[1]);\nvar inputs = readline().split(' ');\nvar HP2 = parseInt(inputs[0]);\nvar D2 = parseInt(inputs[1]);\nvar r = 0;\nwhile (HP1 > 0 && HP2 > 0) {\n var HP1 = HP1 - D2;\n var HP2 = HP2 - D1;\n var r = r + 1;\n}\nif (HP1 > HP2) {\n var w = 1;\n} else {\n var w = 2;\n}\nprint(w, r);"
"Leap year"
"Javascript"
"k=readline()\nprint(!(k%100?k%4:k%400))"
"Vowels in each word"
"Bash"
"grep -oP \\\\S+|tr -dc 'aoeuiAOEUI\n'|awk '{printf\" \"length}'|cut -c2-"
"Sum of Prime Factors"
"Python"
"n=input()\nf=[]\nd=2\nwhile n>1:\n while n%d==0:\n f.append(d)\n n/=d\n d=d+1\n if d*d>n:\n if n>1:f.append(n)\n break\nprint sum(f)"
"Semi-Ellipse"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@x0, @y0, @x, @y = gets.split(\" \").collect {|x| x.to_i}\n\n# Write an action using puts\n# To debug: STDERR.puts \"Debug messages...\"\n\np ((@x-@x0)*(@y-@y0)*0.785).abs.ceil"
"Reverse Words"
"Ruby"
"$><<gets.split.map(&:reverse)*\" \""
"Birds Language"
"Python3"
"print(''.join([i+'p'+i if i in 'aeiouAEIOU' else i for i in input()]))"
"Hexa Conversion"
"Ruby"
"# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\n@value_count = gets.to_i\ninputs = gets.split(\" \")\nfor i in 0..(@value_count-1)\n value = inputs[i]\n print value.to_i(16).chr\nend\n\n# Write an action using puts\n# To debug: STDERR.puts \"Debug messages...\"\n\n"
"Digital root"
"Python3"
"s=int(input())\nwhile len(str(s))!=1:\n L=[]\n for i in str(s):\n L.append(int(i))\n s=sum(L)\nprint(s)"
"Only one's"
"Javascript"
"print(!/0/.test((+readline()).toString(2)))"
"Reversed Sentence"
"Python3"
"import sys\nimport math\n\nprint(' '.join(reversed(input().split())))\n"
"Extract capitals"
"Bash"
"tr -dc A-Z"
"Linear function"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar inputs = readline().split(' ');\nvar a = parseInt(inputs[0]);\nvar b = parseInt(inputs[1]);\nvar n = parseInt(readline());\nfor (var i = 0; i < n; i++) {\n var x = parseInt(readline());\n print(a*x+b)\n}\n\n// Write an action using print()\n"
"Sorting"
"Python3"
"input()\nprint(*sorted(map(int,input().split())))"
"Pyramids"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar n = parseInt(readline());\nfor(i=1;i<=n;++i)print(n.toString().repeat(i))"
"Candies, warm up"
"Javascript"
"var inputs = readline().split(' ');\nvar N = parseInt(inputs[0]);\nvar K = parseInt(inputs[1]);\nvar a = [];\nwhile (N > 0) {\n if(N >= K) {\n a.push(K);\n } else {\n a.push(N);\n }\n N -= K\n}\nprint(a.join(\" \"))"
"Simon says"
"Python3"
"s = input()\ni = 0\nwhile s[i] != ':':\n i += 1\nl,r = s[:i].split(),s[i:]\no = \"...\"\nif l[0] == \"Simon\":\n for i in range(len(r)-5):\n if r[i:i+5] == \"write\":\n o = r[i+6:]\n break\nprint(o)\n"
"Modulo Sum"
"Python3"
"m=int(input());n=input();s=0\nfor i in input().split():s+=int(i)%m\nprint(s)"
"Caesar Box Cipher"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nm = input()\n\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\nl=int(len(m)**.5)\na=''\nfor i in range(l):\n for j in range(i,len(m),l):\n a+=m[j]\nprint(a)\n"
"NOT"
"Bash"
"tr 10 01"
"My Branch"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nn = int(input())\n# 1 - L, 2 - 1, 3-2, 4-3, 5-L, 6-1, 7-2, 8-3, 9-L, 10-1\n#LWWWLWWWL\nif (n%4 == 1):\n print(\"LOST\")\nelse:\n print((n-1)%4)\n# Write an action using print\n# To debug: print(\"Debug messages...\", file=sys.stderr)\n\n"
"Complementary DNA strand"
"Python3"
"a='ACGT'\nprint(''.join(a[3-a.index(i)] for i in input()))"
"Sum of the odds"
"Python"
"print input()**2"
"Logic Analayzer"
"Bash"
"echo $[`dd`**2*100]"
"CharCode Encoder"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar l = readline();\nprint(l.split``.map((c,i)=>String.fromCharCode(c.charCodeAt()+i)).join``)"
"Shift letters"
"Python"
"n,w=input(),raw_input()\nn%=len(w)\nprint w[n:]+w[:n]"
"MinusStarPlus"
"Bash"
"read a\nread b\nbc<<<$[a-b]$[a*b]$[a+b]"
"Even sum"
"Perl"
"$a=<>;print$a++*$a"
"OR"
"Python3"
"m,n= input().split()\nw='{0:0'+str(len(m))+'b}'\nm=int(m,2)\nn=int(n,2)\nprint(w.format(m|n))\n"
"Diagonal Words"
"Bash"
"read N\nfor((i=0;i<N;i++));do\nread l\nx+=${l:i:1}\ny+=${l:N-i-1:1}\ndone\necho $x $y"
"Facial composite"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\nhair, cheek, eye, nose, mouth, chin = input().split()\nprint(hair,hair,hair,hair,hair,sep='')\nprint(cheek,eye,' ',eye,cheek,sep='')\nprint(cheek,' ',nose,' ',cheek,sep='')\nprint(cheek,' ',mouth,' ',cheek,sep='')\nprint(chin.center(5,' ').rstrip())\n"
"Traveled Distance - Unit Conversion"
"Bash"
"read\nawk '{print$1*60*$2/100}'"
"HexaFun"
"Perl"
"print hex<>"
"Golf code"
"Python3"
"import sys\nimport math\n\n# Auto-generated code below aims at helping you parse\n# the standard input according to the problem statement.\n\na = sum(int(i)for i in input().split())\nb = sum(int(i)for i in input().split())\nprint(b-a)\n"
"ASCII Math"
"Bash"
"bc<<<`od -An -t uC|sed -r 's/\\S+/&%2*&+/g'`0"
"Word value"
"Python3"
"for a in input().split():\n print(sum([ord(b)for b in a]))"
"Hydrocarbons"
"Javascript"
"/**\n * Auto-generated code below aims at helping you parse\n * the standard input according to the problem statement.\n **/\n\nvar N = parseInt(readline());var a=0,b=0;\nfor (var i = 0; i < N; i++) {\n var l = readline();\n for (var j = 0; j < l.length; j++) {\n if(l.charAt(j)=='C')\n a++;\n else if(l.charAt(j)=='H')\n b++;}\n}\n\nif(a==1&&b==4)\nprint(\"methane\");\nelse if(a==2&&b==6)\nprint(\"ethane\");\nelse if(a==3&&b==8)\nprint(\"propane\");\nelse if(a==4&&b==10)\nprint(\"butane\");\nelse if(a==5&&b==12)\nprint(\"pentane\");\nelse\nprint(\"NONE\");"
"Keywords table"
"Javascript"
"r=readline\nfor(n=r(m=r(t=[]));n--;)t.push(r())\nr(r()).split` `.map(c=>print(t.slice((c-1)*m,c*m).join`\\n`))"
# you'd want to put user details here
userid=273612
user_email=boop@example.com
user_password=P455w0Rd
#!/bin/bash
source user-info.conf
bash check-block.bash
curl_opts="--socks5-hostname 127.0.0.1:9050 -s -b cookies -A \"$(bash gen-string.bash)\""
# join clash. Public handle will be surrounded with quotes
echo "joining clash..."
public_handle=$(curl $curl_opts --data "[$user_id,{\"SHORT\":true},null]" https://www.codingame.com/services/ClashOfCodeRemoteService/playClash | jq '.success.publicHandle')
if [[ $public_handle == "null" ]]
then
echo "WARNING: could not retrieve public handle"
exit
fi
echo $public_handle >> handles
echo $public_handle
# poll every 5 seconds for start
echo "polling for clash start..."
ide_handle="null"
while [[ $ide_handle == "null" ]]
do
sleep 5
ide_handle=$(curl $curl_opts --data "[$user_id, $public_handle]" https://www.codingame.com/services/ClashOfCodeRemoteService/startClashTestSession | jq '.success.handle')
done
# get detailed clash info
echo "getting detailed clash title..."
question_title=$(curl $curl_opts --data "[$ide_handle]" https://www.codingame.com/services/TestSessionRemoteService/startTestSession | jq '.success.currentQuestion.question.title')
echo $question_title >> handles
echo "$question_title"
# default submit data
submit_data="[$ide_handle,{\"code\":\"H\",\"programmingLanguageId\":\"Bash\"},null]"
# find lang and code if available
code_and_lang=$(grep -F -A2 "$question_title" < solutions)
p_lang=$(awk 'NR==2' <<< "$code_and_lang")
p_code=$(awk 'NR==3' <<< "$code_and_lang")
if [[ -z "$code_and_lang" ]]
then
echo "no solution found, submitting bullshit..."
else
echo "Solution found! Inserting..."
submit_data="[$ide_handle,{\"code\":$p_code,\"programmingLanguageId\":$p_lang},null]"
fi
# submit
echo "waiting for submit..."
echo "submitting..."
echo "$(curl $curl_opts --data "$submit_data" https://www.codingame.com/services/TestSessionRemoteService/submit)"
echo "completed successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment