Created
July 3, 2020 19:55
-
-
Save tetsupanda/1b949278a0fdc8dd085faf7b599fbe2f 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
import unittest | |
def solution(T): | |
seasons = ('WINTER', 'SPRING', 'SUMMER', 'AUTUMN') | |
season_len = len(T) // 4 | |
last_highest = 0 | |
highest_season = 0 | |
for i in range(4): | |
temp_arr = T[season_len * i:season_len * (i + 1)] | |
season_amplitutde = max(temp_arr) - min(temp_arr) | |
if season_amplitutde > last_highest: | |
highest_season = i | |
last_highest = season_amplitutde | |
return seasons[highest_season] | |
class amplitudetemp(unittest.TestCase): | |
def test1(self): | |
t_arr = [-3, -14, -5, 7, 8, 42, 8, 3] | |
self.assertEqual(solution(t_arr), 'SUMMER') | |
def test2(self): | |
t_arr = [2, -3, 3, 1, 10, 8, 2, 5, 13, -5, 3, -18] | |
self.assertEqual(solution(t_arr), 'AUTUMN') | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment