summaryrefslogtreecommitdiff
path: root/python/problems/functions_and_modules
diff options
context:
space:
mode:
Diffstat (limited to 'python/problems/functions_and_modules')
-rw-r--r--python/problems/functions_and_modules/all/common.py47
-rw-r--r--python/problems/functions_and_modules/all/en.py16
-rw-r--r--python/problems/functions_and_modules/all/sl.py40
-rw-r--r--python/problems/functions_and_modules/any/common.py47
-rw-r--r--python/problems/functions_and_modules/any/en.py16
-rw-r--r--python/problems/functions_and_modules/any/sl.py34
-rw-r--r--python/problems/functions_and_modules/caesar_cipher/common.py52
-rw-r--r--python/problems/functions_and_modules/caesar_cipher/en.py16
-rw-r--r--python/problems/functions_and_modules/caesar_cipher/sl.py35
-rw-r--r--python/problems/functions_and_modules/dominoes/common.py47
-rw-r--r--python/problems/functions_and_modules/dominoes/en.py16
-rw-r--r--python/problems/functions_and_modules/dominoes/sl.py29
-rw-r--r--python/problems/functions_and_modules/en.py3
-rw-r--r--python/problems/functions_and_modules/largest_sublist/common.py53
-rw-r--r--python/problems/functions_and_modules/largest_sublist/en.py16
-rw-r--r--python/problems/functions_and_modules/largest_sublist/sl.py33
-rw-r--r--python/problems/functions_and_modules/lists_sum/common.py50
-rw-r--r--python/problems/functions_and_modules/lists_sum/en.py16
-rw-r--r--python/problems/functions_and_modules/lists_sum/sl.py35
-rw-r--r--python/problems/functions_and_modules/longest_word/common.py48
-rw-r--r--python/problems/functions_and_modules/longest_word/en.py16
-rw-r--r--python/problems/functions_and_modules/longest_word/sl.py30
-rw-r--r--python/problems/functions_and_modules/map/common.py47
-rw-r--r--python/problems/functions_and_modules/map/en.py16
-rw-r--r--python/problems/functions_and_modules/map/sl.py34
-rw-r--r--python/problems/functions_and_modules/multiplicative_range/common.py48
-rw-r--r--python/problems/functions_and_modules/multiplicative_range/en.py16
-rw-r--r--python/problems/functions_and_modules/multiplicative_range/sl.py32
-rw-r--r--python/problems/functions_and_modules/similarity/common.py48
-rw-r--r--python/problems/functions_and_modules/similarity/en.py16
-rw-r--r--python/problems/functions_and_modules/similarity/sl.py39
-rw-r--r--python/problems/functions_and_modules/sl.py3
-rw-r--r--python/problems/functions_and_modules/suspicious_words/common.py48
-rw-r--r--python/problems/functions_and_modules/suspicious_words/en.py16
-rw-r--r--python/problems/functions_and_modules/suspicious_words/sl.py32
35 files changed, 1090 insertions, 0 deletions
diff --git a/python/problems/functions_and_modules/all/common.py b/python/problems/functions_and_modules/all/common.py
new file mode 100644
index 0000000..7fb60f5
--- /dev/null
+++ b/python/problems/functions_and_modules/all/common.py
@@ -0,0 +1,47 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 238
+group = 'functions_and_modules'
+number = 4
+visible = True
+
+solution = '''\
+def all(xs):
+ for x in xs:
+ if not x:
+ return False
+ return True
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/all/en.py b/python/problems/functions_and_modules/all/en.py
new file mode 100644
index 0000000..3028ad4
--- /dev/null
+++ b/python/problems/functions_and_modules/all/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 238
+name = 'All'
+slug = 'All'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/all/sl.py b/python/problems/functions_and_modules/all/sl.py
new file mode 100644
index 0000000..f71fa4b
--- /dev/null
+++ b/python/problems/functions_and_modules/all/sl.py
@@ -0,0 +1,40 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 238
+name = 'Vsi'
+slug = 'Vsi'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>all</code>, ki sprejme seznam <code>xs</code> in vrne <code>True</code>,
+če so vse vrednosti v seznamu resnične. Elementi seznama <code>xs</code> so lahko poljubnega tipa, ne le <code>bool</code>.
+<pre>
+>>> all([True, True, False])
+False
+>>> all([True, True])
+True
+>>> all([1, 2, 3, 0])
+False
+>>> all(['foo', 42, True])
+True
+>>> all([])
+True
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/any/common.py b/python/problems/functions_and_modules/any/common.py
new file mode 100644
index 0000000..78867c5
--- /dev/null
+++ b/python/problems/functions_and_modules/any/common.py
@@ -0,0 +1,47 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 239
+group = 'functions_and_modules'
+number = 4
+visible = True
+
+solution = '''\
+def any(xs):
+ for x in xs:
+ if x:
+ return True
+ return False
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/any/en.py b/python/problems/functions_and_modules/any/en.py
new file mode 100644
index 0000000..f5b94d9
--- /dev/null
+++ b/python/problems/functions_and_modules/any/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 239
+name = 'Any'
+slug = 'Any'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/any/sl.py b/python/problems/functions_and_modules/any/sl.py
new file mode 100644
index 0000000..f32e50e
--- /dev/null
+++ b/python/problems/functions_and_modules/any/sl.py
@@ -0,0 +1,34 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 239
+name = 'Vsaj eden'
+slug = 'Vsaj eden'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>any(xs)</code>, ki deluje podobno kot <code>all</code>, le da vrne <code>True</code>,
+če je vsaj ena vrednost v seznamu resnična.
+<pre>
+>>> any([2, 3, 0])
+True
+>>> any([])
+False
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/caesar_cipher/common.py b/python/problems/functions_and_modules/caesar_cipher/common.py
new file mode 100644
index 0000000..494a7f9
--- /dev/null
+++ b/python/problems/functions_and_modules/caesar_cipher/common.py
@@ -0,0 +1,52 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 243
+group = 'functions_and_modules'
+number = 9
+visible = True
+
+solution = '''\
+def caesar(s):
+ cipher = ''
+ for c in s:
+ if 'a' <= c <= 'w':
+ cipher += chr(ord(c) + 3)
+ elif 'x' <= c <= 'z':
+ cipher += chr(ord(c) - 23)
+ else:
+ cipher += c
+ return cipher)
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/caesar_cipher/en.py b/python/problems/functions_and_modules/caesar_cipher/en.py
new file mode 100644
index 0000000..bcfedee
--- /dev/null
+++ b/python/problems/functions_and_modules/caesar_cipher/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 243
+name = 'Caesar cipher'
+slug = 'Caesar cipher'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/caesar_cipher/sl.py b/python/problems/functions_and_modules/caesar_cipher/sl.py
new file mode 100644
index 0000000..ea4d9c8
--- /dev/null
+++ b/python/problems/functions_and_modules/caesar_cipher/sl.py
@@ -0,0 +1,35 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 243
+name = 'Cezarjeva šifra'
+slug = 'Cezarjeva šifra'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>caesar(s)</code>, ki podan niz zašifrira z uporabo <a href="http://sl.wikipedia.org/wiki/Cezarjeva_%C5%A1ifra">cezarjeve šifre</a>.
+Preden se lotite naloge, se je morda vredno pozanimati kaj počneta funkciji
+<a href="https://docs.python.org/3.5/library/functions.html#ord">ord</a> in
+<a href="https://docs.python.org/3.5/library/functions.html#chr">chr</a>.
+Predpostavite lahko, da niz <code>s</code> vsebuje le male črke angleške besede in presledke.
+<pre>
+>>> caesar('the quick brown fox jumps over the lazy dog')
+'wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj'
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/dominoes/common.py b/python/problems/functions_and_modules/dominoes/common.py
new file mode 100644
index 0000000..5e73d8e
--- /dev/null
+++ b/python/problems/functions_and_modules/dominoes/common.py
@@ -0,0 +1,47 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 240
+group = 'functions_and_modules'
+number = 6
+visible = True
+
+solution = '''\
+def dominoes(domine):
+ for i in range(len(domine) - 1):
+ if domine[i][1] != domine[i + 1][0]:
+ return False
+ return True
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/dominoes/en.py b/python/problems/functions_and_modules/dominoes/en.py
new file mode 100644
index 0000000..4d0d31b
--- /dev/null
+++ b/python/problems/functions_and_modules/dominoes/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 240
+name = 'Dominoes'
+slug = 'Dominoes'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/dominoes/sl.py b/python/problems/functions_and_modules/dominoes/sl.py
new file mode 100644
index 0000000..41cb860
--- /dev/null
+++ b/python/problems/functions_and_modules/dominoes/sl.py
@@ -0,0 +1,29 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 240
+name = 'Domine'
+slug = 'Domine'
+
+
+description = '''\
+<p>
+Vrsta domin je podana s seznamom parov (terk), na primer
+<code>[(3, 6), (6, 6), (6, 1), (1, 0)] ali [(3, 6), (6, 6), (2, 3)]</code>. Napišite funkcijo <code>dominoes(xs)</code>,
+ki prejme takšen seznam in pove, ali so domine pravilno zložene. Za prvi seznam mora vrniti <code>True</code> in za drugega <code>False</code>.
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/en.py b/python/problems/functions_and_modules/en.py
new file mode 100644
index 0000000..1218e73
--- /dev/null
+++ b/python/problems/functions_and_modules/en.py
@@ -0,0 +1,3 @@
+name = 'Functions and Modules'
+description = 'Advanced functions and modules'
+
diff --git a/python/problems/functions_and_modules/largest_sublist/common.py b/python/problems/functions_and_modules/largest_sublist/common.py
new file mode 100644
index 0000000..372e34f
--- /dev/null
+++ b/python/problems/functions_and_modules/largest_sublist/common.py
@@ -0,0 +1,53 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 242
+group = 'functions_and_modules'
+number = 8
+visible = True
+
+solution = '''\
+def largest_sublist(xss):
+ najvecji = []
+ najvecji_vsota = float('-inf')
+ for xs in xss:
+ vsota = 0
+ for x in xs:
+ vsota += x
+ if vsota > najvecji_vsota:
+ najvecji = xs
+ najvecji_vsota = vsota
+ return najvecji
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/largest_sublist/en.py b/python/problems/functions_and_modules/largest_sublist/en.py
new file mode 100644
index 0000000..132eb39
--- /dev/null
+++ b/python/problems/functions_and_modules/largest_sublist/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 242
+name = 'Largest sublist'
+slug = 'Largest sublist'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/largest_sublist/sl.py b/python/problems/functions_and_modules/largest_sublist/sl.py
new file mode 100644
index 0000000..b550ce2
--- /dev/null
+++ b/python/problems/functions_and_modules/largest_sublist/sl.py
@@ -0,0 +1,33 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 242
+name = 'Največji podseznam'
+slug = 'Največji podseznam'
+
+
+description = '''\
+<p>
+Napiši funkcijo <code>largest_sublist</code>, ki vrne podseznam z največjo vsoto elementov.
+<pre>
+>>> largest_sublist([[1, 1, 1], [1, 1]])
+[1, 1, 1]
+>>> largest_sublist([[2, 4, 1], [3, 1], [], [8, 2], [1, 1, 1, 1]])
+[8, 2]
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/lists_sum/common.py b/python/problems/functions_and_modules/lists_sum/common.py
new file mode 100644
index 0000000..d3afef4
--- /dev/null
+++ b/python/problems/functions_and_modules/lists_sum/common.py
@@ -0,0 +1,50 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 241
+group = 'functions_and_modules'
+number = 7
+visible = True
+
+solution = '''\
+def lists_sum(xss):
+ vsote = []
+ for xs in xss:
+ vsota = 0
+ for x in xs:
+ vsota += x
+ vsote.append(vsota)
+ return vsote
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/lists_sum/en.py b/python/problems/functions_and_modules/lists_sum/en.py
new file mode 100644
index 0000000..12eaf0b
--- /dev/null
+++ b/python/problems/functions_and_modules/lists_sum/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 241
+name = 'Lists sum'
+slug = 'Lists sum'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/lists_sum/sl.py b/python/problems/functions_and_modules/lists_sum/sl.py
new file mode 100644
index 0000000..4baa002
--- /dev/null
+++ b/python/problems/functions_and_modules/lists_sum/sl.py
@@ -0,0 +1,35 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 241
+name = 'Vsota seznamov'
+slug = 'Vsota seznamov'
+
+
+description = '''\
+<p>
+Podan je seznam seznamov, npr. <code>[[2, 4, 1], [3, 1], [], [8, 2], [1, 1, 1, 1]]</code>.
+Napiši funkcijo <code>lists_sum(xxs)</code>, ki v seznamu vrne vsote vseh elementov v posameznih podseznamih.
+Za gornji seznam naj funkcija vrne seznam <code>[7, 4, 0, 10, 4]</code>, saj je, na primer, <code>2 + 4 + 1 = 7</code>.
+<pre>
+>>> lists_sum([[1, 1, 1], [1, 1]])
+[3, 2]
+>>> lists_sum([[2, 4, 1], [3, 1], [], [8, 2], [1, 1, 1, 1]])
+[7, 4, 0, 10, 4]
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/longest_word/common.py b/python/problems/functions_and_modules/longest_word/common.py
new file mode 100644
index 0000000..1201c1d
--- /dev/null
+++ b/python/problems/functions_and_modules/longest_word/common.py
@@ -0,0 +1,48 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 235
+group = 'functions_and_modules'
+number = 1
+visible = True
+
+solution = '''\
+def longest(s):
+ naj = ''
+ for beseda in s.split():
+ if len(beseda) > len(naj):
+ naj = beseda
+ return naj
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/longest_word/en.py b/python/problems/functions_and_modules/longest_word/en.py
new file mode 100644
index 0000000..7bd4dc2
--- /dev/null
+++ b/python/problems/functions_and_modules/longest_word/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 235
+name = 'Longest word'
+slug = 'Longest word'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/longest_word/sl.py b/python/problems/functions_and_modules/longest_word/sl.py
new file mode 100644
index 0000000..eb85509
--- /dev/null
+++ b/python/problems/functions_and_modules/longest_word/sl.py
@@ -0,0 +1,30 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 235
+name = 'Najdaljša beseda'
+slug = 'Najdaljša beseda'
+
+
+description = '''\
+<p>
+Napiši funkcijo <code>longest(s)</code>, ki vrne najdaljšo besedo v nizu <code>s</code>.
+<pre>
+>>> longest('an ban pet podgan')
+'podgan'
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/map/common.py b/python/problems/functions_and_modules/map/common.py
new file mode 100644
index 0000000..e28f356
--- /dev/null
+++ b/python/problems/functions_and_modules/map/common.py
@@ -0,0 +1,47 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 245
+group = 'functions_and_modules'
+number = 11
+visible = True
+
+solution = '''\
+def map(f, xs):
+ ys = []
+ for x in xs:
+ ys.append(f(x))
+ return ys
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/map/en.py b/python/problems/functions_and_modules/map/en.py
new file mode 100644
index 0000000..dcc1785
--- /dev/null
+++ b/python/problems/functions_and_modules/map/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 245
+name = 'Map'
+slug = 'Map'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/map/sl.py b/python/problems/functions_and_modules/map/sl.py
new file mode 100644
index 0000000..18c47fb
--- /dev/null
+++ b/python/problems/functions_and_modules/map/sl.py
@@ -0,0 +1,34 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 245
+name = 'Slikaj'
+slug = 'Slikaj'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>map(f, xs)</code>, ki sprejme funkcijo <code>f</code> in seznam <code>[x_1, x_2, ..., x_n]</code>
+in vrne nov seznam <code>[f(x_1), f(x_2), ..., f(x_n)]</code>.
+<pre>
+>>> map(abs, [-5, 8, -3, -1, 3])
+[5, 8, 3, 1, 3]
+>>> map(len, "Daydream delusion limousine eyelash".split())
+[8, 8, 9, 7]
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/multiplicative_range/common.py b/python/problems/functions_and_modules/multiplicative_range/common.py
new file mode 100644
index 0000000..9a52dce
--- /dev/null
+++ b/python/problems/functions_and_modules/multiplicative_range/common.py
@@ -0,0 +1,48 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 244
+group = 'functions_and_modules'
+number = 10
+visible = True
+
+solution = '''\
+def mrange(s, r, l):
+ xs = []
+ for i in range(l):
+ xs.append(s)
+ s *= r
+ return xs
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/multiplicative_range/en.py b/python/problems/functions_and_modules/multiplicative_range/en.py
new file mode 100644
index 0000000..566ef5f
--- /dev/null
+++ b/python/problems/functions_and_modules/multiplicative_range/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 244
+name = 'Multiplicative range'
+slug = 'Multiplicative range'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/multiplicative_range/sl.py b/python/problems/functions_and_modules/multiplicative_range/sl.py
new file mode 100644
index 0000000..8bd4bd0
--- /dev/null
+++ b/python/problems/functions_and_modules/multiplicative_range/sl.py
@@ -0,0 +1,32 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 244
+name = 'Multiplikativni range'
+slug = 'Multiplikativni range'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>mrange(start, factor, length)</code>, ki vrne seznam, kjer je vsako naslednje število za
+<code>factor</code> večje od prejšnjega. Npr., v seznamu <code>[1, 2, 4, 8, 16]</code> je vsako naslednje število 2-krat večje od prejšnjega.
+<pre>
+>>> print(mrange(7, 4, 7))
+[7, 28, 112, 448, 1792, 7168, 28672]
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/similarity/common.py b/python/problems/functions_and_modules/similarity/common.py
new file mode 100644
index 0000000..5cb8fe7
--- /dev/null
+++ b/python/problems/functions_and_modules/similarity/common.py
@@ -0,0 +1,48 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 236
+group = 'functions_and_modules'
+number = 2
+visible = True
+
+solution = '''\
+def similarity(s1, s2):
+ stevec = 0
+ for i in range(min(len(s1), len(s2))):
+ if s1[i] == s2[i]:
+ stevec += 1
+ return stevec
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/similarity/en.py b/python/problems/functions_and_modules/similarity/en.py
new file mode 100644
index 0000000..e1dc014
--- /dev/null
+++ b/python/problems/functions_and_modules/similarity/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 236
+name = 'Similarity'
+slug = 'Similarity'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/similarity/sl.py b/python/problems/functions_and_modules/similarity/sl.py
new file mode 100644
index 0000000..8aaf0b0
--- /dev/null
+++ b/python/problems/functions_and_modules/similarity/sl.py
@@ -0,0 +1,39 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 236
+name = 'Podobnost'
+slug = 'Podobnost'
+
+
+description = '''\
+<p>
+Napišite funkcijo <code>similarity(s1, s2)</code>, ki izračuna podobnost med dvema nizoma.
+Podobnost definirajmo kot število mest v katerih se niza ujemata.
+<pre>
+sobota
+robot
+------
+011110 -> 4
+
+>>> podobnost('sobota', 'robot')
+4
+>>> podobnost('robot', 'sobota')
+4
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}
diff --git a/python/problems/functions_and_modules/sl.py b/python/problems/functions_and_modules/sl.py
new file mode 100644
index 0000000..fb4f520
--- /dev/null
+++ b/python/problems/functions_and_modules/sl.py
@@ -0,0 +1,3 @@
+name = 'Funkcije in delo z moduli'
+description = 'Uporaba funkcij in delo z moduli (predvsem z nizi)'
+
diff --git a/python/problems/functions_and_modules/suspicious_words/common.py b/python/problems/functions_and_modules/suspicious_words/common.py
new file mode 100644
index 0000000..74868ab
--- /dev/null
+++ b/python/problems/functions_and_modules/suspicious_words/common.py
@@ -0,0 +1,48 @@
+# coding=utf-8
+
+import re
+from python.util import has_token_sequence, string_almost_equal, \
+ string_contains_number, get_tokens, get_numbers, get_exception_desc
+from server.hints import Hint
+
+id = 237
+group = 'functions_and_modules'
+number = 3
+visible = True
+
+solution = '''\
+def suspicious(s):
+ susp = []
+ for word in s.split():
+ if 'u' in word and 'a' in word:
+ susp.append(word)
+ return susp
+'''
+
+hint_type = {
+ 'final_hint': Hint('final_hint')
+}
+
+def test(python, code):
+ test_in = [1]
+ n_correct = 0
+
+ passed = n_correct == len(test_in)
+ tin = None
+ tout = None
+ hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}]
+ if tin:
+ hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}})
+ if passed:
+ hints.append({'id': 'final_hint'})
+ return passed, hints
+
+def hint(python, code):
+ tokens = get_tokens(code)
+
+ # run one test first to see if there are any exceptions
+ answer = python(code=code, inputs=[(None, None)], timeout=1.0)
+ exc = get_exception_desc(answer[0][3])
+ if exc: return exc
+
+ return None
diff --git a/python/problems/functions_and_modules/suspicious_words/en.py b/python/problems/functions_and_modules/suspicious_words/en.py
new file mode 100644
index 0000000..9a406bf
--- /dev/null
+++ b/python/problems/functions_and_modules/suspicious_words/en.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+id = 237
+name = 'Suspicious words'
+slug = 'Suspicious words'
+
+description = '''\
+<p>(translation missing)</p>'''
+
+hint = {
+ 'plan': '''\
+<p>(translation missing)</p>''',
+
+ 'no_input_call': '''\
+<p>(translation missing)</p>''',
+}
diff --git a/python/problems/functions_and_modules/suspicious_words/sl.py b/python/problems/functions_and_modules/suspicious_words/sl.py
new file mode 100644
index 0000000..3bf2c7b
--- /dev/null
+++ b/python/problems/functions_and_modules/suspicious_words/sl.py
@@ -0,0 +1,32 @@
+# coding=utf-8
+import server
+mod = server.problems.load_language('python', 'sl')
+
+
+id = 237
+name = 'Sumljive besede'
+slug = 'Sumljive besede'
+
+
+description = '''\
+<p>
+Napiši funkcijo <code>suspicious(s)</code>, ki vrne seznam vseh sumljivih besed v danem nizu.
+Beseda je sumljiva, če vsebuje tako črko u kot črko a.
+<pre>
+>>> susupicious('Muha pa je rekla: "Tale juha se je pa res prilegla, najlepša huala," in odletela.')
+['Muha', 'juha', 'huala,"']
+</pre>
+</p>'''
+
+plan = ['''\
+<p></p>
+''',
+ '''\
+<p></p>''']
+
+hint = {
+ 'final_hint': ['''\
+<p>Program je pravilen! <br>
+</p>
+'''],
+}