-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_numbers.py
85 lines (66 loc) · 2.07 KB
/
convert_numbers.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# convert score and time's font
# method_1
# input e.g. [["50", "3:15"],["50", "4:15"], ["40", "3:15"], ["30", "3:15"]]
import arcade
input_final = [["50", "3:15"],["50", "4:15"], ["40", "3:15"], ["30", "3:15"]]
input = ["50", "3:15"]
Score = "6580"
Time = "3:15"
# 先做一行
def slice_digit(list):
l = []
for digit in list:
if digit == ":":
digit = "hg"
l.append(digit)
return l
scores = []
times = []
for i in input_final:
scores.append(slice_digit(i[0]))
times.append(slice_digit(i[1]))
print(scores)
print(times)
SCREEN_WIDTH = 500
SCREEN_HEIGHT = 500
SCREEN_TITLE = "Drawing Text Example"
class MyGame(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
arcade.set_background_color(arcade.color.WHITE)
def on_draw(self):
"""
Render the screen.
"""
arcade.start_render()
for i in range(len(scores)):
for j in range(len(scores[i])):
arcade.draw_texture_rectangle(100 + j * 20, 400 - i*40, 20, 24,
arcade.load_texture("number/n_" + str(scores[i][j]) + ".png"))
for i in range(len(times)):
for j in range(len(times[i])):
arcade.draw_texture_rectangle(300 + j * 20, 400 - i * 40, 20, 24,
arcade.load_texture("number/n_" + str(times[i][j]) + ".png"))
def main():
MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
arcade.run()
from typing import List
def insertion_stack(nums: List[int]) -> List[int]:
""" A helper function that sort the data in an ascending order
Args:
nums: The original data
Returns:
a sorted list in ascending order
"""
left = []
right = []
for num in nums:
while left and left[-1] > num:
right.append(left.pop())
left.append(num)
while right:
left.append(right.pop())
return left
print(insertion_stack([5, 3, 4, 2, 1]))
# if __name__ == "__main__":
# main()