🎉 Hello world
This commit is contained in:
commit
95b2aa6c2f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/.idea
|
||||||
|
/venv
|
92
ElectronicStation/find-sequence.py
Normal file
92
ElectronicStation/find-sequence.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
def checkio(matr):
|
||||||
|
"""
|
||||||
|
Given the matrix NxN (4<=N<=10). Check if 4 numbers in sequence in a column or in a row or diagonally exist.
|
||||||
|
"""
|
||||||
|
for r in matr: # horizontal
|
||||||
|
if checkline(r):
|
||||||
|
return True
|
||||||
|
for r in zip(*matr): # vertical
|
||||||
|
if checkline(r):
|
||||||
|
return True
|
||||||
|
print(matr)
|
||||||
|
for r in range(0, len(matr)): # diagonal
|
||||||
|
for c in range(0, len(matr[0])):
|
||||||
|
ret = []
|
||||||
|
rx = r
|
||||||
|
cx = c
|
||||||
|
while True:
|
||||||
|
print('r = ', str(rx))
|
||||||
|
print('c = ', str(cx))
|
||||||
|
ret.append(matr[rx][cx])
|
||||||
|
rx = rx + 1
|
||||||
|
cx = cx + 1
|
||||||
|
if cx >= len(matr[0]) or rx >= len(matr):
|
||||||
|
break
|
||||||
|
if checkline(ret):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def checkline(l):
|
||||||
|
c = 0
|
||||||
|
p = ''
|
||||||
|
for x in l:
|
||||||
|
if p == '':
|
||||||
|
p = x
|
||||||
|
c = 1
|
||||||
|
continue
|
||||||
|
if p == x:
|
||||||
|
c += 1
|
||||||
|
if c >= 4:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
c = 0
|
||||||
|
p = x
|
||||||
|
return False
|
||||||
|
# len([x for x in l if l.count(x) == 4]) > 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
assert checkio([
|
||||||
|
[1, 1, 1, 1],
|
||||||
|
[1, 2, 3, 4],
|
||||||
|
[5, 4, 3, 1],
|
||||||
|
[6, 1, 3, 2]
|
||||||
|
]) == True, "First, horizontal"
|
||||||
|
assert checkio([
|
||||||
|
[7, 6, 5, 7, 9],
|
||||||
|
[8, 7, 3, 6, 5],
|
||||||
|
[4, 0, 6, 5, 4],
|
||||||
|
[9, 8, 4, 0, 5],
|
||||||
|
[2, 10, 7, 2, 10]
|
||||||
|
]) == False, "Second"
|
||||||
|
assert checkio([
|
||||||
|
[10, 1, 9, 6, 4, 1],
|
||||||
|
[2, 5, 4, 2, 2, 7],
|
||||||
|
[2, 2, 1, 2, 6, 4],
|
||||||
|
[3, 2, 2, 1, 0, 2],
|
||||||
|
[7, 9, 6, 2, 5, 7],
|
||||||
|
[7, 3, 10, 5, 6, 2]
|
||||||
|
]) == True, "Third"
|
||||||
|
assert checkio([
|
||||||
|
[6, 6, 7, 7, 7],
|
||||||
|
[1, 7, 3, 6, 5],
|
||||||
|
[4, 1, 2, 3, 2],
|
||||||
|
[9, 0, 4, 0, 5],
|
||||||
|
[2, 0, 7, 5, 10]
|
||||||
|
]) == False, "fourth"
|
||||||
|
assert checkio([
|
||||||
|
[1, 1, 1, 6, 1, 1, 1],
|
||||||
|
[2, 5, 4, 2, 2, 7, 2],
|
||||||
|
[2, 6, 1, 2, 6, 4, 3],
|
||||||
|
[3, 2, 2, 1, 0, 2, 4],
|
||||||
|
[7, 9, 6, 2, 5, 7, 5],
|
||||||
|
[7, 3, 10, 5, 6, 2, 5],
|
||||||
|
[7, 3, 10, 5, 6, 2, 5]
|
||||||
|
]) == False, "Fifth"
|
||||||
|
assert checkio([
|
||||||
|
[1, 1, 3, 1],
|
||||||
|
[1, 2, 3, 4],
|
||||||
|
[5, 4, 3, 1],
|
||||||
|
[6, 1, 3, 2]
|
||||||
|
]) == True, "Six, vertircal"
|
19
ElectronicStation/roman-numerals.py
Normal file
19
ElectronicStation/roman-numerals.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
def checkio(data):
|
||||||
|
mille = ['', 'M', 'MM', 'MMM']
|
||||||
|
centaine = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
|
||||||
|
dixaine = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
|
||||||
|
unite = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
|
||||||
|
return mille[int(data / 1000)] + \
|
||||||
|
centaine[int(data % 1000 / 100)] + \
|
||||||
|
dixaine[int(data % 1000 % 100 / 10)] + \
|
||||||
|
unite[int(data % 1000 % 100 % 10)]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert checkio(6) == 'VI', '6'
|
||||||
|
assert checkio(76) == 'LXXVI', '76'
|
||||||
|
assert checkio(499) == 'CDXCIX', '499'
|
||||||
|
assert checkio(3888) == 'MMMDCCCLXXXVIII', '3888'
|
||||||
|
assert checkio(3999) == 'MMMCMXCIX', '3999'
|
||||||
|
print('Done! Go Check!')
|
39
ElectronicStation/speechmodule.py
Normal file
39
ElectronicStation/speechmodule.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
def checkio(number):
|
||||||
|
toStr = ""
|
||||||
|
hasSpecials = False
|
||||||
|
numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
|
||||||
|
deci = {1: "ten", 2: "twenty", 3: "thirty", 4: "forty", 5: "fifty", 6: "sixty", 7: "seventy", 8: "eighty",
|
||||||
|
9: "ninety"}
|
||||||
|
specials = {11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen",
|
||||||
|
17: "seventeen", 18: "eighteen", 19: "nineteen"}
|
||||||
|
isHundred = number / 100
|
||||||
|
isDeci = (number % 100) / 10
|
||||||
|
isNum = ((number % 100) % 10)
|
||||||
|
|
||||||
|
if isHundred >= 1:
|
||||||
|
toStr += numbers[isHundred] + " hundred"
|
||||||
|
if isDeci == 1 and (isNum != 0):
|
||||||
|
if toStr:
|
||||||
|
toStr += " "
|
||||||
|
toStr += specials[isDeci * 10 + isNum]
|
||||||
|
hasSpecials = True
|
||||||
|
elif isDeci > 1:
|
||||||
|
if toStr:
|
||||||
|
toStr += " "
|
||||||
|
toStr += str(deci[int(isDeci)])
|
||||||
|
if hasSpecials == False and isNum != 0:
|
||||||
|
if toStr:
|
||||||
|
toStr += " "
|
||||||
|
toStr += numbers[isNum]
|
||||||
|
return toStr
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
assert checkio(4) == 'four', "First"
|
||||||
|
assert checkio(133) == 'one hundred thirty three', "Second"
|
||||||
|
assert checkio(12) == 'twelve', "Third"
|
||||||
|
assert checkio(101) == 'one hundred one', "Fifth"
|
||||||
|
assert checkio(212) == 'two hundred twelve', "Sixth"
|
||||||
|
assert checkio(40) == 'forty', "Seventh, forty - it is correct"
|
||||||
|
|
||||||
|
print('All ok')
|
18
Elementary/correct-sentence.py
Normal file
18
Elementary/correct-sentence.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
def correct_sentence(text: str) -> str:
|
||||||
|
"""
|
||||||
|
returns a corrected sentence which starts with a capital letter
|
||||||
|
and ends with a dot.
|
||||||
|
"""
|
||||||
|
return "{}{}.".format(text[0].upper(), text[1:].strip('.'))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(correct_sentence("greetings, friends"))
|
||||||
|
# These "asserts" are used for self-checking and not for an auto-testing
|
||||||
|
assert correct_sentence("greetings, friends") == "Greetings, friends."
|
||||||
|
assert correct_sentence("Greetings, friends") == "Greetings, friends."
|
||||||
|
assert correct_sentence("Greetings, friends.") == "Greetings, friends."
|
||||||
|
assert correct_sentence("hi") == "Hi."
|
||||||
|
assert correct_sentence("welcome to New York") == "Welcome to New York."
|
||||||
|
print("Coding complete? Click 'Check' to earn cool rewards!")
|
16
Elementary/say-history.py
Normal file
16
Elementary/say-history.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# 1. on CheckiO your solution should be a function
|
||||||
|
# 2. the function should return the right answer, not print it.
|
||||||
|
|
||||||
|
|
||||||
|
def say_hi(name: str, age: int) -> str:
|
||||||
|
"""
|
||||||
|
Hi!
|
||||||
|
"""
|
||||||
|
return "Hi. My name is {} and I'm {} years old".format(name, age)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert say_hi("Alex", 32) == "Hi. My name is Alex and I'm 32 years old", "First"
|
||||||
|
assert say_hi("Frank", 68) == "Hi. My name is Frank and I'm 68 years old", "Second"
|
||||||
|
print('Done. Time to Check.')
|
25
Home/all-the-same.py
Normal file
25
Home/all-the-same.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from typing import List, Any
|
||||||
|
|
||||||
|
|
||||||
|
def all_the_same(elements: List[Any]) -> bool:
|
||||||
|
if len(elements) <= 1:
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
elements.sort()
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
return elements[0] == elements[-1:][0]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(all_the_same([1, 1, 1]))
|
||||||
|
|
||||||
|
# These "asserts" are used for self-checking and not for an auto-testing
|
||||||
|
assert all_the_same([1, 1, 1]) == True
|
||||||
|
assert all_the_same([1, 2, 1]) == False
|
||||||
|
assert all_the_same([1, 'a', 1]) == False
|
||||||
|
assert all_the_same(['a', 'a', 'a']) == True
|
||||||
|
assert all_the_same([]) == True
|
||||||
|
assert all_the_same([1]) == True
|
||||||
|
print("Coding complete? Click 'Check' to earn cool rewards!")
|
27
Home/bird-language.py
Normal file
27
Home/bird-language.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
VOWELS = "aeiouy"
|
||||||
|
|
||||||
|
|
||||||
|
def translate(phrase):
|
||||||
|
sentence = ""
|
||||||
|
pointer = 0
|
||||||
|
while pointer < len(phrase):
|
||||||
|
char = phrase[pointer]
|
||||||
|
if char not in VOWELS:
|
||||||
|
sentence += char
|
||||||
|
pointer += (1 if char == ' ' else 2)
|
||||||
|
else:
|
||||||
|
sentence += char
|
||||||
|
pointer += 3
|
||||||
|
return sentence
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(translate("hieeelalaooo"))
|
||||||
|
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert translate("hieeelalaooo") == "hello", "Hi!"
|
||||||
|
assert translate("hoooowe yyyooouuu duoooiiine") == "how you doin", "Joey?"
|
||||||
|
assert translate("aaa bo cy da eee fe") == "a b c d e f", "Alphabet"
|
||||||
|
assert translate("sooooso aaaaaaaaa") == "sos aaa", "Mayday, mayday"
|
||||||
|
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
|
16
Home/flatten-list.py
Normal file
16
Home/flatten-list.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
def flat_list(array):
|
||||||
|
result = []
|
||||||
|
for element in array:
|
||||||
|
if isinstance(element, list):
|
||||||
|
result += flat_list(element)
|
||||||
|
else:
|
||||||
|
result.append(element)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
assert flat_list([1, 2, 3]) == [1, 2, 3], "First"
|
||||||
|
assert flat_list([1, [2, 2, 2], 4]) == [1, 2, 2, 2, 4], "Second"
|
||||||
|
assert flat_list([[[2]], [4, [5, 6, [6], 6, 6, 6], 7]]) == [2, 4, 5, 6, 6, 6, 6, 6, 7], "Third"
|
||||||
|
assert flat_list([-1, [1, [-2], 1], -1]) == [-1, 1, -2, 1, -1], "Four"
|
||||||
|
print('Done! Check it')
|
29
Home/house-password.py
Normal file
29
Home/house-password.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# migrated from python 2.7
|
||||||
|
def checkio(data):
|
||||||
|
numbers = ["0","1","2","3","4","5","6","7","8","9"]
|
||||||
|
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t" ,"u", "v", "w", "x", "y", "z"]
|
||||||
|
beta = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" ,"U", "V", "W", "X", "Y", "Z"]
|
||||||
|
if(len(data)<10):
|
||||||
|
return False
|
||||||
|
if(has(data, numbers) == False):
|
||||||
|
return False
|
||||||
|
if(has(data, alpha) == False):
|
||||||
|
return False
|
||||||
|
if(has(data, beta) == False):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def has(da, ar):
|
||||||
|
for c in da:
|
||||||
|
if(c in ar):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
assert checkio('A1213pokl')==False, 'First'
|
||||||
|
assert checkio('bAse730onE4')==True, 'Second'
|
||||||
|
assert checkio('asasasasasasasaas')==False, 'Third'
|
||||||
|
assert checkio('QWERTYqwerty')==False, 'Fourth'
|
||||||
|
assert checkio('123456123456')==False, 'Fifth'
|
||||||
|
assert checkio('QwErTy911poqqqq')==True, 'Sixth'
|
||||||
|
print('All ok')
|
28
Home/long-repeat.py
Normal file
28
Home/long-repeat.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
def long_repeat(line: str) -> int:
|
||||||
|
longest = 0
|
||||||
|
"""
|
||||||
|
length the longest substring that consists of the same char
|
||||||
|
"""
|
||||||
|
current = None
|
||||||
|
current_counter = 0
|
||||||
|
for char in line:
|
||||||
|
if char != current:
|
||||||
|
if current_counter > longest:
|
||||||
|
longest = current_counter
|
||||||
|
current = char
|
||||||
|
current_counter = 1
|
||||||
|
else:
|
||||||
|
current_counter += 1
|
||||||
|
|
||||||
|
if current_counter > longest:
|
||||||
|
longest = current_counter
|
||||||
|
return longest
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert long_repeat('sdsffffse') == 4, "First"
|
||||||
|
assert long_repeat('ddvvrwwwrggg') == 3, "Second"
|
||||||
|
assert long_repeat('abababaab') == 2, "Third"
|
||||||
|
assert long_repeat('') == 0, "Empty"
|
||||||
|
print('"Run" is good. How is "Check"?')
|
32
Home/most-wanted-letter.py
Normal file
32
Home/most-wanted-letter.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import string
|
||||||
|
|
||||||
|
def checkio(text: str) -> str:
|
||||||
|
letters = {x: 0 for x in list(string.ascii_lowercase)}
|
||||||
|
for letter in text:
|
||||||
|
letter = letter.lower()
|
||||||
|
if letter in letters:
|
||||||
|
letters[letter] = letters[letter] + 1
|
||||||
|
|
||||||
|
retour = None
|
||||||
|
retour_count = 0
|
||||||
|
for letter, count in letters.items():
|
||||||
|
if retour_count < count:
|
||||||
|
retour_count = count
|
||||||
|
retour = letter
|
||||||
|
|
||||||
|
return retour
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(checkio("Hello World!"))
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert checkio("Hello World!") == "l", "Hello test"
|
||||||
|
assert checkio("How do you do?") == "o", "O is most wanted"
|
||||||
|
assert checkio("One") == "e", "All letter only once."
|
||||||
|
assert checkio("Oops!") == "o", "Don't forget about lower case."
|
||||||
|
assert checkio("AAaooo!!!!") == "a", "Only letters."
|
||||||
|
assert checkio("abe") == "a", "The First."
|
||||||
|
print("Start the long test")
|
||||||
|
assert checkio("a" * 9000 + "b" * 1000) == "a", "Long."
|
||||||
|
print("The local tests are done.")
|
25
Home/non-unique-elements.py
Normal file
25
Home/non-unique-elements.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Your optional code here
|
||||||
|
# You can import some modules or create additional functions
|
||||||
|
|
||||||
|
|
||||||
|
def checkio(data: list) -> list:
|
||||||
|
doublon = []
|
||||||
|
for number in data:
|
||||||
|
if data.count(number) > 1:
|
||||||
|
doublon.append(number)
|
||||||
|
return doublon
|
||||||
|
|
||||||
|
|
||||||
|
# Some hints
|
||||||
|
# You can use list.count(element) method for counting.
|
||||||
|
# Create new list with non-unique elements
|
||||||
|
# Loop over original list
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert list(checkio([1, 2, 3, 1, 3])) == [1, 3, 1, 3], "1st example"
|
||||||
|
assert list(checkio([1, 2, 3, 4, 5])) == [], "2nd example"
|
||||||
|
assert list(checkio([5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5], "3rd example"
|
||||||
|
assert list(checkio([10, 9, 10, 10, 9, 8])) == [10, 9, 10, 10, 9], "4th example"
|
||||||
|
print("It is all good. Let's check it now")
|
23
Home/time-converter-24h-to-12h.py
Normal file
23
Home/time-converter-24h-to-12h.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
def time_converter(time):
|
||||||
|
time_string = int(time.replace(':', ''))
|
||||||
|
time_array = time.split(':')
|
||||||
|
if time_string < 100:
|
||||||
|
return "12:{} a.m.".format(time_array[1])
|
||||||
|
elif time_string < 1200:
|
||||||
|
return "{} a.m.".format(time.lstrip('0'))
|
||||||
|
elif time_string < 1300:
|
||||||
|
return "{} p.m.".format(time.lstrip('0'))
|
||||||
|
else:
|
||||||
|
return "{}:{} p.m.".format(int(time_array[0]) - 12, time_array[1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(time_converter('12:30'))
|
||||||
|
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert time_converter('00:00') == '12:00 a.m.'
|
||||||
|
assert time_converter('12:30') == '12:30 p.m.'
|
||||||
|
assert time_converter('09:00') == '9:00 a.m.'
|
||||||
|
assert time_converter('23:15') == '11:15 p.m.'
|
||||||
|
print("Coding complete? Click 'Check' to earn cool rewards!")
|
70
Home/x-o-referee.py
Normal file
70
Home/x-o-referee.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
def checkio(game_result: List[str]) -> str:
|
||||||
|
h = horizontal(game_result)
|
||||||
|
v = vertical(game_result)
|
||||||
|
d = diagonal(game_result)
|
||||||
|
if h != "D":
|
||||||
|
return h
|
||||||
|
if v != "D":
|
||||||
|
return v
|
||||||
|
if d != "D":
|
||||||
|
return d
|
||||||
|
return "D"
|
||||||
|
|
||||||
|
|
||||||
|
def horizontal(game_result: List[str]) -> str:
|
||||||
|
for row in game_result:
|
||||||
|
cells = list(row)
|
||||||
|
cells.sort()
|
||||||
|
if cells[0] == '.':
|
||||||
|
continue
|
||||||
|
if cells[0] == cells[-1:][0]:
|
||||||
|
return cells[0]
|
||||||
|
return "D"
|
||||||
|
|
||||||
|
|
||||||
|
def vertical(game_result: List[str]) -> str:
|
||||||
|
new_game_result = []
|
||||||
|
for i in range(len(game_result)):
|
||||||
|
new_game_result.append(game_result[0][i] + game_result[1][i] + game_result[2][i])
|
||||||
|
return horizontal(new_game_result)
|
||||||
|
|
||||||
|
|
||||||
|
def diagonal(game_result: List[str]) -> str:
|
||||||
|
if game_result[1][1] == '.':
|
||||||
|
return "D"
|
||||||
|
if game_result[0][0] == game_result[1][1] and game_result[1][1] == game_result[2][2]:
|
||||||
|
return game_result[1][1]
|
||||||
|
if game_result[0][2] == game_result[1][1] and game_result[1][1] == game_result[2][0]:
|
||||||
|
return game_result[1][1]
|
||||||
|
return "D"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Example:")
|
||||||
|
print(checkio(["X.O",
|
||||||
|
"XX.",
|
||||||
|
"XOO"]))
|
||||||
|
|
||||||
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
||||||
|
assert checkio([
|
||||||
|
"X.O",
|
||||||
|
"XX.",
|
||||||
|
"XOO"]) == "X", "Xs wins"
|
||||||
|
assert checkio([
|
||||||
|
"OO.",
|
||||||
|
"XOX",
|
||||||
|
"XOX"]) == "O", "Os wins"
|
||||||
|
assert checkio([
|
||||||
|
"OOX",
|
||||||
|
"XXO",
|
||||||
|
"OXX"]) == "D", "Draw"
|
||||||
|
assert checkio([
|
||||||
|
"O.X",
|
||||||
|
"XX.",
|
||||||
|
"XOO"]) == "X", "Xs wins again"
|
||||||
|
assert checkio([".O.", "XXX", ".O."]) == "X", "Xs wins again"
|
||||||
|
assert checkio(["...", "XXX", "OO."]) == "X", "Xs wins again"
|
||||||
|
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
|
Loading…
Reference in New Issue
Block a user