-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplas.py
More file actions
55 lines (37 loc) · 841 Bytes
/
duplas.py
File metadata and controls
55 lines (37 loc) · 841 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
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
#opt.1
###
# num = [1,2,8,2,1,5,5,0,1,0,7,3]
# count = 0
#for index in range(0,11,1):
# if num[index] + num[index+1] == 10:
# count += 1
#print(count)
#opt.2
#num = [1,2,8,2,1,5,5,0,1,0,7,3]
#count2 = 0
#def duplas(a,b) -> int:
# if a + b == 10:
# return 1
# else:
# return 0
#for index in range(len(num)-1):
# count2 += duplas(num[index], num[index+1])
#print(count2)
#opt. 3
num = [1,2,8,2,1,5,5,0,1,0,7,3]
a = 0
b = 0
total = 0
class duplas:
def __init__(self, a, b):
self.a = a
self.b = b
self.total = 0
#print("a: {}, b: {}".format(a,b))
def cantOf10s(self):
if (self.a + self.b == 10):
self.total += 1
return self.total
for i in range(len(num)-1):
total += duplas(num[i],num[i+1]).cantOf10s()
print(total)