Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
254 lines (252 sloc) 7.82 KB
explanations = {
"" : "push 16",
"" : "push 32",
"" : "push 64",
"" : "push 128",
"" : "push 256",
"" : "push 512",
"" : "push 1024",
"" : "push 2048",
"" : "push 4096",
"" : "push 10",
"" : "push 100",
"" : "push 1000",
"" : "push 10000",
"" : "push 100000",
"" : "push 1000000",
"" : "push 10000000",
"" : "push 100000000",
"" : "is_prime(n)",
"§" : "get from array",
"" : "while true without popping",
"" : "while false without popping",
"" : "while true with pop",
"" : "while false with pop",
"" : "do while true without popping",
"" : "do while false without popping",
"" : "pop a, b, loop from a to b (inclusive)",
"" : "do while true with pop",
"" : "do while false with pop",
" " : "space character",
"!" : "gamma(n+1)",
"\"" : "string notation",
"#" : "pop a, b : push(a**b)",
"" : "pop a, b : push(b**a)",
"$" : "pop(a), push ord(a) or char(a)",
"%" : "modulo",
"'" : "push single character",
"(" : "decrement",
")" : "increment",
"*" : "pop a, b : push(a*b)",
"." : "pop a, b : push(b*a)",
"+" : "pop a, b : push(a+b)",
"-" : "pop a, b : push(a-b)",
"/" : "pop a, b : push(a/b), split strings",
"0" : "push 0",
"1" : "push 1",
"2" : "push 2",
"3" : "push 3",
"4" : "push 4",
"5" : "push 5",
"6" : "push 6",
"7" : "push 7",
"8" : "push 8",
"9" : "push 9",
";" : "discard TOS",
"<" : "pop(a, b), push(a<b)",
"=" : "pop(a, b), push(a==b)",
">" : "pop(a, b), push(a>b)",
"?" : "rot3",
"@" : "rrot3",
"A" : "push 11",
"B" : "push 12",
"C" : "push 13",
"D" : "push 14",
"E" : "push 15",
"F" : "push 17",
"G" : "push 18",
"H" : "push 19",
"I" : "push 20",
"J" : "push 21",
"K" : "push 22",
"L" : "push 23",
"M" : "push 24",
"N" : "push 25",
"O" : "push 26",
"P" : "push 27",
"Q" : "push 28",
"R" : "push 29",
"S" : "push 30",
"T" : "push 31",
"U" : "push 33",
"V" : "push 34",
"W" : "push 35",
"X" : "push 36",
"Y" : "push 37",
"Z" : "push 38",
"[" : "start array",
"\\" : "swap top elements",
"]" : "end array / wrap stack in array",
"^" : "zip top two elements on stack",
"_" : "duplicate TOS",
"`" : "duplicate the top two items",
"a" : "wrap in array",
"b" : "push -1",
"c" : "push -2",
"d" : "push -3",
"e" : "push e (2.71828...)",
"f" : "pop a, push fibonacci(a)",
"g" : "pop a, (b), pop operator from code, filter",
"h" : "length of array/string without popping",
"i" : "convert to integer (implicit map)",
"j" : "read float from input",
"k" : "read integer from input",
"l" : "read string from input",
"m" : "explicit map",
"n" : "newline char, or map array with newlines",
"o" : "print TOS without popping",
"p" : "print with newline",
"q" : "print without newline",
"r" : "range(0, n)",
"s" : "sort(array)",
"t" : "unix timestamp as integer milliseconds",
"u" : "join with separator",
"v" : "random integer in [-2**31, 2**31-1]",
"w" : "random integer in range, random item from list",
"x" : "reverse int/array/string",
"y" : "join array without separator to string or number",
"z" : "reverse sort(array)",
"{" : "start block or arbitrary length",
"}" : "end block",
"~" : "evaluate string, dump array, negate integer",
"" : "asterisk character (for challenges where a printable character is needed)",
"Ç" : "inverted filter",
"ü" : "ceiling with implicit map",
"â" : "convert to binary",
"ä" : "convert from binary",
"à" : "convert to binary string",
"å" : "convert from binary string",
"ç" : "implicit faulty filter",
"ê" : "read entire input as int array",
"ë" : "read entire input as float array",
"è" : "read entire input as string array",
"ï" : "index of current loop, or length of last loop",
"î" : "index of current loop (1-based)",
"ì" : "get loop value in foreach loop",
"Ä" : "start block of length 1",
"Å" : "start block of length 2",
"É" : "start block of length 3",
"æ" : "start block of length 4",
"Æ" : "start block of length 5",
"ô" : "start block of length 6",
"ö" : "start block of length 7",
"ò" : "start block of length 8",
"û" : "start string of length 2",
"ù" : "start string of length 3",
"ÿ" : "start string of length 4",
"¢" : "convert to/from hexadecimal",
"£" : "length of array/string with pop",
"¥" : "modulo 2",
"ƒ" : "random float in range [0,1]",
"á" : "sort by comparator",
"í" : "get total number of iterations of for loop",
"ó" : "pop(a), push(2**a)",
"ú" : "pop(a), push(10**a)",
"ñ" : "pop(a), push palindromize(a) string/list/number",
"Ñ" : "check if palindrome",
"ª" : "push [1]",
"º" : "push [0]",
"¿" : "if/else (uses one of the next two characters/blocks in the code)",
"" : "rotate entire stack",
"¬" : "rotate entire stack in reverse",
"½" : "pop a : push(a//2 if int else a/2)",
"¼" : "pop a : push(a//4 if int else a/4)",
"¡" : "push a, b, push a != b",
"«" : "end compressed string (etaoinsrdluczbfp)",
"»" : "end compressed string (gwymvkxjqh ?*#.,)",
"" : "convert to string (implicit map)",
"" : "split to list of chars/digits",
"" : "get average of list",
"" : "get differences of list",
"" : "pop from right of string/array",
"" : "discard from right of string/array",
"" : "start compressed string of length 2 (etaoinsrdluczbfp)",
"" : "start compressed string of length 3 (etaoinsrdluczbfp)",
"" : "start compressed string of length 4 (etaoinsrdluczbfp)",
"" : "start compressed string of length 2 (gwymvkxjqh ?*#.,)",
"" : "start compressed string of length 3 (gwymvkxjqh ?*#.,)",
"" : "start compressed string of length 4 (gwymvkxjqh ?*#.,)",
"" : "else without if",
"" : "if without else",
"" : "push TOS-1 without popping",
"" : "push TOS+1 without popping",
"" : "check if equal to 1",
"" : "check if equal to 0",
"" : "pop from left of string/array",
"" : "flatten array",
"" : "duplicate second item from top and push to top",
"" : "discard from left of string/array",
"" : "push 60",
"" : "push 3600",
"" : "push 86400",
"" : "fetch single dictionary word (top 256)",
"" : "fetch single dictionary word (all)",
"" : "pop a, b, push b/a",
"" : "pad list elements to equal length",
"" : "pop a, b, a.contains(b)",
"" : "closest power of two above",
"" : "range(-n, n+1)",
"" : "closest power of two below",
"" : "maximum of two elements, max of list, maximum by filter",
"" : "discard everything in stack",
"" : "range(1,n+1)",
"" : "minimum of two elements, min of list, minimum by filter",
"" : "left-rotate bits in int, list/str",
"" : "right-rotate bits in int, list, str",
"" : "convert to boolean",
"" : "convert to inverted boolean",
"" : "lowercase alphabet as string",
"" : "prepend to start of list",
"" : "append to end of list",
"" : "unique elements of string/list",
"α" : "wrap last two elements in array",
"ß" : "wrap last three elements in array",
"Γ" : "wrap last four elements in array",
"π" : "pi (3.14159...)",
"Σ" : "sum(list), digit sum(int)",
"σ" : "remove leading zeroes",
"µ" : "swap array/string items",
"τ" : "tau (2*pi)",
"Φ" : "increment array/string item",
"Θ" : "decrement array/string item",
"Ω" : "center string/int",
"δ" : "capitalize string",
"" : "pop a, push 2*a",
"φ" : "golden ratio (1.618...)",
"ε" : "reduce list with operator",
"±" : "absolute value",
"" : "greater or equal",
"" : "lesser or equal",
"" : "increment twice",
"" : "decrement twice",
"÷" : "is divisible",
"°" : "is perfect square",
"" : "pop a : push 1/a (implicit map)",
"" : "triplicate TOS",
"·" : "quadruplicate TOS",
"" : "pop a : push(sqrt(a)), split string to list",
"" : "pop a : push(a*a*a)",
"²" : "pop a : push(a*a)",
"" : "cartesian product with itself for lists, next collatz item for numbers",
" " : "discard everything but TOS"
}
def create_explanation(code):
l = len(code)
print('## Explanation\n')
for i, c in enumerate(code):
if c in explanations:
explained = explanations[c]
else:
explained = "not implemented yet"
row = (4+i)*" " + c + (l-i+2)*" " + explained
print(row)
You can’t perform that action at this time.