forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouredev.py
50 lines (40 loc) · 1.22 KB
/
mouredev.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
import locale
def read_abacus_number(abacus: list) -> str:
if len(abacus) != 7:
raise Exception("Tamaño total incorrecto")
number = ""
for row in abacus:
if len(row) == 12 and "---" in row and row.replace("---", "") == "OOOOOOOOO":
number += str(len(row.split("---")[0]))
else:
raise Exception("Formato de fila incorrecto")
return "{:,}".format(int(number)).replace(",", ".")
abacus = ["O---OOOOOOOO",
"OOO---OOOOOO",
"---OOOOOOOOO",
"OO---OOOOOOO",
"OOOOOOO---OO",
"OOOOOOOOO---",
"---OOOOOOOOO"]
# abacus = ["OOOOOOOOO---",
# "OOOOOOOOO---",
# "OOOOOOOOO---",
# "OOOOOOOOO---",
# "OOOOOOOOO---",
# "OOOOOOOOO---",
# "OOOOOOOOO---"]
# abacus = ["---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO"]
# abacus = ["---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "O---OOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO",
# "---OOOOOOOOO"]
print(read_abacus_number(abacus))