Skip to content

Instantly share code, notes, and snippets.

@lab313ru
Created April 4, 2021 20:16
Show Gist options
  • Save lab313ru/0fa83b494cfd48d786348ea010fc6d9e to your computer and use it in GitHub Desktop.
Save lab313ru/0fa83b494cfd48d786348ea010fc6d9e to your computer and use it in GitHub Desktop.
Generates level passwords for Snow Bros, Sega
import random
import sys
rand_part = [
(19, 24),
(20, 26),
(25, 20),
(26, 24),
(24, 19),
(1, 16),
(6, 11),
(10, 12),
(19, 2),
(8, 13),
(13, 18),
(5, 15),
(15, 15),
(18, 4),
(23, 19),
(15, 9)
]
l_numbers = [
[ 0xFF, 0x01, 0x02, 0x03, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x06,
0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[ 0xFF, 0x06, 0x07, 0x08, 0xFF, 0x09, 0x0A, 0xFF, 0xFF, 0x01,
0x02, 0x03, 0x04, 0xFF, 0xFF, 0xFF, 0x05, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[ 0xFF, 0x08, 0x09, 0x0A, 0xFF, 0x01, 0x02, 0xFF, 0xFF, 0x03,
0x04, 0x05, 0x06, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[ 0xFF, 0x02, 0x03, 0x04, 0xFF, 0x05, 0x06, 0xFF, 0xFF, 0x07,
0x08, 0x09, 0x0A, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[ 0xFF, 0x02, 0x09, 0x05, 0xFF, 0x06, 0x01, 0xFF, 0xFF, 0x0A,
0x03, 0x08, 0x04, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[ 0xFF, 0xFF, 0x02, 0x05, 0xFF, 0x07, 0x08, 0xFF, 0xFF, 0x01,
0x03, 0x04, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x06,
0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF],
[ 0xFF, 0x05, 0x06, 0x01, 0xFF, 0x0A, 0xFF, 0xFF, 0xFF, 0x03,
0x08, 0xFF, 0x04, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF,
0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x09],
[ 0xFF, 0x02, 0x04, 0x06, 0xFF, 0x08, 0x0A, 0xFF, 0xFF, 0x01,
0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x09, 0xFF, 0x07],
]
ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def gen_password(level):
boss_index = (level // 10) + 1
sub_index = (level % 10) + 1
rnd = random.randint(0, 7)
a1 = l_numbers[rnd]
pswd = []
for i, a in enumerate(a1):
if a == sub_index:
pswd.append(i)
break
for i, a in enumerate(a1):
if a == boss_index:
pswd.append(i)
break
a2 = rand_part[rnd]
pswd.append(a2[0])
pswd.append(a2[1])
print([chr(0x40 + p) for p in pswd])
gen_password(int(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment