Last active
September 18, 2019 11:33
-
-
Save 0xIslamTaha/e7f0e904b7dc1d1731bae4d020189701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tomato_cheese(c, t): | |
if t % 2 != 0 or c <= 0 or t <= 0 or t/2 < c: | |
return [-1, -1] | |
if t/2 == c: | |
return [int(t/2), 0] | |
mini, big = 0, 0 | |
if t/2 > c: | |
t = t - 4 | |
c = c - 1 | |
big = big + 1 | |
curs = tomato_cheese(c, t) | |
if -1 in curs: | |
return [-1, -1] | |
else: | |
mini = mini + curs[0] | |
big = big + curs[1] | |
return [mini, big] | |
def switching_list(data): | |
print(data) | |
if len(data) == 1: | |
return 1 | |
if len(data) == 2: | |
return 0 | |
if all(elem == data[0] for elem in data): | |
return len(data) | |
result = 0 | |
if data[0] != data[2]: | |
data = data[1:] | |
result = result + switching_list(data) | |
return result | |
if data[-1] != data[-3]: | |
data = data[:-1] | |
result = result + switching_list(data) | |
return result | |
result = len(data) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment