08_zmagozmagovalci
This commit is contained in:
parent
0400df0ede
commit
02cae0ff85
3
.idea/dictionaries/gapi.xml
Normal file
3
.idea/dictionaries/gapi.xml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="gapi" />
|
||||||
|
</component>
|
|
@ -2,7 +2,7 @@
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.11 (domace_naloge)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,5 +1,6 @@
|
||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<settings>
|
<settings>
|
||||||
|
<option name="PROJECT_PROFILE" value="Default" />
|
||||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
<version value="1.0" />
|
<version value="1.0" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.11 (domace_naloge)" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (domace_naloge)" project-jdk-type="Python SDK" />
|
||||||
<component name="PyPackaging">
|
<component name="PyPackaging">
|
||||||
<option name="earlyReleasesAsUpgrades" value="true" />
|
<option name="earlyReleasesAsUpgrades" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|
0
08_zmagozmagovalci/__init__.py
Normal file
0
08_zmagozmagovalci/__init__.py
Normal file
16
08_zmagozmagovalci/naloga.py
Normal file
16
08_zmagozmagovalci/naloga.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
def hitrejsi(kolesar1, kolesar2, razmerja):
|
||||||
|
if dokazov(kolesar1, kolesar2, razmerja):
|
||||||
|
return kolesar1
|
||||||
|
elif dokazov(kolesar2, kolesar1, razmerja):
|
||||||
|
return kolesar2
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def dokazov(kolesar1, kolesar2, razmerja):
|
||||||
|
dokazi = 0
|
||||||
|
for kolesar in razmerja[kolesar1]:
|
||||||
|
if kolesar == kolesar2:
|
||||||
|
dokazi += 1
|
||||||
|
else:
|
||||||
|
dokazi += dokazov(kolesar, kolesar2, razmerja)
|
||||||
|
return dokazi
|
69
08_zmagozmagovalci/naloga_test.py
Normal file
69
08_zmagozmagovalci/naloga_test.py
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
from .naloga import *
|
||||||
|
|
||||||
|
from itertools import pairwise
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
razmerja = {'Ana': {'Vera', 'Cilka'},
|
||||||
|
'Berta': {'Greta', 'Klara', 'Iva', 'Cilka'},
|
||||||
|
'Cilka': {'Olga'},
|
||||||
|
'Črtomira': set(),
|
||||||
|
'Dani': {'Liza', 'Ana', 'Fanči', 'Cilka', 'Micka', 'Greta'},
|
||||||
|
'Ema': set(),
|
||||||
|
'Fanči': {'Liza', 'Poldka', 'Cilka'},
|
||||||
|
'Greta': set(),
|
||||||
|
'Helga': set(),
|
||||||
|
'Iva': {'Ema', 'Helga'},
|
||||||
|
'Jana': {'Liza', 'Dani', 'Berta', 'Micka', 'Tina', 'Greta'},
|
||||||
|
'Klara': {'Helga', 'Nina'},
|
||||||
|
'Liza': {'Vera', 'Olga', 'Rezka'},
|
||||||
|
'Micka': {'Liza', 'Saša', 'Urša'},
|
||||||
|
'Nina': {'Olga', 'Poldka'},
|
||||||
|
'Olga': {'Poldka'},
|
||||||
|
'Poldka': set(),
|
||||||
|
'Rezka': {'Saša'},
|
||||||
|
'Saša': set(),
|
||||||
|
'Špela': {'Žana'},
|
||||||
|
'Tina': set(),
|
||||||
|
'Urša': {'Vera'},
|
||||||
|
'Vera': set(),
|
||||||
|
'Zoja': {'Žana', 'Tina'},
|
||||||
|
'Žana': set()}
|
||||||
|
|
||||||
|
razmerja2 = {x: {y} for x, y in pairwise(sorted(razmerja))}
|
||||||
|
razmerja2.update({"Žana": set(), "Trelawney": set()})
|
||||||
|
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
def test_01_obvezna(self):
|
||||||
|
self.assertEqual("Jana", hitrejsi("Jana", "Berta", razmerja))
|
||||||
|
self.assertEqual("Jana", hitrejsi("Berta", "Jana", razmerja))
|
||||||
|
self.assertEqual("Berta", hitrejsi("Berta", "Poldka", razmerja))
|
||||||
|
self.assertEqual("Berta", hitrejsi("Poldka", "Berta", razmerja))
|
||||||
|
self.assertEqual("Berta", hitrejsi("Poldka", "Berta", razmerja))
|
||||||
|
self.assertIsNone(hitrejsi("Saša", "Berta", razmerja))
|
||||||
|
self.assertIsNone(hitrejsi("Berta", "Saša", razmerja))
|
||||||
|
self.assertIsNone(hitrejsi("Špela", "Tina", razmerja))
|
||||||
|
self.assertIsNone(hitrejsi("Jana", "Črtomira", razmerja))
|
||||||
|
self.assertIsNone(hitrejsi("Črtomira", "Jana", razmerja))
|
||||||
|
|
||||||
|
self.assertEqual("Ana", hitrejsi("Ana", "Žana", razmerja2))
|
||||||
|
self.assertEqual("Ana", hitrejsi("Žana", "Ana", razmerja2))
|
||||||
|
self.assertIsNone(hitrejsi("Ana", "Trelawney", razmerja2))
|
||||||
|
self.assertIsNone(hitrejsi("Ana", "Trelawney", razmerja2))
|
||||||
|
|
||||||
|
def test_02_dokazov(self):
|
||||||
|
self.assertEqual(1, dokazov("Jana", "Berta", razmerja))
|
||||||
|
self.assertEqual(0, dokazov("Berta", "Jana", razmerja))
|
||||||
|
self.assertEqual(4, dokazov("Jana", "Cilka", razmerja))
|
||||||
|
self.assertEqual(1, dokazov("Jana", "Nina", razmerja))
|
||||||
|
self.assertEqual(5, dokazov("Jana", "Liza", razmerja))
|
||||||
|
self.assertEqual(10, dokazov("Jana", "Olga", razmerja))
|
||||||
|
self.assertEqual(12, dokazov("Jana", "Poldka", razmerja))
|
||||||
|
self.assertEqual(1, dokazov("Špela", "Žana", razmerja))
|
||||||
|
|
||||||
|
self.assertEqual(1, dokazov("Ana", "Žana", razmerja2))
|
||||||
|
self.assertEqual(0, dokazov("Žana", "Ana", razmerja2))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user