-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 12
More file actions
30 lines (26 loc) · 729 Bytes
/
Day 12
File metadata and controls
30 lines (26 loc) · 729 Bytes
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
# Day 12
def print_formatted(number):
w=len(bin(number)[2:])
for i in range(1,number+1):
print(str(i).rjust(w," "),str(oct(i)[2:]).rjust(w," "),str(hex(i)[2:]).upper().rjust(w," "),str(bin(i)[2:]).rjust(w," "))
if __name__ == '__main__':
n = int(input())
print_formatted(n)
17
1 1 1 1
2 2 2 10
3 3 3 11
4 4 4 100
5 5 5 101
6 6 6 110
7 7 7 111
8 10 8 1000
9 11 9 1001
10 12 A 1010
11 13 B 1011
12 14 C 1100
13 15 D 1101
14 16 E 1110
15 17 F 1111
16 20 10 10000
17 21 11 10001