-
Notifications
You must be signed in to change notification settings - Fork 10
/
coding.ch119.py
executable file
·53 lines (46 loc) · 1.22 KB
/
coding.ch119.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ringzer0
ascii_digits = '''\
xxx |x x |x x |x x | xxx |0|
xx |x x | x | x |xxxxx |1|
xxx |x x | xx | x |xxxxx |2|
xxx |x x | xx |x x | xxx |3|
x x|x x| xxxxx| x| x |4|
xxxxx |x | xxxx | x |xxxxx |5|
'''.splitlines()
ascii_table = {}
for form in ascii_digits:
if not '|' in form: continue
ascii_table[form[-2]] = form[:-3].split('|')
ascii_rows = len(ascii_table.values()[0])
def parse_ascii(data):
numbers = []
n, dln = 0, 0
for line in data.splitlines():
if 'x' not in line: continue
line = line.ljust(6, ' ')
if dln == 0: numbers.append([])
numbers[n].append(line)
if dln == 4:
dln = 0
n += 1
else:
dln += 1
numline = ''
for number in numbers:
for k, v in ascii_table.items():
if v == number:
numline += k
return numline
def ch119():
ch, s = 119, ringzer0.login()
sections = ringzer0.read_challenge(s, ch, clean=False)
title, msg = sections['title'], sections['message']
ringzer0.output('solving')
result = parse_ascii(msg)
ringzer0.output('solved', result)
response = ringzer0.submit_challenge(s, ch, result)
ringzer0.output('response', response)
if __name__ == '__main__':
ch119()