Skip to content

Instantly share code, notes, and snippets.

@ygabo
Last active December 20, 2015 20:49
Show Gist options
  • Save ygabo/6193064 to your computer and use it in GitHub Desktop.
Save ygabo/6193064 to your computer and use it in GitHub Desktop.
1, 6, f, 1c, 2d, 42, 5b, 78, 99 What is the first term of this hex sequence that is at least 9 digits and composed only of letters (a-f)?
#x = ['1', '6', 'f', '1c', '2d', '42', '5b', '78', '99']
#x = [ int(i,16) for i in x ]
#for i in x:
# print hex(i)
#print x
#for i in range(1, len(x)):
# print x[i]-x[i-1]
def lessthanf(x):
for i in x:
if i.lower() > 'f':
return False
return True
offset = 33
current = 153
current_hex = ""
while True:
offset += 4
current += offset
# print hex(current)
current_hex = hex(current)[2:]
if current_hex.isalpha() and len(current_hex) >= 9 and lessthanf(current_hex):
print current_hex
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment