Skip to content

Instantly share code, notes, and snippets.

@bbayles
Created November 23, 2025 20:16
Show Gist options
  • Select an option

  • Save bbayles/5876326dc762b016af0e122c0334208b to your computer and use it in GitHub Desktop.

Select an option

Save bbayles/5876326dc762b016af0e122c0334208b to your computer and use it in GitHub Desktop.
The Weakest Link (PlayStation) - passcode generator
Character Round Start Moves
Angela 2 Ruth (6, 2) ← ← ↑ ← ← ← ↓ ↑
Angela 3 Barry (1, 3) ↑ → ↓ ← ↑ ↑ → ←
Angela 4 Steve (3, 1) ← ← ↓ → ↑ ← ↓ ↑
Karen 2 Gary (4, 1) ↓ → ↑ ← ← ← ↓ ↑
Karen 3 Frank (1, 2) ↑ → ↓ ← ↑ → → ←
Karen 4 Gary (4, 1) ↓ ↓ ← ↑ ↑ ← ↓ ↑
Steve 2 Cindy (2, 2) ← ↓ → → ↑ ↑ ← →
Steve 3 Tim (7, 3) ↑ ↑ ← ← ← ← ← →
Steve 4 Rose (3, 3) ← ← ↑ ↑ → → ↓ ↑
Gary 2 William (8, 3) ← ← ↑ ↑ ← ← ← →
Gary 3 Karen (2, 1) → ↓ ↓ → ↑ ↑ → ←
Gary 4 Gary (4, 1) ↓ ← ↓ → ↑ ↑ ← →
Nick 2 Cindy (2, 2) ↓ → → ↑ ↑ → ↓ ↑
Nick 3 Mary (8, 2) ↓ ← ← ↑ ↑ ← ← →
Nick 4 Ruth (6, 2) ↓ → ↑ ← ↑ ← ← →
Tony 2 Evelyn (7, 2) → ↓ ← ↑ ← ↑ ← →
Tony 3 Amber (6, 3) → → ↑ ↑ ← ← ↓ ↑
Tony 4 Amber (6, 3) ↑ → → ↑ ← ← ← →
Allen 2 Sarah (5, 3) ↑ → → → ↑ ← ← →
Allen 3 Samantha (4, 2) ↓ → ↑ → ↑ → ↓ ↑
Allen 4 Ruth (6, 2) → → ↓ ← ↑ ↑ ← →
Jenny 2 Jojo (5, 2) ← ↑ → → → → ↓ ↑
Jenny 3 Tony (6, 1) ↓ → ↓ → ↑ ↑ ← →
Jenny 4 Jules (4, 3) → → → → ↑ ↑ ← →
Frank 2 Frank (1, 2) ↑ → → ↓ ← ← ↓ ↑
Frank 3 Eddie (3, 2) → ↓ ← ← ← ↑ ↑ ↓
Frank 4 Ravi (2, 3) ↑ → ↑ ← ← ↓ → ←
Cindy 2 Cindy (2, 2) ↓ ← ↑ ↑ → ↓ ↓ ↑
Cindy 3 Ruth (6, 2) ← ← ↓ ← ← ↑ ← →
Cindy 4 Rose (3, 3) → ↑ ↑ ← ← ↓ ↓ ↑
Eddie 2 Gary (4, 1) ↓ ↓ → ↑ ← ← ↓ ↑
Eddie 3 Ravi (2, 3) ← ↑ → ↓ → ↑ ← →
Eddie 4 Jules (4, 3) → ↑ ← ↓ ← ↑ ↑ ↓
Samantha 2 Mary (8, 2) ↓ ← ← ← ↑ ← ↓ ↑
Samantha 3 Cindy (2, 2) ↑ ← ↓ → → → → ←
Samantha 4 Angela (1, 1) ↓ ↓ → → ↑ → ↓ ↑
Jojo 2 William (8, 3) ← ↑ ← ↓ ← ↑ ← →
Jojo 3 Frank (1, 2) ↓ → → → → ↑ ↑ ↓
Jojo 4 Eddie (3, 2) ↓ → → → ↑ ← ↑ ↓
Ruth 2 Barry (1, 3) → → → → → ↑ ↑ ↓
Ruth 3 Mary (8, 2) ← ↓ → ↑ ← ← ↑ ↓
Ruth 4 Nick (5, 1) → ↓ ← ↓ → ↑ ← →
Evelyn 2 Eddie (3, 2) → ↓ → → → ↑ ↑ ↓
Evelyn 3 Eddie (3, 2) → ↑ → → → ↓ ↓ ↑
Evelyn 4 Amber (6, 3) → → ↑ ↑ ← ↓ ← →
Mary 2 Sarah (5, 3) ↑ → ↓ → ↑ → ↓ ↑
Mary 3 Samantha (4, 2) → ↓ → → ↑ → ↑ ↓
Mary 4 Tim (7, 3) ↑ → ↑ ← ↓ → ↑ ↓
Barry 2 Nick (5, 1) ← ← ← ↓ ← ↓ → ←
Barry 3 Rose (3, 3) ← ↑ ↑ ← ↓ ↓ → ←
Barry 4 Tim (7, 3) ← ← ← ← ← ← ↑ ↓
Ravi 2 Eddie (3, 2) ↓ ← ↑ ← ↓ → ↑ ↓
Ravi 3 Jojo (5, 2) → ↓ ← ← ← ← ← →
Ravi 4 Tony (6, 1) ← ← ← ↓ ↓ ← ↑ ↓
Rose 2 Samantha (4, 2) ↓ → ↑ ← ← ↓ ← →
Rose 3 Cindy (2, 2) ↑ ← ↓ ↓ → → ↑ ↓
Rose 4 Cindy (2, 2) ↓ ← ↑ → → ↓ → ←
Jules 2 Tony (6, 1) ↓ ← ↑ ← ↓ ↓ ← →
Jules 3 Amber (6, 3) ← ↑ → ↓ ← ← ↑ ↓
Jules 4 Karen (2, 1) ← ↓ ↓ → → → ↑ ↓
Sarah 2 Barry (1, 3) → ↑ → → → ↓ ← →
Sarah 3 Sarah (5, 3) ↑ → ↑ ← ↓ ↓ ← →
Sarah 4 Tim (7, 3) ↑ → ↓ ← ← ← ↑ ↓
Amber 2 Evelyn (7, 2) → ↑ ← ↓ ↓ ← ↑ ↓
Amber 3 Amber (6, 3) ← ↑ ↑ → ↓ ↓ → ←
Amber 4 Evelyn (7, 2) ↓ → ↑ ← ← ↓ ← →
Tim 2 Ruth (6, 2) → ↓ → ↑ ← ↓ → ←
Tim 3 Samantha (4, 2) → → → → ↓ ← ← →
Tim 4 Mary (8, 2) ↑ ← ↓ ← ↓ → → ←
William 2 Gary (4, 1) → ↓ ↓ → → → ↑ ↓
William 3 Jojo (5, 2) → → ↑ → ↓ ↓ ← →
William 4 Jojo (5, 2) ↑ → → → ↓ ↓ ← →
import struct
# Sequences the game is looking for
TARGET_DATA = b"\x8e\x54\x14\x00\xd1\xc1\x06\x00\x83\xe4\x14\x00\x84\x54\x0e\x00\xc9\xc7\x06\x00\x84\x04\x0b\x00\x6a\xe1\x13\x00\x77\x55\x01\x00\x93\x1e\x14\x00\x78\x15\x14\x00\xc2\xe1\x1a\x00\x64\xe1\x0c\x00\x8a\x86\x0f\x00\x70\x05\x0d\x00\x6e\x45\x0e\x00\x6f\x11\x1b\x00\x96\x14\x1e\x00\x76\x95\x07\x00\x75\xe5\x07\x00\x8c\x66\x0e\x00\x6e\xc1\x1e\x00\x8d\xfe\x11\x00\x66\xe1\x0e\x00\x74\xe1\x1f\x00\x89\xb4\x07\x00\x2b\x50\x1b\x00\xd2\x53\x06\x00\x8a\x1a\x0c\x00\x6e\xd1\x14\x00\x93\x52\x18\x00\x84\x94\x0b\x00\x72\xb9\x11\x00\x34\x30\x19\x00\x90\x44\x0d\x00\xca\xff\x04\x00\x81\xe6\x0b\x00\x78\x31\x11\x00\x29\xf8\x0f\x00\x2b\xe4\x0f\x00\x31\xf8\x1f\x00\x30\x94\x13\x00\x65\x39\x1b\x00\x2b\xf8\x1b\x00\x8b\xfa\x19\x00\x76\x13\x1e\x00\x95\xe6\x06\x00\x2c\xe6\x1b\x00\x37\x4e\x06\x00\xc5\x33\x15\x00\xd3\x4b\x10\x00\x37\x54\x15\x00\x2b\x4e\x0c\x00\x6d\x55\x1b\x00\x26\x2c\x15\x00\x6c\x53\x0e\x00\x2a\xbe\x04\x00\xca\x7b\x0c\x00\x66\x4b\x0c\x00\x36\xb4\x11\x00\x22\xfe\x12\x00\x71\xfb\x19\x00\x75\x4b\x06\x00\x37\xd4\x06\x00\x2f\x2c\x19\x00\xd6\x6b\x10\x00\x6f\x53\x0e\x00\xce\x93\x1b\x00\x6c\xed\x1f\x00\xd0\xcf\x04\x00\x24\xfe\x1a\x00\x6d\x6b\x1e\x00\x6d\xeb\x07\x00"
# The grid is 8x3
MOVE_MAP = [
"Up", # Position -8, +0 to accumulator
"Down", # Position +8, +1 to the accumulator
"Left", # Position -1, +2 to the accumulator
"Right", # Position +1, +3 to the accumulator
]
CONTESTANTS = [
"Angela",
"Karen",
"Steve",
"Gary",
"Nick",
"Tony",
"Allen",
"Jenny",
"Frank",
"Cindy",
"Eddie",
"Samantha",
"Jojo",
"Ruth",
"Evelyn",
"Mary",
"Barry",
"Ravi",
"Rose",
"Jules",
"Sarah",
"Amber",
"Tim",
"William",
]
def main():
# Unpack into 32-bit Little Endian integers
count = len(TARGET_DATA) // 4
targets = struct.unpack(f"<{count}I", TARGET_DATA)
print("Index", "Target character", "Target round", "Start position", "Moves", sep="\t")
for idx, target in enumerate(targets):
# Extract Start Position
raw_val = target - 1
start_pos = raw_val & 0b11111 # Lower 5 bits
start_y, start_x = divmod(start_pos, 8)
# Extract Path Vector
path_int = raw_val >> 5 # High bits
moves = []
# We need to extract 8 moves, 2 bits each.
# The first move is in the most significant bits.
for i in range(7, -1, -1):
bits = (path_int >> (i * 2)) & 0b11
moves.append(MOVE_MAP[bits])
target_pos, round_index = divmod(idx, 3)
print(
idx,
CONTESTANTS[target_pos],
round_index + 2,
CONTESTANTS[start_pos] + f" ({start_x + 1}, {start_y + 1})",
", ".join(moves),
sep="\t",
)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment