diff --git a/src/python.py b/src/python.py index 0fe8a02..64b7ef7 100644 --- a/src/python.py +++ b/src/python.py @@ -1,9 +1,14 @@ # Your friend has become a firm python fanatic, # to the point where he will only speak in sentences # that contain all of the letters in the word python -# Your objective is, given a string, return true if +# Your objective is, given a string, return true if # it contains all the letters p, y, t, h, o, n, and return # false otherwise def python(sentence): - pass \ No newline at end of file + letters = set(sentence) + word = 'python' + for c in word: + if c not in letters: + return False + return True diff --git a/src/stringToInt.py b/src/stringToInt.py index f5dbef9..b053202 100644 --- a/src/stringToInt.py +++ b/src/stringToInt.py @@ -1,3 +1,11 @@ # return the int representation of string s def stringToInt(s): - pass \ No newline at end of file + result = 0 + power = 1 + sign = 1 - 2*('-' == s[0]) + if sign == -1: + s = s[1:] + for c in reversed(s): + result += (ord(c)-ord('0'))*power + power *= 10 + return result*sign diff --git a/testing/python_test.py b/testing/python_test.py index ce369c9..aa968cb 100644 --- a/testing/python_test.py +++ b/testing/python_test.py @@ -14,7 +14,7 @@ def test2(self): self.assertEqual(python.python("java"), False) def test3(self): - self.assertEqual(python.python("pytho?", False) + self.assertEqual(python.python("pytho?"), False) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()