Init
This commit is contained in:
commit
c3f32e6f79
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.pyc
|
||||
Task*Test.xml
|
||||
*~
|
||||
pylint.log
|
29
blend.sh
Executable file
29
blend.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/zsh
|
||||
|
||||
. ./vars
|
||||
|
||||
cd ..
|
||||
|
||||
STUDENT_DIR=`ls -d ${PREFIX}-s??????`
|
||||
|
||||
echo "USING $STUDENT_DIR"
|
||||
|
||||
rm -rf arena
|
||||
mkdir arena
|
||||
|
||||
cp -R $STUDENT_DIR/* arena/
|
||||
ln -s ../$STUDENT_DIR/.git arena/.git
|
||||
|
||||
mkdir -p arena/regexp
|
||||
mkdir -p arena/automata
|
||||
|
||||
rm -rf arena/odp arena/$PREFIX
|
||||
|
||||
rm arena/run.sh arena/vars
|
||||
find arena -regex '.*/Task.*Test\.\(py\|dat\..*\)' -exec rm '{}' ';'
|
||||
|
||||
cp "${PREFIX}/run.sh" arena/run.sh
|
||||
cp "${PREFIX}/vars" arena/vars
|
||||
cp "${PREFIX}/overrides.txt" arena/overrides.txt
|
||||
|
||||
find ${PREFIX} -regex '.*/Task.*Test\.\(py\|dat\..*\)' -print | while read T; do cp $T ${T/${PREFIX}/arena}; done
|
12
intro/Task101.py
Normal file
12
intro/Task101.py
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Rozwiązanie zadania 101."""
|
||||
|
||||
|
||||
def even_elements(inlist):
|
||||
"""Zwraca elementy listy o indeksach parzystych."""
|
||||
return [inlist[i] for i in range(len(inlist)) if i % 2 == 0]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(even_elements([1, 2, 3, 4]))
|
44
intro/Task101Test.py
Executable file
44
intro/Task101Test.py
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 101
|
||||
|
||||
Napisz funkcję `even_elements` zwracającą listę, która zawiera tylko
|
||||
elementy z `list` o parzystych indeksach. (Zadanie kontrolne z gotowym
|
||||
rozwiązaniem!)
|
||||
|
||||
NAME: even_elements
|
||||
PARAMS: list
|
||||
RETURN: list
|
||||
POINTS: 1
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task101 import even_elements
|
||||
|
||||
class Task101Test(unittest.TestCase):
|
||||
"""Testy do zadania 101"""
|
||||
|
||||
def test_sequence(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(even_elements([1, 2, 3, 4, 5, 6]), [1, 3, 5])
|
||||
|
||||
def test_empty(self):
|
||||
"""Test na pustej liście."""
|
||||
self.assertEqual(even_elements([]), [])
|
||||
|
||||
def test_singleton(self):
|
||||
"""Test na liście jednoelementowej."""
|
||||
self.assertEqual(even_elements([41]), [41])
|
||||
|
||||
def test_two_elements(self):
|
||||
"""Test na liście dwuelementowej."""
|
||||
self.assertEqual(even_elements([100, 2]), [100])
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test na liście z ujemnym elementem."""
|
||||
self.assertEqual(even_elements([-31, 0, 2]), [-31, 2])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
30
intro/Task102Test.py
Executable file
30
intro/Task102Test.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 102
|
||||
|
||||
Napisz funkcję `add_three_numbers` zwracającą sumę trzech liczb całkowitych.
|
||||
|
||||
NAME: add_three_numbers
|
||||
PARAMS: int, int, int
|
||||
RETURN: int
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task102 import add_three_numbers
|
||||
|
||||
class Task102Test(unittest.TestCase):
|
||||
"""Testy do zadania 102"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(add_three_numbers(2, 5, 7), 14)
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test z liczbami ujemnymi."""
|
||||
self.assertEqual(add_three_numbers(-3, -1, 2), -2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
46
intro/Task103Test.py
Executable file
46
intro/Task103Test.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 103
|
||||
|
||||
Napisz funkcję `probability` sprawdzającej, czy zadana liczba
|
||||
reprezentuje prawdopodobieństwo (liczbę z zakresu od 0.0 do 1.0).
|
||||
Jeśli tak, powinna zostać zwrócona ta liczba, w przeciwnym razie -
|
||||
liczba 0.
|
||||
|
||||
NAME: probability
|
||||
PARAMS: double
|
||||
RETURN: double
|
||||
POINTS: 2
|
||||
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task103 import probability
|
||||
|
||||
class Task103Test(unittest.TestCase):
|
||||
"""Testy do zadania 103"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertAlmostEqual(probability(0.62), 0.62)
|
||||
|
||||
def test_negatives(self):
|
||||
"""Test z liczbami ujemnymi."""
|
||||
self.assertAlmostEqual(probability(-0.6), 0.0)
|
||||
self.assertAlmostEqual(probability(-1337), 0.0)
|
||||
|
||||
def test_special_cases(self):
|
||||
"""Test z wartościami specjalnymi."""
|
||||
self.assertEqual(probability(0.0), 0.0)
|
||||
self.assertEqual(probability(1.0), 1.0)
|
||||
|
||||
def test_out_of_range(self):
|
||||
"""Za duże wartości."""
|
||||
self.assertEqual(probability(1.001), 0.0)
|
||||
self.assertEqual(probability(972.12), 0.0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
38
intro/Task104Test.py
Executable file
38
intro/Task104Test.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 104
|
||||
|
||||
Napisz funkcję `fahrenheit`, która przelicza stopnie Celsjusza na
|
||||
stopnie Fahrenheita. Dla wartości mniejszych niż -273.15 funkcja
|
||||
powinna zwracać zawsze -459.67.
|
||||
|
||||
NAME: fahrenheit
|
||||
PARAMS: float
|
||||
RETURN: float
|
||||
POINTS: 2
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task104 import fahrenheit
|
||||
|
||||
class Task104Test(unittest.TestCase):
|
||||
"""Testy do zadania 104"""
|
||||
|
||||
def test_simple_cases(self):
|
||||
"""Testy dla standardowych przypadków."""
|
||||
self.assertAlmostEqual(fahrenheit(10), 50)
|
||||
self.assertAlmostEqual(fahrenheit(33), 91.4)
|
||||
self.assertAlmostEqual(fahrenheit(0), 32)
|
||||
self.assertAlmostEqual(fahrenheit(-8), 17.6)
|
||||
self.assertAlmostEqual(fahrenheit(-273), -459.4)
|
||||
self.assertAlmostEqual(fahrenheit(-273.15), -459.67)
|
||||
|
||||
def test_below_zero(self):
|
||||
"""Testy dla temperatur poniżej zera absolutnego."""
|
||||
self.assertAlmostEqual(fahrenheit(-274), -459.67)
|
||||
self.assertAlmostEqual(fahrenheit(-10000), -459.67)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
50
intro/Task105Test.py
Executable file
50
intro/Task105Test.py
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 105
|
||||
|
||||
Napisz funkcję `is_almost_prime(number, limit)` sprawdzającą, czy
|
||||
podana liczba nie dzieli się przez żadną liczbę z zakresu od 2 do
|
||||
`limit`. Dla liczb ujemnych powinna zostać zwrócona wartość `False`.
|
||||
|
||||
NAME: is_almost_prime
|
||||
PARAMS: int, int
|
||||
RETURN: bool
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task105 import is_almost_prime
|
||||
|
||||
class Task105Test(unittest.TestCase):
|
||||
"""Testy do zadania 105"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Proste testy"""
|
||||
self.assertTrue(is_almost_prime(35, 4))
|
||||
self.assertFalse(is_almost_prime(35, 5))
|
||||
self.assertFalse(is_almost_prime(35, 100))
|
||||
self.assertTrue(is_almost_prime(17, 4))
|
||||
self.assertTrue(is_almost_prime(17, 16))
|
||||
self.assertFalse(is_almost_prime(17, 17))
|
||||
self.assertFalse(is_almost_prime(17, 100))
|
||||
self.assertFalse(is_almost_prime(16, 2))
|
||||
self.assertFalse(is_almost_prime(16, 5))
|
||||
self.assertFalse(is_almost_prime(16, 13))
|
||||
self.assertFalse(is_almost_prime(16, 101))
|
||||
|
||||
def test_special_cases(self):
|
||||
"""Testy przypadków szczególnych."""
|
||||
self.assertFalse(is_almost_prime(-1, 10))
|
||||
self.assertFalse(is_almost_prime(0, 8))
|
||||
self.assertTrue(is_almost_prime(1, 6))
|
||||
self.assertFalse(is_almost_prime(2, 2))
|
||||
|
||||
def test_negatives(self):
|
||||
"""Testy dla liczb ujemnych."""
|
||||
self.assertFalse(is_almost_prime(-5, 100))
|
||||
self.assertFalse(is_almost_prime(-13, 5))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
48
intro/Task106Test.py
Executable file
48
intro/Task106Test.py
Executable file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 106
|
||||
|
||||
Napisz funkcję `penultimate(list, otherwise)` zwracającą przedostatni
|
||||
element listy `list`. Jeśli lista jest pusta lub jednoelementowa,
|
||||
należy zwrócić wartość `otherwise`.
|
||||
|
||||
NAME: penultimate
|
||||
PARAMS: list, obj
|
||||
RETURN: obj
|
||||
POINTS: 2
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task106 import penultimate
|
||||
|
||||
class Task106Test(unittest.TestCase):
|
||||
"""Testy do zadania 106"""
|
||||
|
||||
def test_sequence(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(
|
||||
penultimate([1, 2, 3, 4, 5, 6], 'blabla'),
|
||||
5)
|
||||
|
||||
def test_empty(self):
|
||||
"""Test na pustej liście."""
|
||||
self.assertEqual(
|
||||
penultimate([], 'DO NOT WANT'),
|
||||
'DO NOT WANT')
|
||||
|
||||
def test_singleton(self):
|
||||
"""Test na liście jednoelementowej."""
|
||||
self.assertEqual(
|
||||
penultimate([41], 42),
|
||||
42)
|
||||
|
||||
def test_two_elements(self):
|
||||
"""Test na liście dwuelementowej."""
|
||||
self.assertEqual(
|
||||
penultimate(['x', 'y'], 'z'),
|
||||
'x')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
intro/Task107Test.py
Executable file
40
intro/Task107Test.py
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 107
|
||||
|
||||
Napisz funkcję `list_cubed(list)` zwracającą sumę sześcianów
|
||||
zadanych liczb. Dla listy pustej powinna zostać zwrócona wartość zero.
|
||||
|
||||
NAME: list_cubed
|
||||
PARAMS: list
|
||||
RETURN: obj
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task107 import list_cubed
|
||||
|
||||
class Task107Test(unittest.TestCase):
|
||||
"""Testy do zadania 107"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(list_cubed([3, 0, -1, 2]), 34),
|
||||
|
||||
def test_empty(self):
|
||||
"""Test na pustej liście."""
|
||||
self.assertEqual(list_cubed([]), 0),
|
||||
|
||||
def test_singleton(self):
|
||||
"""Test na liście jednoelementowej."""
|
||||
self.assertEqual(list_cubed([-4]), -64)
|
||||
|
||||
def test_two_elements(self):
|
||||
"""Test na liście dwuelementowej."""
|
||||
self.assertEqual(list_cubed([100, -100]), 0)
|
||||
self.assertEqual(list_cubed([2, 10]), 1008)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
37
intro/Task108Test.py
Executable file
37
intro/Task108Test.py
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 108
|
||||
|
||||
Napisz funkcję `pokemon_speak`, która zamienia w podanym napisie co
|
||||
drugą literę na wielką. Np. `pokemon_speak('pokemon')` powinno zwrócić
|
||||
'PoKeMoN'.
|
||||
|
||||
NAME: pokemon_speak
|
||||
PARAMS: string
|
||||
RETURN: string
|
||||
POINTS: 4
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task108 import pokemon_speak
|
||||
|
||||
class Task108Test(unittest.TestCase):
|
||||
"""Testy do zadania 108."""
|
||||
|
||||
def test_special_cases(self):
|
||||
"""Przypadki szczególne."""
|
||||
self.assertEqual(pokemon_speak(''), '')
|
||||
self.assertEqual(pokemon_speak('x'), 'X')
|
||||
self.assertEqual(pokemon_speak('X'), 'X')
|
||||
self.assertEqual(pokemon_speak('1337'), '1337')
|
||||
|
||||
def test_standard_cases(self):
|
||||
"""Standardowe przypadki."""
|
||||
self.assertEqual(pokemon_speak('pokemon'), 'PoKeMoN')
|
||||
self.assertEqual(pokemon_speak('do not want'), 'Do nOt wAnT')
|
||||
self.assertEqual(pokemon_speak('POKEMON'), 'POKEMON')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
8
intro/Task109Test.dat.txt
Normal file
8
intro/Task109Test.dat.txt
Normal file
@ -0,0 +1,8 @@
|
||||
raz
|
||||
dwa
|
||||
YES
|
||||
cztery
|
||||
YES
|
||||
YES
|
||||
YES
|
||||
tego YES nie liczyć
|
31
intro/Task109Test.py
Executable file
31
intro/Task109Test.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 109
|
||||
|
||||
Napisz funkcję `count_yes_lines(filename)`, która po podaniu nazwy pliku
|
||||
tekstowego `filename` zwraca liczbę wierszy w pliku zawierających
|
||||
(wyłącznie) napis "YES" (i znak końca wiersza).
|
||||
|
||||
NAME: count_yes_lines
|
||||
PARAMS: string
|
||||
RETURN: int
|
||||
POINTS: 3
|
||||
"""
|
||||
import unittest
|
||||
from Task109 import count_yes_lines
|
||||
|
||||
class Task109Test(unittest.TestCase):
|
||||
"""Testy do zadania 109."""
|
||||
|
||||
def test_on_self(self):
|
||||
"""Testy na samym sobie."""
|
||||
self.failUnlessEqual(count_yes_lines("Task109Test.py"), 0)
|
||||
|
||||
def test_simple(self):
|
||||
"""Testy na prostym pliku."""
|
||||
self.failUnlessEqual(count_yes_lines("Task109Test.dat.txt"), 4)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
6
intro/Task110Test.dat.in.txt
Normal file
6
intro/Task110Test.dat.in.txt
Normal file
@ -0,0 +1,6 @@
|
||||
this is a string
|
||||
Ala ma kota
|
||||
blablabla
|
||||
|
||||
nic
|
||||
pies, czyli kot
|
6
intro/Task110Test.dat.out.txt
Normal file
6
intro/Task110Test.dat.out.txt
Normal file
@ -0,0 +1,6 @@
|
||||
4 2 1 6
|
||||
3 2 4
|
||||
9
|
||||
|
||||
3
|
||||
5 5 3
|
46
intro/Task110Test.py
Executable file
46
intro/Task110Test.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 110
|
||||
|
||||
Napisz funkcję `words_to_length(infile, outfile)`, która wczytując
|
||||
wiersze z pliku `infile` i wypisując je do pliku `outfile`, zamienia
|
||||
wyrazy na liczbę odpowiadającą długości wyrazu. Np. wiersz `this is a
|
||||
string` zostanie zamieniony na `4 2 1 6`. Zakładamy, że wyrazy
|
||||
oddzielone są spacjami (np. dla `pies, czyli kot` powinno wyjść `5 5
|
||||
3`).
|
||||
|
||||
NAME: word_to_length
|
||||
PARAMS: file, file
|
||||
RETURN: string
|
||||
POINTS: 5
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task110 import word_to_length
|
||||
|
||||
class Task110Test(unittest.TestCase):
|
||||
"""Testy do zadania 110"""
|
||||
|
||||
def test(self):
|
||||
"""Prosty test przez porównanie z oczekiwanym wyjściem."""
|
||||
infile = open("Task110Test.dat.in.txt", 'r')
|
||||
|
||||
out1 = open("Task110Test.out.txt", 'w')
|
||||
word_to_length(infile, out1)
|
||||
infile.close()
|
||||
out1.close()
|
||||
|
||||
out1 = open("Task110Test.out.txt", 'r')
|
||||
out2 = open("Task110Test.dat.out.txt", 'r')
|
||||
|
||||
for line1 in out1:
|
||||
line2 = out2.readline()
|
||||
self.assertEqual( line1, line2 )
|
||||
|
||||
out1.close()
|
||||
out2.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
37
regexp/Task301Test.py
Executable file
37
regexp/Task301Test.py
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 301
|
||||
|
||||
Napisz funkcję `letter_and_two_digits(string)`, która sprawdza
|
||||
czy podany napis zawiera ciąg składający się z wielkiej litery
|
||||
i dwóch cyfr.
|
||||
|
||||
NAME: letter_and_two_digits
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task301 import letter_and_two_digits
|
||||
|
||||
class Task301Test(unittest.TestCase):
|
||||
"""Testy do zadania 301"""
|
||||
|
||||
def test_sequence(self):
|
||||
"""Prosty test."""
|
||||
self.assertTrue(letter_and_two_digits("hahaA39dsdsd"))
|
||||
self.assertTrue(letter_and_two_digits("G3923d"))
|
||||
self.assertTrue(letter_and_two_digits("Z00"))
|
||||
self.assertTrue(letter_and_two_digits("sssssssssssU23"))
|
||||
self.assertFalse(letter_and_two_digits("Z0x0"))
|
||||
self.assertFalse(letter_and_two_digits("dsdg34"))
|
||||
self.assertFalse(letter_and_two_digits("G9"))
|
||||
self.assertFalse(letter_and_two_digits("az33a"));
|
||||
self.assertFalse(letter_and_two_digits("Ha3a5"));
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
36
regexp/Task302Test.py
Executable file
36
regexp/Task302Test.py
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 302
|
||||
|
||||
Napisz funkcję `extract_minutes(string)`, która
|
||||
z podanego napisu reprezentującego godzinę
|
||||
w formacie typu "9:13", "18:44" wyciąga minuty.
|
||||
Funkcja powinna zwracać napis "<NONE>", jeśli podany
|
||||
napis nie jest godziną.
|
||||
|
||||
NAME: extract_minutes
|
||||
PARAMS: string
|
||||
RETURN: string
|
||||
POINTS: 4
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task302 import extract_minutes
|
||||
|
||||
class Task302Test(unittest.TestCase):
|
||||
"""Testy do zadania 302"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(extract_minutes("9:13"), "13")
|
||||
self.assertEqual(extract_minutes("18:44"), "44")
|
||||
self.assertEqual(extract_minutes("23:59"), "59")
|
||||
self.assertEqual(extract_minutes("0:00"), "00")
|
||||
self.assertEqual(extract_minutes("25:14"), "<NONE>")
|
||||
self.assertEqual(extract_minutes("9:61"), "<NONE>")
|
||||
self.assertEqual(extract_minutes("x9:13y"), "<NONE>")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task303Test.py
Executable file
39
regexp/Task303Test.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 303
|
||||
|
||||
Napisz funkcję `divisable_by_four(string)`, która
|
||||
sprawdza, czy podany napis reprezentuje liczbę nieujemną podzielną
|
||||
przez 4. Uwaga: cała "logika" rozwiązania powinna być zaszyta
|
||||
w wyrażeniu regularnym, w szczególności proszę nie używać operatora
|
||||
wyznaczania reszty.
|
||||
|
||||
NAME: divisable_by_four
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 3
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task303 import divisable_by_four
|
||||
|
||||
class Task303Test(unittest.TestCase):
|
||||
"""Testy do zadania 303"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertTrue(divisable_by_four("32"))
|
||||
self.assertFalse(divisable_by_four("33"))
|
||||
self.assertFalse(divisable_by_four("-32"))
|
||||
self.assertTrue(divisable_by_four("0"))
|
||||
|
||||
for num in range(45000, 47000):
|
||||
if num % 4 == 0:
|
||||
self.assertTrue(divisable_by_four(str(num)), str(num))
|
||||
else:
|
||||
self.assertFalse(divisable_by_four(str(num)), str(num))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
41
regexp/Task304Test.py
Executable file
41
regexp/Task304Test.py
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 304
|
||||
|
||||
Napisz funkcję `split_list(string)`, która która zwraca listę powstałą
|
||||
w wyniku podziału napisu. Separatorami mogą być przecinki otoczone
|
||||
opcjonalnymi spacjami bądź pojedyncze dwukropki.
|
||||
|
||||
|
||||
NAME: split_list
|
||||
PARAMS: string
|
||||
RETURN: list
|
||||
POINTS: 2
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from Task304 import split_list
|
||||
|
||||
class Task304Test(unittest.TestCase):
|
||||
"""Testy do zadania 304"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Prosty test."""
|
||||
self.assertEqual(
|
||||
split_list("foo, bar , sss:s"),
|
||||
['foo', 'bar', 'sss', 's'])
|
||||
|
||||
|
||||
self.assertEqual(
|
||||
split_list("foo"),
|
||||
['foo'])
|
||||
|
||||
self.assertEqual(
|
||||
split_list("bla : bla"),
|
||||
['bla ', ' bla'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
45
regexp/Task305Test.py
Executable file
45
regexp/Task305Test.py
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 305
|
||||
|
||||
Napisać funkcję divisable_by_two(string), która sprawdza, czy
|
||||
zadany napis reprezentuje nieujemną liczbę podzielną przez 2.
|
||||
Napis nie powinien zawierać zer nieznaczących.
|
||||
Uwaga: cała "logika" rozwiązania powinna być zaszyta
|
||||
w wyrażeniu regularnym, w szczególności proszę nie używać operatora
|
||||
wyznaczania reszty.
|
||||
|
||||
NAME: divisable_by_two
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task305 import divisable_by_two
|
||||
|
||||
class Task305Test(unittest.TestCase):
|
||||
"""Testy do zadania 305"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(divisable_by_two("222221"))
|
||||
self.assertFalse(divisable_by_two("3"))
|
||||
self.assertFalse(divisable_by_two("4 4"))
|
||||
self.assertFalse(divisable_by_two("04"))
|
||||
self.assertTrue(divisable_by_two("2"))
|
||||
self.assertTrue(divisable_by_two("222222"))
|
||||
self.assertFalse(divisable_by_two("1"))
|
||||
self.assertTrue(divisable_by_two("4"))
|
||||
self.assertFalse(divisable_by_two("0018"))
|
||||
self.assertFalse(divisable_by_two("-20"))
|
||||
self.assertTrue(divisable_by_two("88"))
|
||||
self.assertTrue(divisable_by_two("0"))
|
||||
self.assertTrue(divisable_by_two("16"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task306Test.py
Executable file
39
regexp/Task306Test.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 306
|
||||
|
||||
Napisać funkcję is_power_of_hundred(string), która sprawdza, czy
|
||||
zadany napis jest potęgą liczby 100.
|
||||
Uwaga: cała "logika" rozwiązania powinna być zaszyta
|
||||
w wyrażeniu regularnym.
|
||||
|
||||
NAME: is_power_of_hundred
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task306 import is_power_of_hundred
|
||||
|
||||
class Task306Test(unittest.TestCase):
|
||||
"""Testy do zadania 306"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_power_of_hundred("-100"))
|
||||
self.assertTrue(is_power_of_hundred("10000"))
|
||||
self.assertFalse(is_power_of_hundred("1001"))
|
||||
self.assertTrue(is_power_of_hundred("1"))
|
||||
self.assertTrue(is_power_of_hundred("1000000"))
|
||||
self.assertFalse(is_power_of_hundred("10"))
|
||||
self.assertFalse(is_power_of_hundred("2000"))
|
||||
self.assertFalse(is_power_of_hundred("500"))
|
||||
self.assertTrue(is_power_of_hundred("100"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
31
regexp/Task307Test.py
Executable file
31
regexp/Task307Test.py
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 307
|
||||
|
||||
Stworzyć funkcję `extract_phone_number(string_to_be_checked), która wydobywa z zadanego napisu numer telefonu. Zakładamy, że numer telefonu składa się z dwóch cyfr opcjonalnie poprzedzonych zerem, po których następuje spacja i 7 cyfr w formacie N-NNN-NNN. Jeśli zadany napis nie zawiera numeru telefonu, należy zwrócić "<NONE>".
|
||||
|
||||
NAME: is_phone_number
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task307 import extract_phone_number
|
||||
|
||||
class Task307Test(unittest.TestCase):
|
||||
"""Testy do zadania 307"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertEqual(extract_phone_number("bla 61 5-555-555xyz"), "61 5-555-555");
|
||||
self.assertEqual(extract_phone_number("bla 061 5-555-555xyz"), "061 5-555-555");
|
||||
self.assertEqual(extract_phone_number("bla 61 5-555-45xyz"), "<NONE>");
|
||||
self.assertEqual(extract_phone_number("bla 5-555-4555xyz"), "<NONE>");
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
41
regexp/Task308Test.py
Normal file
41
regexp/Task308Test.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 308
|
||||
|
||||
Napisać funkcję is_horse_head(string), która sprawdza, czy
|
||||
napis jest napisem złożonym z ciągu 5 wielkich liter i 4 wielkich
|
||||
liter oddzielonych spacją, które wstukane na standardowym telefonie
|
||||
dadzą taki sam numer jak przy wstukaniu napisu "HORSE HEAD".
|
||||
Zakładamy standardowe mapowanie liter na cyfry w telefonie ("ABC" -
|
||||
2, "DEF" - 3 itd.)
|
||||
|
||||
NAME: is_horse_head
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task308 import is_horse_head
|
||||
|
||||
class Task308Test(unittest.TestCase):
|
||||
"""Testy do zadania 308"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_horse_head("ZOSRE IDAD"))
|
||||
self.assertFalse(is_horse_head("morse head"))
|
||||
self.assertFalse(is_horse_head("MORSEHEAD"))
|
||||
self.assertFalse(is_horse_head("AAAAAA BBBB"))
|
||||
self.assertFalse(is_horse_head("MORSE HEAD"))
|
||||
self.assertTrue(is_horse_head("HORSE HEAD"))
|
||||
self.assertFalse(is_horse_head("AAAAA BBBB"))
|
||||
self.assertTrue(is_horse_head("GOSRE IDAD"))
|
||||
self.assertFalse(is_horse_head("0MORSE HEAD"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
42
regexp/Task309Test.py
Normal file
42
regexp/Task309Test.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 309
|
||||
|
||||
Napisać funkcję is_movie_number(string), która sprawdza, czy
|
||||
napis jest 9-cyfrowym numerem telefonu zapisanym w formacie
|
||||
"NNN-NNN-NNN" badź "NNN NNN NNN" zaczynającym sie od kombinacji
|
||||
"555".
|
||||
|
||||
NAME: is_movie_number
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task309 import is_movie_number
|
||||
|
||||
class Task309Test(unittest.TestCase):
|
||||
"""Testy do zadania 309"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_movie_number("555 000-000"))
|
||||
self.assertFalse(is_movie_number("556 345-667"))
|
||||
self.assertFalse(is_movie_number("556 345 6675"))
|
||||
self.assertFalse(is_movie_number("055-555-555"))
|
||||
self.assertTrue(is_movie_number("555 123 456"))
|
||||
self.assertFalse(is_movie_number("505-324-555"))
|
||||
self.assertTrue(is_movie_number("555-123-456"))
|
||||
self.assertFalse(is_movie_number("555-000 000"))
|
||||
self.assertTrue(is_movie_number("555 000 000"))
|
||||
self.assertTrue(is_movie_number("555-000-000"))
|
||||
self.assertFalse(is_movie_number("556 345 667"))
|
||||
self.assertFalse(is_movie_number("551-233-455"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
regexp/Task310Test.py
Normal file
40
regexp/Task310Test.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 310
|
||||
|
||||
Napisać funkcję is_football_result(string), która sprawdza, czy
|
||||
napis reprezentuje wynik meczu piłkarskiego (dwie liczby oddzielone
|
||||
dwukropkiem). Maksymalna liczba bramek wynosi 10.
|
||||
|
||||
NAME: is_football_result
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task310 import is_football_result
|
||||
|
||||
class Task310Test(unittest.TestCase):
|
||||
"""Testy do zadania 310"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_football_result("3"))
|
||||
self.assertTrue(is_football_result("10:10"))
|
||||
self.assertTrue(is_football_result("5:2"))
|
||||
self.assertFalse(is_football_result("11:2"))
|
||||
self.assertFalse(is_football_result("5-5"))
|
||||
self.assertTrue(is_football_result("2:1"))
|
||||
self.assertTrue(is_football_result("5:5"))
|
||||
self.assertFalse(is_football_result(":3"))
|
||||
self.assertFalse(is_football_result("3:101"))
|
||||
self.assertFalse(is_football_result("xxxx"))
|
||||
self.assertTrue(is_football_result("0:7"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
34
regexp/Task311Test.py
Normal file
34
regexp/Task311Test.py
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 311
|
||||
|
||||
Napisać funkcję is_nip_number(string), która sprawdza, czy
|
||||
napis jest numerem NIP zapisanym w formacie xxx-xxx-xx-xx bądź
|
||||
xxx-xx-xx-xxx. Nie trzeba brać pod uwagę sumy kontrolnej.
|
||||
|
||||
NAME: is_nip_number
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task311 import is_nip_number
|
||||
|
||||
class Task311Test(unittest.TestCase):
|
||||
"""Testy do zadania 311"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_nip_number("3454551234"))
|
||||
self.assertTrue(is_nip_number("000-00-00-000"))
|
||||
self.assertTrue(is_nip_number("345-45-12-334"))
|
||||
self.assertFalse(is_nip_number("345-455-12-349"))
|
||||
self.assertTrue(is_nip_number("345-455-12-34"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
regexp/Task312Test.py
Normal file
40
regexp/Task312Test.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 312
|
||||
|
||||
Napisać funkcję is_pin_code(string), która sprawdza, czy
|
||||
napis jest 4-cyfrowym kodem PIN, przy czym zakładamy, że kod PIN
|
||||
nie może składać się z samych zer.
|
||||
|
||||
NAME: is_pin_code
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task312 import is_pin_code
|
||||
|
||||
class Task312Test(unittest.TestCase):
|
||||
"""Testy do zadania 312"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_pin_code("7787"))
|
||||
self.assertTrue(is_pin_code("8888"))
|
||||
self.assertTrue(is_pin_code("5034"))
|
||||
self.assertFalse(is_pin_code("WTF"))
|
||||
self.assertTrue(is_pin_code("1112"))
|
||||
self.assertTrue(is_pin_code("0123"))
|
||||
self.assertTrue(is_pin_code("1111"))
|
||||
self.assertTrue(is_pin_code("0300"))
|
||||
self.assertFalse(is_pin_code("0000"))
|
||||
self.assertFalse(is_pin_code("12345"))
|
||||
self.assertTrue(is_pin_code("4655"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
43
regexp/Task313Test.py
Normal file
43
regexp/Task313Test.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 313
|
||||
|
||||
Napisać funkcję is_human_age(string), która sprawdza, czy
|
||||
napis reprezentuje wiek człowieka, tzn. jest postaci typu "45 lat".
|
||||
Maksymalny wiek - 99 lat.
|
||||
|
||||
NAME: is_human_age
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task313 import is_human_age
|
||||
|
||||
class Task313Test(unittest.TestCase):
|
||||
"""Testy do zadania 313"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_human_age("12 lata"))
|
||||
self.assertTrue(is_human_age("99 lat"))
|
||||
self.assertTrue(is_human_age("5 lat"))
|
||||
self.assertTrue(is_human_age("1 rok"))
|
||||
self.assertTrue(is_human_age("44 lata"))
|
||||
self.assertTrue(is_human_age("11 lat"))
|
||||
self.assertTrue(is_human_age("22 lata"))
|
||||
self.assertTrue(is_human_age("4 lata"))
|
||||
self.assertFalse(is_human_age("100 lat"))
|
||||
self.assertFalse(is_human_age("112 lat"))
|
||||
self.assertFalse(is_human_age("22 lat"))
|
||||
self.assertTrue(is_human_age("2 lata"))
|
||||
self.assertTrue(is_human_age("3 lata"))
|
||||
self.assertTrue(is_human_age("12 lat"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task314Test.py
Normal file
39
regexp/Task314Test.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 314
|
||||
|
||||
Napisać funkcję is_male(string), która sprawdza, czy
|
||||
napis reprezentuje imię i nazwisko mężczyzny. Imię i nazwisko to
|
||||
przynajmniej dwuliterowy napis zaczynający się wielką literą, po
|
||||
której następują małe litery. Dodatkowo imię nie może kończyć
|
||||
się na "a".
|
||||
|
||||
NAME: is_male
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task314 import is_male
|
||||
|
||||
class Task314Test(unittest.TestCase):
|
||||
"""Testy do zadania 314"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_male("Joanna Kowalska"))
|
||||
self.assertTrue(is_male("Oo Oo"))
|
||||
self.assertTrue(is_male("Atanazy Bazakbal"))
|
||||
self.assertTrue(is_male("Ai Oi"))
|
||||
self.assertTrue(is_male("Ax Aa"))
|
||||
self.assertFalse(is_male("Aa Ax"))
|
||||
self.assertTrue(is_male("Kim Bo"))
|
||||
self.assertTrue(is_male("Jan Maska"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
regexp/Task315Test.py
Executable file
40
regexp/Task315Test.py
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 315
|
||||
|
||||
Napisać funkcję is_female(string), która sprawdza, czy
|
||||
napis reprezentuje imię i nazwisko kobiety. Imię i nazwisko to
|
||||
przynajmniej dwuliterowy napis zaczynający się wielką literą, po
|
||||
której następują małe litery. Dodatkowo imię musi kończyć się
|
||||
na "a".
|
||||
|
||||
NAME: is_female
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task315 import is_female
|
||||
|
||||
class Task315Test(unittest.TestCase):
|
||||
"""Testy do zadania 315"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_female("Joanna Kowalska"))
|
||||
self.assertFalse(is_female("Ai Oi"))
|
||||
self.assertTrue(is_female("Aa Ax"))
|
||||
self.assertFalse(is_female("Kim Bo"))
|
||||
self.assertFalse(is_female("Jan Maska"))
|
||||
self.assertFalse(is_female("Oo Oo"))
|
||||
self.assertTrue(is_female("Za Mysz"))
|
||||
self.assertFalse(is_female("Atanazy Bazakbal"))
|
||||
self.assertFalse(is_female("Ax Aa"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task316Test.py
Normal file
39
regexp/Task316Test.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 316
|
||||
|
||||
Napisać funkcję is_acronym(string), która sprawdza, czy
|
||||
napis jest akronimem (ciągiem co najmniej dwóch i co najwyżej
|
||||
pięciu wielkich liter. Dodatkowo należy uwzględnić akronim
|
||||
"PCMCIA".
|
||||
|
||||
NAME: is_acronym
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task316 import is_acronym
|
||||
|
||||
class Task316Test(unittest.TestCase):
|
||||
"""Testy do zadania 316"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_acronym("ATX"))
|
||||
self.assertFalse(is_acronym("AAAAAA"))
|
||||
self.assertFalse(is_acronym("P"))
|
||||
self.assertTrue(is_acronym("ABCDE"))
|
||||
self.assertFalse(is_acronym("Pc"))
|
||||
self.assertTrue(is_acronym("PC"))
|
||||
self.assertTrue(is_acronym("PCMCIA"))
|
||||
self.assertTrue(is_acronym("ZZZZ"))
|
||||
self.assertFalse(is_acronym("PCMCIB"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
41
regexp/Task317Test.py
Normal file
41
regexp/Task317Test.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 317
|
||||
|
||||
Napisać funkcję is_integer(string), która sprawdza, czy
|
||||
napis reprezentuje liczbę całkowitą. Liczba nie powinna zawierać
|
||||
zer nieznaczących. Liczby dodatnie mogą opcjonalnie zaczynać się
|
||||
plusem.
|
||||
|
||||
NAME: is_integer
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task317 import is_integer
|
||||
|
||||
class Task317Test(unittest.TestCase):
|
||||
"""Testy do zadania 317"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_integer("+5"))
|
||||
self.assertTrue(is_integer("-5"))
|
||||
self.assertTrue(is_integer("3434343435"))
|
||||
self.assertFalse(is_integer("-0"))
|
||||
self.assertTrue(is_integer("0"))
|
||||
self.assertFalse(is_integer("03434343435"))
|
||||
self.assertFalse(is_integer("+0"))
|
||||
self.assertFalse(is_integer("06"))
|
||||
self.assertTrue(is_integer("100"))
|
||||
self.assertTrue(is_integer("5"))
|
||||
self.assertTrue(is_integer("-11110"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task318Test.py
Normal file
39
regexp/Task318Test.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 318
|
||||
|
||||
Napisać funkcję is_five_six_digit(string), która sprawdza, czy
|
||||
napis reprezentuje liczbę pięcio- bądź sześciocyfrową. Liczba
|
||||
nie powinna zawierać zer nieznaczących.
|
||||
|
||||
NAME: is_five_six_digit
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task318 import is_five_six_digit
|
||||
|
||||
class Task318Test(unittest.TestCase):
|
||||
"""Testy do zadania 318"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_five_six_digit("0123456"))
|
||||
self.assertTrue(is_five_six_digit("123456"))
|
||||
self.assertTrue(is_five_six_digit("100001"))
|
||||
self.assertTrue(is_five_six_digit("10000"))
|
||||
self.assertTrue(is_five_six_digit("99999"))
|
||||
self.assertFalse(is_five_six_digit("333333333333"))
|
||||
self.assertFalse(is_five_six_digit("012345"))
|
||||
self.assertTrue(is_five_six_digit("999999"))
|
||||
self.assertTrue(is_five_six_digit("12345"))
|
||||
self.assertFalse(is_five_six_digit("9999"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
41
regexp/Task319Test.py
Normal file
41
regexp/Task319Test.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 319
|
||||
|
||||
Napisać funkcję less_than(string), która sprawdza, czy
|
||||
napis reprezentuje liczbę całkowitą nieujemną mniejszą niż 143.
|
||||
Liczba nie powinna zawierać zer nieznaczących.
|
||||
|
||||
NAME: less_than
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task319 import less_than
|
||||
|
||||
class Task319Test(unittest.TestCase):
|
||||
"""Testy do zadania 319"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(less_than("098"))
|
||||
self.assertFalse(less_than("05"))
|
||||
self.assertTrue(less_than("142"))
|
||||
self.assertTrue(less_than("139"))
|
||||
self.assertTrue(less_than("78"))
|
||||
self.assertFalse(less_than("143"))
|
||||
self.assertTrue(less_than("103"))
|
||||
self.assertTrue(less_than("99"))
|
||||
self.assertTrue(less_than("0"))
|
||||
self.assertFalse(less_than("1000"))
|
||||
self.assertFalse(less_than("-1"))
|
||||
self.assertTrue(less_than("5"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task320Test.py
Normal file
39
regexp/Task320Test.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 320
|
||||
|
||||
Napisać funkcję is_domain_name(string), która sprawdza, czy
|
||||
napis reprezentuje nazwę domenową. Zakładamy, że nazwa domenowa
|
||||
składa się z 2 lub 3 członów oddzielonych kropkami. Każdy człon
|
||||
to ciąg małych liter.
|
||||
|
||||
NAME: is_domain_name
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task320 import is_domain_name
|
||||
|
||||
class Task320Test(unittest.TestCase):
|
||||
"""Testy do zadania 320"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_domain_name("www.haha.bla.pl"))
|
||||
self.assertTrue(is_domain_name("foo.tv"))
|
||||
self.assertTrue(is_domain_name("bla.pl"))
|
||||
self.assertFalse(is_domain_name("bla1.pl"))
|
||||
self.assertTrue(is_domain_name("www.bla.pl"))
|
||||
self.assertFalse(is_domain_name("foo..tv"))
|
||||
self.assertTrue(is_domain_name("z.z"))
|
||||
self.assertTrue(is_domain_name("x.y.z"))
|
||||
self.assertFalse(is_domain_name("foo.pl."))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
43
regexp/Task321Test.py
Normal file
43
regexp/Task321Test.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 321
|
||||
|
||||
Napisać funkcję is_identifier(string), która sprawdza, czy
|
||||
napis jest identyfikatorem (ciągiem liter, cyfr i podkreślników
|
||||
nie zaczynających się cyfrą).
|
||||
|
||||
NAME: is_identifier
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task321 import is_identifier
|
||||
|
||||
class Task321Test(unittest.TestCase):
|
||||
"""Testy do zadania 321"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_identifier("Gitorah"))
|
||||
self.assertTrue(is_identifier("z0000000"))
|
||||
self.assertTrue(is_identifier("_____"))
|
||||
self.assertTrue(is_identifier("godzilla"))
|
||||
self.assertTrue(is_identifier("x"))
|
||||
self.assertFalse(is_identifier("2"))
|
||||
self.assertFalse(is_identifier("bla-bla"))
|
||||
self.assertFalse(is_identifier("2_"))
|
||||
self.assertFalse(is_identifier(";zmienna"))
|
||||
self.assertFalse(is_identifier("zmienna$"))
|
||||
self.assertFalse(is_identifier("90876z"))
|
||||
self.assertTrue(is_identifier("_2"))
|
||||
self.assertTrue(is_identifier("_a_"))
|
||||
self.assertTrue(is_identifier("blo_34a"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
regexp/Task322Test.py
Normal file
40
regexp/Task322Test.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 322
|
||||
|
||||
Napisać funkcję is_temperature(string), która sprawdza, czy
|
||||
napis jest liczbą całkowitą zakresu od -49 do 49. Liczba nie
|
||||
powinna zawierać zer nieznaczących.
|
||||
|
||||
NAME: is_temperature
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task322 import is_temperature
|
||||
|
||||
class Task322Test(unittest.TestCase):
|
||||
"""Testy do zadania 322"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_temperature("50"))
|
||||
self.assertTrue(is_temperature("-50"))
|
||||
self.assertTrue(is_temperature("-9"))
|
||||
self.assertFalse(is_temperature("7"))
|
||||
self.assertFalse(is_temperature("-200"))
|
||||
self.assertTrue(is_temperature("-21"))
|
||||
self.assertTrue(is_temperature("18"))
|
||||
self.assertTrue(is_temperature("0"))
|
||||
self.assertTrue(is_temperature("49"))
|
||||
self.assertFalse(is_temperature("100"))
|
||||
self.assertTrue(is_temperature("-49"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
35
regexp/Task323Test.py
Normal file
35
regexp/Task323Test.py
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 323
|
||||
|
||||
Napisać funkcję are_stars(string), która sprawdza, czy
|
||||
napis składa się z samych gwiazdek (co najmniej jednej).
|
||||
|
||||
NAME: are_stars
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task323 import are_stars
|
||||
|
||||
class Task323Test(unittest.TestCase):
|
||||
"""Testy do zadania 323"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(are_stars("*a"))
|
||||
self.assertTrue(are_stars("***********"))
|
||||
self.assertTrue(are_stars("**"))
|
||||
self.assertFalse(are_stars("a*"))
|
||||
self.assertTrue(are_stars("*"))
|
||||
self.assertFalse(are_stars("+"))
|
||||
self.assertTrue(are_stars("***"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
38
regexp/Task324Test.py
Normal file
38
regexp/Task324Test.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 324
|
||||
|
||||
Napisać funkcję is_one_vowel(string), która sprawdza, czy
|
||||
napis jest wyrazem zawierającym dokładnie jedną samogłoskę.
|
||||
Należy uwzględnić małe litery alfabetu łacińskiego.
|
||||
|
||||
NAME: is_one_vowel
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task324 import is_one_vowel
|
||||
|
||||
class Task324Test(unittest.TestCase):
|
||||
"""Testy do zadania 324"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_one_vowel("dom"))
|
||||
self.assertFalse(is_one_vowel("puko"))
|
||||
self.assertTrue(is_one_vowel("u"))
|
||||
self.assertFalse(is_one_vowel("ostrach"))
|
||||
self.assertFalse(is_one_vowel("html"))
|
||||
self.assertTrue(is_one_vowel("strach"))
|
||||
self.assertFalse(is_one_vowel("strachy"))
|
||||
self.assertFalse(is_one_vowel("aa"))
|
||||
self.assertFalse(is_one_vowel("223"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
37
regexp/Task325Test.py
Normal file
37
regexp/Task325Test.py
Normal file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 325
|
||||
|
||||
Napisać funkcję is_dollar_sum(string), która sprawdza, czy
|
||||
napis wyraża sumę w dolarach, tj. zaczyna się znakiem dolara, po
|
||||
którym następuje liczba dodatnia (bez zer nieznaczących).
|
||||
|
||||
NAME: is_dollar_sum
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task325 import is_dollar_sum
|
||||
|
||||
class Task325Test(unittest.TestCase):
|
||||
"""Testy do zadania 325"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_dollar_sum("$"))
|
||||
self.assertTrue(is_dollar_sum("$1"))
|
||||
self.assertTrue(is_dollar_sum("$100"))
|
||||
self.assertFalse(is_dollar_sum("10$100"))
|
||||
self.assertFalse(is_dollar_sum("89"))
|
||||
self.assertFalse(is_dollar_sum("$0098"))
|
||||
self.assertTrue(is_dollar_sum("$67592234"))
|
||||
self.assertTrue(is_dollar_sum("$89"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
40
regexp/Task326Test.py
Normal file
40
regexp/Task326Test.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 326
|
||||
|
||||
Napisać funkcję is_dna(string), która sprawdza, czy
|
||||
napis jest niepustym ciągiem liter A, G, C, T, U, przy czym w jednym
|
||||
ciągu może wystąpić albo T, albo U nie obie litery
|
||||
równocześnie.
|
||||
|
||||
NAME: is_dna
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task326 import is_dna
|
||||
|
||||
class Task326Test(unittest.TestCase):
|
||||
"""Testy do zadania 326"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_dna("UAT"))
|
||||
self.assertTrue(is_dna("AGCUUGGAAACU"))
|
||||
self.assertTrue(is_dna("AGCTTGGAAACT"))
|
||||
self.assertFalse(is_dna("89"))
|
||||
self.assertTrue(is_dna("AAAAA"))
|
||||
self.assertFalse(is_dna("aaa"))
|
||||
self.assertFalse(is_dna("TAU"))
|
||||
self.assertTrue(is_dna("G"))
|
||||
self.assertTrue(is_dna("UAU"))
|
||||
self.assertTrue(is_dna("TAT"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
39
regexp/Task327Test.py
Normal file
39
regexp/Task327Test.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 327
|
||||
|
||||
Napisać funkcję is_giggle(string), która sprawdza, czy
|
||||
napis jest chichotem tzn. "hi" powtórzonym przynajmniej 2 razy, po
|
||||
czym następuje opcjonalny ciąg wykrzykników.
|
||||
|
||||
NAME: is_giggle
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task327 import is_giggle
|
||||
|
||||
class Task327Test(unittest.TestCase):
|
||||
"""Testy do zadania 327"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_giggle("hi"))
|
||||
self.assertFalse(is_giggle("ih!"))
|
||||
self.assertTrue(is_giggle("hihi!!!!!!!!!"))
|
||||
self.assertTrue(is_giggle("hihihihihihihihi"))
|
||||
self.assertTrue(is_giggle("hihi"))
|
||||
self.assertFalse(is_giggle("!!!!!"))
|
||||
self.assertTrue(is_giggle("hihihi"))
|
||||
self.assertFalse(is_giggle("hi!!!"))
|
||||
self.assertFalse(is_giggle("!hi"))
|
||||
self.assertTrue(is_giggle("hihihi!"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
41
regexp/Task328Test.py
Normal file
41
regexp/Task328Test.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 328
|
||||
|
||||
Napisać funkcję is_hmmmm(string), która sprawdza, czy
|
||||
napis to "hmmm....." - 'm' występuje 2 lub więcej razy, kropki są
|
||||
opcjonalne, ale jeśli występują muszą wystąpić przynajmniej 3
|
||||
razy.
|
||||
|
||||
NAME: is_hmmmm
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task328 import is_hmmmm
|
||||
|
||||
class Task328Test(unittest.TestCase):
|
||||
"""Testy do zadania 328"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertTrue(is_hmmmm("hmm..."))
|
||||
self.assertFalse(is_hmmmm("hmmmm.....?!"))
|
||||
self.assertFalse(is_hmmmm("ahmmmm....."))
|
||||
self.assertFalse(is_hmmmm("hhmmm....."))
|
||||
self.assertFalse(is_hmmmm("hm....."))
|
||||
self.assertFalse(is_hmmmm("mmm...."))
|
||||
self.assertFalse(is_hmmmm("hmmm.."))
|
||||
self.assertTrue(is_hmmmm("hmmmm......"))
|
||||
self.assertFalse(is_hmmmm("hmmm."))
|
||||
self.assertTrue(is_hmmmm("hmm"))
|
||||
self.assertTrue(is_hmmmm("hmmm...."))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
38
regexp/Task329Test.py
Normal file
38
regexp/Task329Test.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Zadanie 329
|
||||
|
||||
Napisać funkcję is_singing(string), która sprawdza, czy
|
||||
napis jest śpiewem, tj. jest ciągiem sylab "li", "la", "lo" (co
|
||||
najmniej dwóch), po którym następuje opcjonalny ciąg
|
||||
wykrzykników.
|
||||
|
||||
NAME: is_singing
|
||||
PARAMS: string
|
||||
RETURN: bool
|
||||
POINTS: 9
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Task329 import is_singing
|
||||
|
||||
class Task329Test(unittest.TestCase):
|
||||
"""Testy do zadania 329"""
|
||||
|
||||
def test_simple(self):
|
||||
"""Podstawowy test."""
|
||||
|
||||
self.assertFalse(is_singing("!!lala!!"))
|
||||
self.assertFalse(is_singing("lol"))
|
||||
self.assertFalse(is_singing("ola!"))
|
||||
self.assertFalse(is_singing("luli"))
|
||||
self.assertTrue(is_singing("lilala!!!"))
|
||||
self.assertTrue(is_singing("lololali!"))
|
||||
self.assertTrue(is_singing("lilili!!!!"))
|
||||
self.assertTrue(is_singing("lala"))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
273
run.sh
Executable file
273
run.sh
Executable file
@ -0,0 +1,273 @@
|
||||
#!/bin/zsh
|
||||
|
||||
. ./vars
|
||||
|
||||
PREFIX="$1"
|
||||
OPTION="$2"
|
||||
TASKS_DONE=0
|
||||
POINTS_AWARDED=0
|
||||
|
||||
LOGFILE=`pwd`/log.all.txt
|
||||
echo '' > "$LOGFILE"
|
||||
|
||||
typeset -A POINTS_PER_CLASSES
|
||||
|
||||
if [[ -e /usr/bin/pylint2 ]]
|
||||
then
|
||||
PYLINT_EXEC=pylint2
|
||||
else
|
||||
PYLINT_EXEC=pylint
|
||||
fi
|
||||
|
||||
run_pylint()
|
||||
{
|
||||
T=$1
|
||||
DIR=$2
|
||||
UNWANTED=$3
|
||||
|
||||
#pylint --disable=R0904,"$UNWANTED" $T ${T/%Test.py/.py} -f parseable | perl -pne "s{^Task}{${PREFIX}${DIR}/Task}" >> $PYLINT_LOG
|
||||
$PYLINT_EXEC --disable=R0904,C0111,"$UNWANTED" ${T/%Test.py/.py} -f parseable | perl -pne "s{^Task}{${PREFIX}${DIR}/Task}" >> $PYLINT_LOG
|
||||
PYLINT_EXIT_CODE=${pipestatus[1]}
|
||||
}
|
||||
|
||||
run_pylint_single_file()
|
||||
{
|
||||
T=$1
|
||||
DIR=$2
|
||||
UNWANTED=$3
|
||||
|
||||
$PYLINT_EXEC --disable=R0904,C0111,"$UNWANTED" $T -f parseable | perl -pne "s{^}{${PREFIX}${DIR}/}" >> $PYLINT_LOG
|
||||
PYLINT_EXIT_CODE=${pipestatus[1]}
|
||||
}
|
||||
|
||||
process_test()
|
||||
{
|
||||
SOLUTION=${1/%Test.py/.py}
|
||||
if [[ -r $SOLUTION ]]
|
||||
then
|
||||
echo "RUNNING $1"
|
||||
|
||||
JUST_NUMBER=${1/%Test.py/}
|
||||
JUST_NUMBER=${JUST_NUMBER/#Task/}
|
||||
|
||||
TASK_KEY="${STUDENT_NUMBER}_${JUST_NUMBER}"
|
||||
|
||||
WAS_OVERRIDDEN=no
|
||||
|
||||
if [[ $OVERRIDDEN_POINTS[$TASK_KEY] != "" ]]
|
||||
then
|
||||
echo "from overridden.txt: $OVERRIDDEN_POINTS[$TASK_KEY]"
|
||||
SUCCESS=yes
|
||||
WAS_OVERRIDDEN=yes
|
||||
MSS="READ FROM FILE overridden.txt "
|
||||
else
|
||||
XML_FILE=${1/%.py/.xml}
|
||||
nosetests2 --with-xunit --xunit-file="$XML_FILE" $1
|
||||
TESTS_OK=$?
|
||||
|
||||
run_pylint $1 $2
|
||||
PYLINT_OK=$PYLINT_EXIT_CODE
|
||||
|
||||
SUCCESS=yes
|
||||
|
||||
if [[ "$TESTS_OK" == "0" ]]
|
||||
then
|
||||
MSS="TESTS OK"
|
||||
else
|
||||
MSS="TESTS FAILED"
|
||||
SUCCESS=no
|
||||
fi
|
||||
|
||||
if [[ "$PYLINT_OK" == "0" ]]
|
||||
then
|
||||
MSS="$MSS PYLINT OK"
|
||||
else
|
||||
MSS="$MSS PYLINT FAILED"
|
||||
# SUCCESS=no
|
||||
fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 205 && "$JUST_NUMBER" -le 219 ]]
|
||||
then
|
||||
if [[ `expr $JUST_NUMBER % 15` != `expr $STUDENT_NUMBER % 15` ]]
|
||||
then
|
||||
MSS="$MSS ZLA RESZTA Z DZIELENIA!"
|
||||
SUCCESS=no
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 305 && "$JUST_NUMBER" -le 329 ]]
|
||||
then
|
||||
if [[ `expr $JUST_NUMBER % 25` != `expr $STUDENT_NUMBER % 25` ]]
|
||||
then
|
||||
MSS="$MSS ZLA RESZTA Z DZIELENIA!"
|
||||
SUCCESS=no
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
CLASSES=$SOLUTION[-6]
|
||||
echo "task belongs to classes $CLASSES"
|
||||
CLASSES_TIME_LIMIT=$TIME_LIMITS[$CLASSES]
|
||||
echo "classes time limit is $CLASSES_TIME_LIMIT"
|
||||
HOME_TIME_LIMIT=$HOME_TIME_LIMITS[$CLASSES]
|
||||
echo "home time limit is $HOME_TIME_LIMIT"
|
||||
HOME_POINT_LIMIT=$HOME_POINT_LIMITS[$CLASSES]
|
||||
echo "home point limit is $HOME_POINT_LIMIT"
|
||||
|
||||
LAST_COMMIT_DATE=`git log -1 --format=%cd --date=iso $SOLUTION`
|
||||
echo "last commit to solution is $LAST_COMMIT_DATE"
|
||||
|
||||
AT_HOME="no"
|
||||
TASK_POINTS_FOR_HOME=0
|
||||
|
||||
if [[ "$WAS_OVERRIDDEN" == "no" && "$CLASSES_TIME_LIMIT" < "$LAST_COMMIT_DATE" ]]
|
||||
then
|
||||
if [[ "$HOME_TIME_LIMIT" < "$LAST_COMMIT_DATE" ]]
|
||||
then
|
||||
MSS="$MSS TOO LATE"
|
||||
SUCCESS="no"
|
||||
echo "solved too late!"
|
||||
else
|
||||
MSS="$MSS DONE AT HOME"
|
||||
|
||||
if [[ "$SUCCESS" == "yes" ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=1
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 205 && "$JUST_NUMBER" -le 219 ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=6
|
||||
fi
|
||||
|
||||
if [[ "$JUST_NUMBER" -gt 305 && "$JUST_NUMBER" -le 329 ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=4
|
||||
fi
|
||||
|
||||
HPPC=$HOME_POINTS_PER_CLASSES[$CLASSES]
|
||||
HPPC=`expr $HPPC + $TASK_POINTS_FOR_HOME`
|
||||
|
||||
HOME_POINT_LIMIT=$HOME_POINT_LIMITS[$CLASSES]
|
||||
|
||||
if [[ $HPPC -gt $HOME_POINT_LIMIT ]]
|
||||
then
|
||||
TASK_POINTS_FOR_HOME=`expr $HOME_POINT_LIMIT - $HOME_POINTS_PER_CLASSES[$CLASSES]`
|
||||
HPPC=$HOME_POINT_LIMIT
|
||||
MSS="$MSS HOME LIMIT EXCEEDED, AWARDING: $TASK_POINTS_FOR_HOME points"
|
||||
fi
|
||||
|
||||
MSS="$MSS HOME POINTS: $TASK_POINTS_FOR_HOME"
|
||||
|
||||
HPOINTS_PER_CLASSES[$CLASSES]=$HPPC
|
||||
fi
|
||||
|
||||
AT_HOME="yes"
|
||||
echo "solved at home!"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$SUCCESS" == "yes" ]]
|
||||
then
|
||||
TASKS_DONE=`expr $TASKS_DONE + 1`
|
||||
TASK_POINTS=`cat $1 | perl -ne 'print "\$1\n" if /^POINTS:\s*(\d+)/'`
|
||||
|
||||
if [[ "$AT_HOME" == "yes" ]]
|
||||
then
|
||||
TASK_POINTS=$TASK_POINTS_FOR_HOME
|
||||
fi
|
||||
|
||||
if [[ $OVERRIDDEN_POINTS[$TASK_KEY] != "" ]]
|
||||
then
|
||||
TASK_POINTS=$OVERRIDDEN_POINTS[$TASK_KEY]
|
||||
fi
|
||||
|
||||
MSS="$MSS POINTS: $TASK_POINTS"
|
||||
|
||||
PPC=$POINTS_PER_CLASSES[$CLASSES]
|
||||
PPC=`expr $PPC + $TASK_POINTS`
|
||||
|
||||
POINT_LIMIT=$DEFAULT_POINT_LIMIT
|
||||
|
||||
if [[ $POINT_LIMITS[$CLASSES] != "" ]]
|
||||
then
|
||||
POINT_LIMIT=$POINT_LIMITS[$CLASSES]
|
||||
fi
|
||||
|
||||
if [[ $PPC -gt $POINT_LIMIT ]]
|
||||
then
|
||||
TASK_POINTS=`expr $POINT_LIMIT - $POINTS_PER_CLASSES[$CLASSES]`
|
||||
PPC=$POINT_LIMIT
|
||||
MSS="$MSS LIMIT EXCEEDED, AWARDING: $TASK_POINTS points"
|
||||
fi
|
||||
|
||||
echo "$MSS $TASK_POINTS" >> "$LOGFILE"
|
||||
|
||||
POINTS_PER_CLASSES[$CLASSES]=$PPC
|
||||
|
||||
POINTS_AWARDED=`expr $POINTS_AWARDED + $TASK_POINTS`
|
||||
fi
|
||||
|
||||
SUMMARY="${SUMMARY}\n$1 $MSS"
|
||||
|
||||
else
|
||||
if [[ "$OPTION" == "fullcheck" ]]
|
||||
then
|
||||
# TODO fix duplication problem
|
||||
run_pylint $1 $2 "F0401,E0602,F0001"
|
||||
fi
|
||||
echo "SKIPPING $1"
|
||||
SUMMARY="${SUMMARY}\n$1 NO SOLUTION"
|
||||
fi
|
||||
}
|
||||
|
||||
process_directory()
|
||||
{
|
||||
echo "=============================="
|
||||
echo "GOING INTO $1"
|
||||
|
||||
pushd $1
|
||||
|
||||
for T in Task*Test.py
|
||||
do
|
||||
process_test $T $1
|
||||
done
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
read_overrides()
|
||||
{
|
||||
perl -pne 's/\s*\#.*//' < overrides.txt | while read INDEX_NUMBER TASK_CODE POINTS;
|
||||
do
|
||||
TASK_KEY="${INDEX_NUMBER}_${TASK_CODE}"
|
||||
OVERRIDDEN_POINTS[$TASK_KEY]=$POINTS
|
||||
done
|
||||
}
|
||||
|
||||
STUDENT_NUMBER=`pwd | perl -ne 'print "$1" if /${PREFIX}-s(\d+)/'`
|
||||
echo "STUDENT INDEX NUMBER IS: $STUDENT_NUMBER"
|
||||
|
||||
typeset -A OVERRIDDEN_POINTS
|
||||
read_overrides
|
||||
|
||||
PYLINT_LOG=`pwd`/pylint.log
|
||||
rm -f "$PYLINT_LOG"
|
||||
|
||||
for D in *(/)
|
||||
do
|
||||
process_directory $D
|
||||
done
|
||||
|
||||
echo "==============================================="
|
||||
echo "SUMMARY"
|
||||
echo $SUMMARY
|
||||
|
||||
echo ""
|
||||
echo "TASKS DONE: $TASKS_DONE"
|
||||
echo "POINTS: $POINTS_AWARDED"
|
||||
|
||||
echo "points" > result.csv
|
||||
echo $POINTS_AWARDED >> result.csv
|
||||
|
||||
perl -pne 's{^zaut-2019}{arena/}' -i pylint.log
|
20
show-solutions.sh
Executable file
20
show-solutions.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/zsh
|
||||
|
||||
PREFIX=$1
|
||||
TASK=$2
|
||||
|
||||
for REPO in $PREFIX-s*
|
||||
do
|
||||
INDEX=${REPO#$PREFIX-s}
|
||||
|
||||
SOLUTION_FILE="${REPO}/${TASK}.py"
|
||||
|
||||
if [[ -r "$SOLUTION_FILE" ]]
|
||||
then
|
||||
echo "========================================"
|
||||
echo "======== $INDEX ========================"
|
||||
cat "$SOLUTION_FILE"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
done
|
23
vars
Normal file
23
vars
Normal file
@ -0,0 +1,23 @@
|
||||
PREFIX=zjfz-2019
|
||||
|
||||
DEFAULT_POINT_LIMIT=15
|
||||
POINT_LIMIT=15
|
||||
|
||||
typeset -A TIME_LIMITS
|
||||
set -A TIME_LIMITS \
|
||||
"1" "2020-01-12 16:00:00 +0100" \
|
||||
"2" "2020-01-25 10:45:00 +0100" \
|
||||
"3" "2020-01-31 23:59:59 +0100"
|
||||
|
||||
typeset -A HOME_TIME_LIMITS
|
||||
set -A HOME_TIME_LIMITS \
|
||||
"1" "2020-01-25 10:45:00 +0100" \
|
||||
"2" "2020-01-25 10:45:00 +0100" \
|
||||
"3" "2020-01-31 23:59:59 +0100"
|
||||
|
||||
|
||||
typeset -A HOME_POINT_LIMITS
|
||||
set -A HOME_POINT_LIMITS \
|
||||
"1" "4" \
|
||||
"2" "0" \
|
||||
"3" "0"
|
Loading…
Reference in New Issue
Block a user