Bernd Zeimetz

wanted to play Lotto using the famous crypto key that was used a processing key for most HD-DVDs so far. But he ran into the problem that the key (which is usually represented in hex) uses 256 numbers, lotto only has 1-49.

Well, remember that in fact the key is a single number. So why process it as hex digits which is very artificial?

def lotto(x, y):
  if x <= 0: return y
  return lotto(x / 49, [int(x%49+1)] + y)

lotto(0x09F911029D74E35BD84156C5635688C0, [])

Here’s your list of lotto numbers:

[43, 25, 5, 27, 12, 13, 44, 45, 1, 6, 10, 1, 20, 30, 2, 44, 5, 20, 18, 11, 6, 34]

Base 49 representation (lower digits last, shifted by 1) of the key. If you need more digits, add leading 1s. (which is the same as adding leading zeros to a decimal number).