Skip to content

Instantly share code, notes, and snippets.

@shelvacu
Created September 12, 2016 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shelvacu/c6da66d602eb6c9313898a69570cea1f to your computer and use it in GitHub Desktop.
Save shelvacu/c6da66d602eb6c9313898a69570cea1f to your computer and use it in GitHub Desktop.
DtHIqH18R0IqH13R1K0FbjH2=+K-4b)RtKJsmtdr1QJ-QJ
DtH Define method t with argument H
IqH18 If H is equal to 18
R0 Return 0 (implicitly ends If block)
IqH13 If H is equal to 13
R1 Return 1
K0 Set variable K to 0
Fb For every value in 'jH2', set variable b to that value and execute block
jH2 Convert H to base 2 as an array of integers
=+K Set K to K + '-4b'
-4b 4 minus b
) End for loop
RtK Return t(K). Implicitly ends function definition
J Set J equal to:
s The sum of all integers in:
m Map a set of values (second arg) using a lambda with parameter named d (first argument)
td lambda d: t(d)
r1Q A range from 1 to Q. Q is automatically set to stdin evaluated
J Implicitly print J
-QJ Implicitly print the result of subtracting J from Q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment