Skip to content

Instantly share code, notes, and snippets.

View Saybayry's full-sized avatar

Kamil Narygin Saybayry

  • Алтайский государственный университет
  • Барнаул Алтайский край Россия
View GitHub Profile
import unittest
from .get_score import get_score
class GetScoreTestCase(unittest.TestCase):
def test_offset_1(self):
game_stamps = [{"offset": 1, "score": {"home": 0, "away": 0}}, {"offset": 2, "score": {"home": 0, "away": 1}}]
self.assertEqual(get_score(game_stamps, 1), (0, 0))
from bisect import bisect_left
def get_score(game_stamps, offset):
'''
Takes list of game's stamps and time offset for which returns the scores for the home and away teams.
Please pay attention to that for some offsets the game_stamps list may not contain scores.
'''
if type(offset)!= int:
raise ValueError
elif offset <= game_stamps[0]['offset']: