Browse Source

Add the first problem

Snow 8 years ago
commit
f6ad6a016e

BIN
arrays-and-strings/__pycache__/test_unique_characters.cpython-35-PYTEST.pyc


BIN
arrays-and-strings/__pycache__/unique_characters.cpython-35-PYTEST.pyc


+ 19 - 0
arrays-and-strings/unique_characters.py

@@ -0,0 +1,19 @@
+import pytest
+
+def isUnique(input):
+  input_len = len(input)
+  sub_string = {}
+  for i in range(input_len):
+    if input[i] in sub_string:
+      return False
+    else:
+      sub_string[input[i]] = True
+  return True
+
+def test_unique():
+  input1 = 'asdfghjkl'
+  input2 = 'aaaawwwwf'
+  assert isUnique(input1) == True
+  assert isUnique(input2) == False
+
+pytest.main()

+ 2 - 0
pytest.ini

@@ -0,0 +1,2 @@
+[pytest]
+python_files=*.py