Skip to content

Instantly share code, notes, and snippets.

@youknowcast
Created July 6, 2019 00:41
Show Gist options
  • Save youknowcast/4d3f84625e63dbc89ae10cd6060ad799 to your computer and use it in GitHub Desktop.
Save youknowcast/4d3f84625e63dbc89ae10cd6060ad799 to your computer and use it in GitHub Desktop.
Q3-3
def calc7(arr):
if len(arr) == 0:
return -1
else:
is_7 = False
ret = 0
for i in arr:
if is_7:
ret += i * 2
is_7 = False
else:
ret += i
if i == 7:
is_7 = True
return ret
print(calc7([1,2]))
print(calc7([3,7]))
print(calc7([7,5,6]))
print(calc7([7,9,7,9,7,9]))
print(calc7([]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment