-
-
Save namongk/d172f5d24ae03280af21 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 | |
import functools | |
def check(sub, sup): | |
try: | |
if len(sub) == 1 and sup.index(sub[0]) >= 0: | |
return True | |
return check(sub[1:], sup[sup.index(sub[0]) + 1:]) | |
except: | |
return False | |
class CheckTest(unittest.TestCase): | |
def setUp(self): | |
self.sup = [1, 2, 3, [4, 5]] | |
self.check = functools.partial(check, sup=self.sup) | |
def test1(self): | |
self.assertTrue(self.check([1])) | |
def test2(self): | |
self.assertTrue(self.check([1, 2])) | |
def test3(self): | |
self.assertTrue(self.check([2, 3])) | |
def test4(self): | |
self.assertTrue(self.check([1, [4, 5]])) | |
def test5(self): | |
self.assertFalse(self.check([2, 1])) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment