-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
74 lines (67 loc) · 1.56 KB
/
test.py
File metadata and controls
74 lines (67 loc) · 1.56 KB
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
__author__ = 'Moon'
import sys
class ListNode(object):
def __init__(self,x):
self.val = x
self.next = None
def generateLinkList(NodeList):
if len(NodeList) == 0:
return None
else:
list_nodes = map(lambda x:ListNode(x),NodeList)
for i in range(len(NodeList)-1):
list_nodes[i].next = list_nodes[i+1]
return list_nodes[0]
def testLinkList(head):
result = []
while head:
result.append(head.val)
head = head.next
return result
def numSquares(n):
"""
:type n: int
:rtype: int
"""
sqrt = 1
count = 0
sq_list = []
while sqrt**2<=n:
sq_list.append(sqrt**2)
sqrt += 1
nums = [4]*(n+1)
for i in range(1,n+1):
if i in sq_list:
nums[i] = 1
else:
for item in sq_list:
if item<i:
nums[i] = min(nums[i],nums[i-item]+1)
else:
break
return nums[-1]
<<<<<<< Updated upstream
print(numSquares(2))
def extract_text(file_path):
file = open(file_path)
lines = file.readlines()
print(len(lines))
count = 0
error = 0
for line in lines:
try:
text = yaml.load(line.strip())
except:
error += 1
continue
if text["extracted_text"]:
count += 1
print(count)
print(error)
=======
#print(numSquares(2))
a = 5
def happy():
print(a)
happy()
>>>>>>> Stashed changes