DESCRIPTION:
Write a function
triple_double(num1, num2)
which takes numbers num1 and num2 and returns 1 if there is a straight triple of a number at any place in num1 and also a straight double of the same number in num2.
If this isn't the case, return 0
Examples
triple_double(451999277, 41177722899) == 1
# num1 has straight triple 999s and num2 has straight double 99s
triple_double(1222345, 12345) == 0
# num1 has straight triple 2s but num2 has only a single 2
triple_double(12345, 12345) == 0
triple_double(666789, 12345667) == 1
def fold_array(array, runs):
for i in range(runs):
if len(array)==1:
break
alist=[]
ln,rn=0,len(array)-1
while ln<rn:
print(ln,rn)
alist.append(array[ln]+array[rn])
ln+=1
rn-=1
if ln==rn:
alist.append(array[ln])
array=alist
return array
'알고리즘 문제 > CodeWar' 카테고리의 다른 글
Count IP Addresses (0) | 2022.10.18 |
---|---|
Fold an array (0) | 2022.10.17 |
Count the Digit (0) | 2022.10.16 |
Breaking Chocolate Problem (0) | 2022.10.16 |
Money, Money, Money (0) | 2022.10.16 |