I hereby claim:
- I am thomasgassmann on github.
- I am thomasgassmann (https://keybase.io/thomasgassmann) on keybase.
- I have a public key ASDd0aQwdCYhnTTZ9o6_WdLpgU6FtYMapZ640BkzR--LNQo
To claim this, I am signing this object:
def fib(n): | |
if n <= 2: | |
return 1 | |
a = [1, 1, 1] | |
for i in range(3, n + 1): | |
a[i % 3] = a[(i - 1) % 3] + a[(i - 2) % 3] | |
return a[n % 3] | |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env bash | |
error_msg="Aborting commit. Your commit message does not match the regex. Please provide a format like: '#666 foo bar'" | |
msg="`cat $1`" | |
if [[ ! $msg =~ ^#[0-9]{3,9}(.|\n)* ]]; then | |
echo "$error_msg" >&2 | |
exit 1 | |
fi |
x = ['print("x =", x)', 'for m in x: print(m)'] | |
print("x =", x) | |
for m in x: print(m) |
from functools import reduce | |
from operator import xor | |
def missing_value(numbers): | |
return reduce(xor, numbers + list(range(len(numbers) + 1))) | |
if __name__ == '__main__': | |
# 4 | |
print(missing_value([0, 1, 2, 3, 5, 6, 7])) |
def sum(x, y): | |
if y == 0: | |
return x | |
sum_without_carry = x ^ y | |
carry = (x & y) << 1 | |
return sum(sum_without_carry, carry) |
import winreg | |
def get_registry_roots(hkey): | |
results = [] | |
try: | |
i = 0 | |
while True: | |
key = winreg.EnumKey(hkey, i) | |
i += 1 |
rules = { | |
3: 'Fizz', | |
5: 'Buzz' | |
} | |
for i in range(1, 1000): | |
output = [rules[key] if i % key == 0 else '' for key in rules] | |
output = ''.join(output) | |
print(output if output != '' else i) |