SHARE
TWEET

Untitled

a guest Jul 17th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def calc7(arr):
  2.     if len(arr) == 0:
  3.         return -1
  4.     else:
  5.         is_7 = False
  6.         ret = 0
  7.         for i in arr:
  8.             if is_7:
  9.                 ret += i * 2
  10.                 is_7 = False
  11.             else:
  12.                 ret += i
  13.                 if i == 7:
  14.                     is_7 = True
  15.         return ret
  16.  
  17. print(calc7([1,2]))
  18. print(calc7([3,7]))
  19. print(calc7([7,5,6]))
  20. print(calc7([7,9,7,9,7,9]))
  21. print(calc7([]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top