From c5139404dff6f3266489e8b041ee6b92b8a03538 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 17 Oct 2016 16:19:23 +0200 Subject: Week2: simpop/3 exercise added. --- prolog/problems/world_data/common.py | 2 + prolog/problems/world_data/en.py | 8 ++++ .../world_data/similar_population_3/common.py | 47 ++++++++++++++++++++++ .../problems/world_data/similar_population_3/en.py | 15 +++++++ .../problems/world_data/similar_population_3/sl.py | 15 +++++++ prolog/problems/world_data/sl.py | 9 +++++ 6 files changed, 96 insertions(+) create mode 100644 prolog/problems/world_data/common.py create mode 100644 prolog/problems/world_data/en.py create mode 100644 prolog/problems/world_data/similar_population_3/common.py create mode 100644 prolog/problems/world_data/similar_population_3/en.py create mode 100644 prolog/problems/world_data/similar_population_3/sl.py create mode 100644 prolog/problems/world_data/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/common.py b/prolog/problems/world_data/common.py new file mode 100644 index 0000000..350b139 --- /dev/null +++ b/prolog/problems/world_data/common.py @@ -0,0 +1,2 @@ +id = 1000 +number = 20 diff --git a/prolog/problems/world_data/en.py b/prolog/problems/world_data/en.py new file mode 100644 index 0000000..3d3cbaf --- /dev/null +++ b/prolog/problems/world_data/en.py @@ -0,0 +1,8 @@ +name = 'The World Factbook' +description = '''\ +

+Let's ask prolog some questions about our world, e.g. through which countries a given river flows or which +two countries are most similar in terms of the size of their populations. For this purpose a database +containing facts about the world has been loaded. The database comes from the almanac "The World Factbook". +

+''' diff --git a/prolog/problems/world_data/similar_population_3/common.py b/prolog/problems/world_data/similar_population_3/common.py new file mode 100644 index 0000000..11d541b --- /dev/null +++ b/prolog/problems/world_data/similar_population_3/common.py @@ -0,0 +1,47 @@ +from operator import itemgetter +import socket +import prolog.engine +from server.hints import Hint +import server.problems + +id = 12519 +number = 1 +visible = True +facts = 'mondial' + +solution = '''\ +simpop(X, Y, D):- + findall(D/X/Y, (country(X,_,_,_,_,PX), country(Y,_,_,_,_,PY), X \== Y, D is abs(PX-PY)), L), + sort(L, [D/X/Y|_]). +''' + +test_cases = [ + ('simpop(X, Y, D)', + [{'X': "'Grenada'", 'Y': "'Tonga'", 'D': '76'}]), + ("simpop('Slovenia', Y, D)", + [{'Y': "'Macedonia'", 'D': '973'}]), + ("simpop(X, 'Australia', D)", + [{'X': "'Taiwan'", 'D': '180541'}]), + ("simpop(X, Y, 1176831)", + [{'X': "'Uzbekistan'", 'Y': "'Venezuela'"}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit = None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return n_correct, len(test_cases), hints + diff --git a/prolog/problems/world_data/similar_population_3/en.py b/prolog/problems/world_data/similar_population_3/en.py new file mode 100644 index 0000000..e9c2516 --- /dev/null +++ b/prolog/problems/world_data/similar_population_3/en.py @@ -0,0 +1,15 @@ +name = 'simpop/3' +slug = 'countries with most similar number of residents' + +description = '''\ +

simpop(X, Y, Diff): X and Y are countries with the most similar numbers of +residents. Diff represents the difference between them.

+
+?- simpop('Fiji', Y, Diff).
+  Y = 'Cyprus',
+  Diff = 20152.
+
+

Useful facts are given as country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/similar_population_3/sl.py b/prolog/problems/world_data/similar_population_3/sl.py new file mode 100644 index 0000000..069f35e --- /dev/null +++ b/prolog/problems/world_data/similar_population_3/sl.py @@ -0,0 +1,15 @@ +name = 'simpop/3' +slug = 'državi z najbolj podobnim številom prebivalcev' + +description = '''\ +

simpop(X, Y, Diff): X in Y je par držav z najbolj podobnim številom +prebivalcev, Diff je razlika med njima.

+
+?- simpop('Fiji', Y, Diff).
+  Y = 'Cyprus',
+  Diff = 20152.
+
+

Uporabna dejstva so podana v obliki country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/sl.py b/prolog/problems/world_data/sl.py new file mode 100644 index 0000000..a2f3f71 --- /dev/null +++ b/prolog/problems/world_data/sl.py @@ -0,0 +1,9 @@ +name = 'Države sveta' +description = '''\ +

+Naučimo se vprašati prolog po različnih dejstvih o našem svetu, npr. skozi katere države teče neka reka ali +kateri dve državi sta si čimbolj podobni po številu prebivalcev. Za ta namen je naložena baza podatkov iz +almanaha svetovnih dejstev "The World Factbook". +

+''' + -- cgit v1.2.1 From edf712f8b4a6a3e73d3cca9b5173ed270a3c634b Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 17 Oct 2016 22:56:32 +0200 Subject: Week2: holiday/2 exercise added. --- prolog/problems/world_data/common.py | 2 +- prolog/problems/world_data/holiday_2/common.py | 49 ++++++++++++++++++++++ prolog/problems/world_data/holiday_2/en.py | 17 ++++++++ prolog/problems/world_data/holiday_2/sl.py | 17 ++++++++ .../world_data/similar_population_3/common.py | 2 +- 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 prolog/problems/world_data/holiday_2/common.py create mode 100644 prolog/problems/world_data/holiday_2/en.py create mode 100644 prolog/problems/world_data/holiday_2/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/common.py b/prolog/problems/world_data/common.py index 350b139..c13c356 100644 --- a/prolog/problems/world_data/common.py +++ b/prolog/problems/world_data/common.py @@ -1,2 +1,2 @@ -id = 1000 +id = 1001 number = 20 diff --git a/prolog/problems/world_data/holiday_2/common.py b/prolog/problems/world_data/holiday_2/common.py new file mode 100644 index 0000000..0e7ba8f --- /dev/null +++ b/prolog/problems/world_data/holiday_2/common.py @@ -0,0 +1,49 @@ +from operator import itemgetter +import socket +import prolog.engine +from server.hints import Hint +import server.problems + +id = 12529 +number = 10 +visible = True +facts = 'mondial' + +solution = '''\ +holiday(Country, Neighbour):- + country(Country,CC1,_,_,_,_), + (borders(CC1,CC2,_) ; borders(CC2,CC1,_)), + once(geo_sea(_,CC2,_)), + country(Neighbour,CC2,_,_,_,_). +''' + +test_cases = [ + ("holiday('Slovenia', N)", + [{'N': "'Italy'"}, {'N': "'Croatia'"}]), + ("holiday(C, 'Canada')", + [{'C': "'United States'"}]), + ("holiday('Venezuela', 'Guyana')", + [{}]), + ("\+ holiday('Uzbekistan', _)", + [{}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit = None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return n_correct, len(test_cases), hints + diff --git a/prolog/problems/world_data/holiday_2/en.py b/prolog/problems/world_data/holiday_2/en.py new file mode 100644 index 0000000..ecb248a --- /dev/null +++ b/prolog/problems/world_data/holiday_2/en.py @@ -0,0 +1,17 @@ +name = 'holiday/2' +slug = 'V katero sosednjo državo gremo lahko na morje?' + +description = '''\ +

V katero sosednjo državo gremo lahko na morje?

+

holiday(Country, Neighbour): Neighbour je sosednja država od Country, +ki ima morje.

+
+?- holiday('Slovenia', Neighbour).
+  Neighbour = 'Italy' ;
+  Neighbour = 'Croatia'
+
+

Prav ti znajo priti podatki v obliki borders(Country1, Country2, LenOfBorder) in +geo_sea(Sea, CountryCode, Province).

+''' + +hint = {} diff --git a/prolog/problems/world_data/holiday_2/sl.py b/prolog/problems/world_data/holiday_2/sl.py new file mode 100644 index 0000000..ecb248a --- /dev/null +++ b/prolog/problems/world_data/holiday_2/sl.py @@ -0,0 +1,17 @@ +name = 'holiday/2' +slug = 'V katero sosednjo državo gremo lahko na morje?' + +description = '''\ +

V katero sosednjo državo gremo lahko na morje?

+

holiday(Country, Neighbour): Neighbour je sosednja država od Country, +ki ima morje.

+
+?- holiday('Slovenia', Neighbour).
+  Neighbour = 'Italy' ;
+  Neighbour = 'Croatia'
+
+

Prav ti znajo priti podatki v obliki borders(Country1, Country2, LenOfBorder) in +geo_sea(Sea, CountryCode, Province).

+''' + +hint = {} diff --git a/prolog/problems/world_data/similar_population_3/common.py b/prolog/problems/world_data/similar_population_3/common.py index 11d541b..2226a30 100644 --- a/prolog/problems/world_data/similar_population_3/common.py +++ b/prolog/problems/world_data/similar_population_3/common.py @@ -5,7 +5,7 @@ from server.hints import Hint import server.problems id = 12519 -number = 1 +number = 40 visible = True facts = 'mondial' -- cgit v1.2.1 From 6a5d6fc44906734b35f5fcb70a447c5300bf26e5 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 18 Oct 2016 02:11:35 +0200 Subject: Week2: grant/1 and landlocked2/1 exercises added. --- prolog/problems/world_data/grant_1/common.py | 50 ++++++++++++++++++++++ prolog/problems/world_data/grant_1/en.py | 15 +++++++ prolog/problems/world_data/grant_1/sl.py | 15 +++++++ prolog/problems/world_data/landlocked2_1/common.py | 48 +++++++++++++++++++++ prolog/problems/world_data/landlocked2_1/en.py | 12 ++++++ prolog/problems/world_data/landlocked2_1/sl.py | 12 ++++++ 6 files changed, 152 insertions(+) create mode 100644 prolog/problems/world_data/grant_1/common.py create mode 100644 prolog/problems/world_data/grant_1/en.py create mode 100644 prolog/problems/world_data/grant_1/sl.py create mode 100644 prolog/problems/world_data/landlocked2_1/common.py create mode 100644 prolog/problems/world_data/landlocked2_1/en.py create mode 100644 prolog/problems/world_data/landlocked2_1/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/grant_1/common.py b/prolog/problems/world_data/grant_1/common.py new file mode 100644 index 0000000..aa016b0 --- /dev/null +++ b/prolog/problems/world_data/grant_1/common.py @@ -0,0 +1,50 @@ +from operator import itemgetter +import socket +import prolog.engine +from server.hints import Hint +import server.problems + +id = 12536 +number = 20 +visible = True +facts = 'mondial' + +solution = '''\ +grant(Loc):- + (city(Loc, _, _, _, Lat, _, _) + ; + island(Loc, _, _, _, _, Lat, _)), + number(Lat), + Lat > -38, + Lat < -36. +''' + +test_cases = [ + ("grant(Loc)", + [{'Loc': "'Melbourne'"}, {'Loc': "'Auckland'"}, {'Loc': "'Hamilton'"}, {'Loc': "'Santa Rosa'"}, + {'Loc': "'Concepción'"}, {'Loc': "'Talcahuano'"}, {'Loc': "'Tristan Da Cunha'"}]), + ("\+ grant('Ljubljana')", + [{}]), + ("grant('Tristan Da Cunha')", + [{}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit = None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return n_correct, len(test_cases), hints + diff --git a/prolog/problems/world_data/grant_1/en.py b/prolog/problems/world_data/grant_1/en.py new file mode 100644 index 0000000..20ad118 --- /dev/null +++ b/prolog/problems/world_data/grant_1/en.py @@ -0,0 +1,15 @@ +name = 'grant/1' +slug = 'Otroka kapitana Granta' + +description = '''\ +

Otroka kapitana Granta, tako pravi Jules Verne, sta našla njegovo pismo v steklenici. Izgubil naj bi se v +brodolomu nekje na morju. Vse kar vesta o njegovi lokaciji je, da leži na 37 poldnevniku južne širine. Povprašaj +prolog v katerem mestu ali na katerem otoku se lahko nahaja, da ga rešimo. Privzemimo, da poiščemo vse +lokacije med -36 in -38 stopinjami južne širine (minus ker je pod ekvatorjem).

+

grant(Location): predikat eno po eno vrne vse lokacije Location, ki ustrezajo +pogojem. Location predstavlja ime lokacije.

+

Prav ti znajo priti podatki v obliki city(Name, CountryCode, Province, Population, Latitude, Longitude, +Elevation) in island(Name, Group, Area, Elevation, Type, Latitude, Longitude).

+''' + +hint = {} diff --git a/prolog/problems/world_data/grant_1/sl.py b/prolog/problems/world_data/grant_1/sl.py new file mode 100644 index 0000000..20ad118 --- /dev/null +++ b/prolog/problems/world_data/grant_1/sl.py @@ -0,0 +1,15 @@ +name = 'grant/1' +slug = 'Otroka kapitana Granta' + +description = '''\ +

Otroka kapitana Granta, tako pravi Jules Verne, sta našla njegovo pismo v steklenici. Izgubil naj bi se v +brodolomu nekje na morju. Vse kar vesta o njegovi lokaciji je, da leži na 37 poldnevniku južne širine. Povprašaj +prolog v katerem mestu ali na katerem otoku se lahko nahaja, da ga rešimo. Privzemimo, da poiščemo vse +lokacije med -36 in -38 stopinjami južne širine (minus ker je pod ekvatorjem).

+

grant(Location): predikat eno po eno vrne vse lokacije Location, ki ustrezajo +pogojem. Location predstavlja ime lokacije.

+

Prav ti znajo priti podatki v obliki city(Name, CountryCode, Province, Population, Latitude, Longitude, +Elevation) in island(Name, Group, Area, Elevation, Type, Latitude, Longitude).

+''' + +hint = {} diff --git a/prolog/problems/world_data/landlocked2_1/common.py b/prolog/problems/world_data/landlocked2_1/common.py new file mode 100644 index 0000000..5c17886 --- /dev/null +++ b/prolog/problems/world_data/landlocked2_1/common.py @@ -0,0 +1,48 @@ +from operator import itemgetter +import socket +import prolog.engine +from server.hints import Hint +import server.problems + +id = 12539 +number = 39 +visible = True +facts = 'mondial' + +solution = '''\ +landlocked2(Country):- + findall(CC, (country(_,CC,_,_,_,_), \+ geo_sea(_,CC,_)), LL), + member(C, LL), + \+ ( (borders(C,C1,_) ; borders(C1,C,_)), + \+ member(C1, LL) ), + country(Country,C,_,_,_,_). +''' + +test_cases = [ + ("landlocked2(Country)", + [{'Country': "'Liechtenstein'"}, {'Country': "'Uzbekistan'"}]), + ("\+ landlocked2('Slovenia')", + [{}]), + ("landlocked2('Uzbekistan')", + [{}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit = None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return n_correct, len(test_cases), hints + diff --git a/prolog/problems/world_data/landlocked2_1/en.py b/prolog/problems/world_data/landlocked2_1/en.py new file mode 100644 index 0000000..6d69382 --- /dev/null +++ b/prolog/problems/world_data/landlocked2_1/en.py @@ -0,0 +1,12 @@ +name = 'landlocked2/1' +slug = 'poišči države brez morja, ki ne mejijo na države z morjem' + +description = '''\ +

Nekatere države nimajo morja. Spet druge države imajo še manj sreče -- ne samo, da nimajo morja, +tudi ne mejijo na nobeno državo, ki bi morje imela. Po angleško takim državam rečemo "double landlocked".

+

landlocked2(Country): predikat eno po eno vrne vse države, ki nimajo ne morja, ne sosede +z morjem.

+

Prav ti znajo priti podatki v obliki geo_sea(Sea, CountryCode, Province).

+''' + +hint = {} diff --git a/prolog/problems/world_data/landlocked2_1/sl.py b/prolog/problems/world_data/landlocked2_1/sl.py new file mode 100644 index 0000000..6d69382 --- /dev/null +++ b/prolog/problems/world_data/landlocked2_1/sl.py @@ -0,0 +1,12 @@ +name = 'landlocked2/1' +slug = 'poišči države brez morja, ki ne mejijo na države z morjem' + +description = '''\ +

Nekatere države nimajo morja. Spet druge države imajo še manj sreče -- ne samo, da nimajo morja, +tudi ne mejijo na nobeno državo, ki bi morje imela. Po angleško takim državam rečemo "double landlocked".

+

landlocked2(Country): predikat eno po eno vrne vse države, ki nimajo ne morja, ne sosede +z morjem.

+

Prav ti znajo priti podatki v obliki geo_sea(Sea, CountryCode, Province).

+''' + +hint = {} -- cgit v1.2.1 From 64e1f9eb2e18910e4ecc7299c53868445d3ed9b1 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 18 Oct 2016 16:20:10 +0200 Subject: Week2: whoSpeaks/3 exercises added. --- prolog/problems/world_data/whoSpeaks_3/common.py | 47 ++++++++++++++++++++++++ prolog/problems/world_data/whoSpeaks_3/en.py | 23 ++++++++++++ prolog/problems/world_data/whoSpeaks_3/sl.py | 23 ++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 prolog/problems/world_data/whoSpeaks_3/common.py create mode 100644 prolog/problems/world_data/whoSpeaks_3/en.py create mode 100644 prolog/problems/world_data/whoSpeaks_3/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/whoSpeaks_3/common.py b/prolog/problems/world_data/whoSpeaks_3/common.py new file mode 100644 index 0000000..b80e5d5 --- /dev/null +++ b/prolog/problems/world_data/whoSpeaks_3/common.py @@ -0,0 +1,47 @@ +from operator import itemgetter +import socket +import prolog.engine +from server.hints import Hint +import server.problems + +id = 12549 +number = 369 +visible = True +facts = 'mondial' + +solution = '''\ +whoSpeaks(Lang, Country, Num):- + language(CC, Lang, Perc), + country(Country, CC, _, _, _, Pop), + Num is Pop*Perc/100. +''' + +test_cases = [ + ("whoSpeaks('Dutch', Country, _)", + [{'Country': "'Belgium'"}, {'Country': "'Netherlands'"}, {'Country': "'Monaco'"}, + {'Country': "'Curacao'"}, {'Country': "'Sint Maarten'"}]), + ("whoSpeaks('Slovenian', 'Slovenia', Num)", + [{'Num': '1873527.11'}]), + ("\+ whoSpeaks('Italian', 'Uzbekistan', _)", + [{}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit = None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return n_correct, len(test_cases), hints + diff --git a/prolog/problems/world_data/whoSpeaks_3/en.py b/prolog/problems/world_data/whoSpeaks_3/en.py new file mode 100644 index 0000000..3dc74e6 --- /dev/null +++ b/prolog/problems/world_data/whoSpeaks_3/en.py @@ -0,0 +1,23 @@ +name = 'whoSpeaks/3' +slug = 'poišči države v katerih govorijo določen jezik' + +description = '''\ +

Določen jezik ne govorijo nujno samo v eni državi. Pravzaprav za večino jezikov velja, da jih govorijo +v več državah na svetu. Napiši predikat, ki ugotovi v katerih državah govorijo določen jezik in koliko je +ljudi, ki ga govorijo. Morda te rezultati presenetijo!

+

whoSpeaks(Lang, Country, NumOfSpeakers): predikat eno po eno vrne vse države Country +v kateri govorijo jezik Lang in obenem vrne tudi koliko ljudi NumOfSpeakers v tej državi +govori ta jezik.

+
+?- whoSpeaks('Spanish', Country, NumOfSpeakers).
+  Country = 'Spain', NumOfSpeakers = 34643777 ;
+  Country = 'Andorra', NumOfSpeakers = 25777 ;
+  Country = 'Belize', NumOfSpeakers = 143966 ;
+  ...
+
+

Prav ti znajo priti podatki v obliki language(CountryCode, Language, PercentageOfSpeakers).

+

S pomočjo napisanega predikata lahko hitro ugotoviš v koliko državah govorijo nek jezik ali v kateri državi je +najbolj pogost. Lahko poskusiš postaviti ustrezno vprašanje prologu v konzoli.

+''' + +hint = {} diff --git a/prolog/problems/world_data/whoSpeaks_3/sl.py b/prolog/problems/world_data/whoSpeaks_3/sl.py new file mode 100644 index 0000000..3dc74e6 --- /dev/null +++ b/prolog/problems/world_data/whoSpeaks_3/sl.py @@ -0,0 +1,23 @@ +name = 'whoSpeaks/3' +slug = 'poišči države v katerih govorijo določen jezik' + +description = '''\ +

Določen jezik ne govorijo nujno samo v eni državi. Pravzaprav za večino jezikov velja, da jih govorijo +v več državah na svetu. Napiši predikat, ki ugotovi v katerih državah govorijo določen jezik in koliko je +ljudi, ki ga govorijo. Morda te rezultati presenetijo!

+

whoSpeaks(Lang, Country, NumOfSpeakers): predikat eno po eno vrne vse države Country +v kateri govorijo jezik Lang in obenem vrne tudi koliko ljudi NumOfSpeakers v tej državi +govori ta jezik.

+
+?- whoSpeaks('Spanish', Country, NumOfSpeakers).
+  Country = 'Spain', NumOfSpeakers = 34643777 ;
+  Country = 'Andorra', NumOfSpeakers = 25777 ;
+  Country = 'Belize', NumOfSpeakers = 143966 ;
+  ...
+
+

Prav ti znajo priti podatki v obliki language(CountryCode, Language, PercentageOfSpeakers).

+

S pomočjo napisanega predikata lahko hitro ugotoviš v koliko državah govorijo nek jezik ali v kateri državi je +najbolj pogost. Lahko poskusiš postaviti ustrezno vprašanje prologu v konzoli.

+''' + +hint = {} -- cgit v1.2.1 From d0dd9cd28eec6007c2f80737a47895498b0ee9f7 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 16:26:00 +0200 Subject: Prolog: add more world_data exercises --- .../problems/world_data/all_capitals_1/common.py | 44 ++++++++++++++++++ prolog/problems/world_data/all_capitals_1/en.py | 13 ++++++ prolog/problems/world_data/all_capitals_1/sl.py | 13 ++++++ prolog/problems/world_data/capital_2/common.py | 52 ++++++++++++++++++++++ prolog/problems/world_data/capital_2/en.py | 13 ++++++ prolog/problems/world_data/capital_2/sl.py | 13 ++++++ prolog/problems/world_data/flows_2/common.py | 51 +++++++++++++++++++++ prolog/problems/world_data/flows_2/en.py | 20 +++++++++ prolog/problems/world_data/flows_2/sl.py | 34 ++++++++++++++ .../world_data/people_in_capitals_1/common.py | 48 ++++++++++++++++++++ .../problems/world_data/people_in_capitals_1/en.py | 11 +++++ .../problems/world_data/people_in_capitals_1/sl.py | 11 +++++ 12 files changed, 323 insertions(+) create mode 100644 prolog/problems/world_data/all_capitals_1/common.py create mode 100644 prolog/problems/world_data/all_capitals_1/en.py create mode 100644 prolog/problems/world_data/all_capitals_1/sl.py create mode 100644 prolog/problems/world_data/capital_2/common.py create mode 100644 prolog/problems/world_data/capital_2/en.py create mode 100644 prolog/problems/world_data/capital_2/sl.py create mode 100644 prolog/problems/world_data/flows_2/common.py create mode 100644 prolog/problems/world_data/flows_2/en.py create mode 100644 prolog/problems/world_data/flows_2/sl.py create mode 100644 prolog/problems/world_data/people_in_capitals_1/common.py create mode 100644 prolog/problems/world_data/people_in_capitals_1/en.py create mode 100644 prolog/problems/world_data/people_in_capitals_1/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/all_capitals_1/common.py b/prolog/problems/world_data/all_capitals_1/common.py new file mode 100644 index 0000000..490c183 --- /dev/null +++ b/prolog/problems/world_data/all_capitals_1/common.py @@ -0,0 +1,44 @@ +from operator import itemgetter +import socket +import prolog.engine +import prolog.util +from server.hints import Hint +import server.problems + +id = 10002 +number = 20 +visible = True +facts = 'mondial' + +solution = '''\ +all_capitals(List) :- + findall(Capital, country(_, _, Capital, _, _, _), List). +''' + +hint_type = { +} + +test_cases = [ + ('all_capitals(X), length(X, L)', [{'L': '244'}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit=None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + if n_correct == len(test_cases): + hints += [{'id': 'final_hint'}] + return n_correct, len(test_cases), hints diff --git a/prolog/problems/world_data/all_capitals_1/en.py b/prolog/problems/world_data/all_capitals_1/en.py new file mode 100644 index 0000000..92eb2b2 --- /dev/null +++ b/prolog/problems/world_data/all_capitals_1/en.py @@ -0,0 +1,13 @@ +name = 'all_capitals/1' +slug = 'capital cities' + +description = '''\ +

all_capitals(List): List is a list of all capitals in the world.

+
+?- all_capitals(List).
+  List = ['Tirana', 'Athina', 'Skopje', 'Beograd', …]
+
+

Useful facts are given as country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/all_capitals_1/sl.py b/prolog/problems/world_data/all_capitals_1/sl.py new file mode 100644 index 0000000..cf3413f --- /dev/null +++ b/prolog/problems/world_data/all_capitals_1/sl.py @@ -0,0 +1,13 @@ +name = 'all_capitals/1' +slug = 'glavna mesta' + +description = '''\ +

all_capitals(List): List je seznam vseh glavnih mest na svetu.

+
+?- all_capitals(List).
+  List = ['Tirana', 'Athina', 'Skopje', 'Beograd', …]
+
+

Uporabna dejstva so podana v obliki country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/capital_2/common.py b/prolog/problems/world_data/capital_2/common.py new file mode 100644 index 0000000..76fb985 --- /dev/null +++ b/prolog/problems/world_data/capital_2/common.py @@ -0,0 +1,52 @@ +from operator import itemgetter +import socket +import prolog.engine +import prolog.util +from server.hints import Hint +import server.problems + +id = '10001' +number = 10 +visible = True +facts = 'mondial' + +solution = '''\ +capital(Country, Capital) :- + country(Country, _, Capital, _, _, _). +''' + +hint_type = { +} + +test_cases = [ + ("capital('France', X)", [{'X': "'Paris'"}]), + ("capital('Turkmenistan', X)", [{'X': "'Ashgabat'"}]), + ("capital('Cocos Islands', X)", [{'X': "'West Island'"}]), + ("capital(X, 'Basseterre')", [{'X': "'Saint Kitts and Nevis'"}]), + ("capital(X, X)", + [{'X': "'Luxembourg'"}, {'X': "'Monaco'"}, {'X': "'Gibraltar'"}, + {'X': "'Ceuta'"}, {'X': "'Melilla'"}, {'X': "'San Marino'"}, + {'X': "'Hong Kong'"}, {'X': "'Macao'"}, {'X': "'Singapore'"}, + {'X': "'Djibouti'"}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit=None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + if n_correct == len(test_cases): + hints += [{'id': 'final_hint'}] + return n_correct, len(test_cases), hints diff --git a/prolog/problems/world_data/capital_2/en.py b/prolog/problems/world_data/capital_2/en.py new file mode 100644 index 0000000..5ecd2ab --- /dev/null +++ b/prolog/problems/world_data/capital_2/en.py @@ -0,0 +1,13 @@ +name = 'capital/2' +slug = 'capitals' + +description = '''\ +

capital(X, Y): Y is the capital city of country X.

+
+?- capital('Ireland', M).
+  Y = 'Dublin'.
+
+

Useful facts are given as country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/capital_2/sl.py b/prolog/problems/world_data/capital_2/sl.py new file mode 100644 index 0000000..7b14a70 --- /dev/null +++ b/prolog/problems/world_data/capital_2/sl.py @@ -0,0 +1,13 @@ +name = 'capital/2' +slug = 'glavna mesta' + +description = '''\ +

capital(X, Y): država X ima glavno mesto Y.

+
+?- capital('Ireland', Y).
+  Y = 'Dublin'.
+
+

Uporabna dejstva so podana v obliki country(Name, ID, Capital, CapitalProvince, Size, Population).

+''' + +hint = {} diff --git a/prolog/problems/world_data/flows_2/common.py b/prolog/problems/world_data/flows_2/common.py new file mode 100644 index 0000000..a3cf79b --- /dev/null +++ b/prolog/problems/world_data/flows_2/common.py @@ -0,0 +1,51 @@ +from operator import itemgetter +import socket +import prolog.engine +import prolog.util +from server.hints import Hint +import server.problems + +id = 10009 +number = 90 +visible = True +facts = 'mondial' + +solution = '''\ +flows(River, Sea) :- + river(River, _, _, Sea, _, _, _, _, _, _, _, _), + Sea \= null. +flows(River, Sea) :- + river(River, River2, _, _, _, _, _, _, _, _, _, _), + River2 \= null, + flows(River2, Sea). +''' + +hint_type = { +} + +test_cases = [ + ("flows('Rhone', X)", [{'X': "'Mediterranean Sea'"}]), + ("flows(X, 'Java Sea')", [{'X': "'Mahakam'"}, {'X': "'Barito'"}]), + ("flows('Drau', X)", [{'X': "'Black Sea'"}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=2.0, inference_limit=None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + if n_correct == len(test_cases): + hints += [{'id': 'final_hint'}] + return n_correct, len(test_cases), hints diff --git a/prolog/problems/world_data/flows_2/en.py b/prolog/problems/world_data/flows_2/en.py new file mode 100644 index 0000000..f108001 --- /dev/null +++ b/prolog/problems/world_data/flows_2/en.py @@ -0,0 +1,20 @@ +name = 'flows/2' +slug = '' + +description = '''\ +

flows(X, Y): the river X flows to sea Y. +The predicate should follow the flow from X through different rivers +until it reaches a sea - for example, Drina flows into Save, which flows into Donau, +ending in the Black Sea:

+
+?- flows('Drina', Y).
+  Y = 'Black Sea'.
+
+

River data is given by the predicate

+
+river(Name, FlowsToRiver, FlowsToLake, FlowsToSea, Length, Area,
+      SourceLat, SourceLon, SourceElevation, MouthLat, MouthLon).
+
+''' + +hint = {} diff --git a/prolog/problems/world_data/flows_2/sl.py b/prolog/problems/world_data/flows_2/sl.py new file mode 100644 index 0000000..ef46f6b --- /dev/null +++ b/prolog/problems/world_data/flows_2/sl.py @@ -0,0 +1,34 @@ +name = 'flows/2' +slug = '' + +description = '''\ +

flows(X, Y): reka X se izliva v morje Y. +Predikat naj sledi toku skozi različne reke - Drina se npr. priključi Savi, +ki se priključi Donavi, ki teče v Črno morje, zato naj program odgovori tako:

+
+?- flows('Drina', Y).
+  Y = 'Black Sea'.
+
+

Podatki o rekah so predstavljeni s predikatom

+
+river(Name, FlowsToRiver, FlowsToLake, FlowsToSea, Length, Area,
+      SourceLat, SourceLon, SourceElevation, MouthLat, MouthLon).
+
+

Za vsako reko je podan največ en izmed argumentov FlowsToRiver, +FlowsToLake in FlowsToSea, ki pove, v katero reko, +jezero oziroma morje se izliva; ostala dva argumenta pa sta null. +''' + +plan = [ + '''\ +

Reke, ki se izlivajo neposredno v morje, lahko dobimo s poizvedbo:

+
+?- river(River, _, _, Sea, _, _, _, _, _, _, _, _), Sea \= null.
+  River = 'Thjorsa', Sea = 'Atlantic Ocean' ;
+  River = 'Thames', Sea = 'North Sea' ;
+  …
+
+''', +] + +hint = {} diff --git a/prolog/problems/world_data/people_in_capitals_1/common.py b/prolog/problems/world_data/people_in_capitals_1/common.py new file mode 100644 index 0000000..b38a96f --- /dev/null +++ b/prolog/problems/world_data/people_in_capitals_1/common.py @@ -0,0 +1,48 @@ +from operator import itemgetter +import socket +import prolog.engine +import prolog.util +from server.hints import Hint +import server.problems + +id = 10003 +number = 30 +visible = True +facts = 'mondial' + +solution = '''\ +people_in_capitals(N) :- + findall(Pop, + (country(_,_,Capital,_,_,_), + city(Capital,_,_,Pop,_,_,_), + number(Pop)), L), + sum(L, N). +''' + +hint_type = { +} + +test_cases = [ + ('people_in_capitals(N)', [{'N': '316277426'}]), +] + +def test(code, aux_code): + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=5.0) + if engine_id is not None and 'error' not in map(itemgetter(0), output): + # Engine successfully created, and no syntax error in program. + for query, answers in test_cases: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0, inference_limit=None): + n_correct += 1 + except socket.timeout: + pass + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + if n_correct == len(test_cases): + hints += [{'id': 'final_hint'}] + return n_correct, len(test_cases), hints diff --git a/prolog/problems/world_data/people_in_capitals_1/en.py b/prolog/problems/world_data/people_in_capitals_1/en.py new file mode 100644 index 0000000..1c8b93d --- /dev/null +++ b/prolog/problems/world_data/people_in_capitals_1/en.py @@ -0,0 +1,11 @@ +name = 'people_in_capitals/1' +slug = 'number of people living in capitals' + +description = '''\ +

people_in_capitals(N): N is the total number of people living in capital cities of the world.

+

Useful predicates:

+
  • country(Name, ID, Capital, CapitalProvince, Size, Population)
  • +
  • city(Name, Country ID, Province, Population, Lat, Lon, Elevation).
  • +''' + +hint = {} diff --git a/prolog/problems/world_data/people_in_capitals_1/sl.py b/prolog/problems/world_data/people_in_capitals_1/sl.py new file mode 100644 index 0000000..a72ba5e --- /dev/null +++ b/prolog/problems/world_data/people_in_capitals_1/sl.py @@ -0,0 +1,11 @@ +name = 'people_in_capitals/1' +slug = 'število prebivalcev glavnih mest' + +description = '''\ +

    people_in_capitals(N): N je število ljudi, ki živijo v glavnih mestih po svetu.

    +

    Uporabni predikati:

    +
  • country(Name, ID, Capital, CapitalProvince, Size, Population)
  • +
  • city(Name, Country ID, Province, Population, Lat, Lon, Elevation).
  • +''' + +hint = {} -- cgit v1.2.1 From 08cc8882bf1a1d77c192726954883bfd5bff7a5a Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 16:26:31 +0200 Subject: Prolog: fix world_data problem IDs and numbers --- prolog/problems/world_data/grant_1/common.py | 4 ++-- prolog/problems/world_data/holiday_2/common.py | 4 ++-- prolog/problems/world_data/landlocked2_1/common.py | 4 ++-- prolog/problems/world_data/similar_population_3/common.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/grant_1/common.py b/prolog/problems/world_data/grant_1/common.py index aa016b0..8c032a3 100644 --- a/prolog/problems/world_data/grant_1/common.py +++ b/prolog/problems/world_data/grant_1/common.py @@ -4,8 +4,8 @@ import prolog.engine from server.hints import Hint import server.problems -id = 12536 -number = 20 +id = 10007 +number = 70 visible = True facts = 'mondial' diff --git a/prolog/problems/world_data/holiday_2/common.py b/prolog/problems/world_data/holiday_2/common.py index 0e7ba8f..0ccf8c2 100644 --- a/prolog/problems/world_data/holiday_2/common.py +++ b/prolog/problems/world_data/holiday_2/common.py @@ -4,8 +4,8 @@ import prolog.engine from server.hints import Hint import server.problems -id = 12529 -number = 10 +id = 10005 +number = 50 visible = True facts = 'mondial' diff --git a/prolog/problems/world_data/landlocked2_1/common.py b/prolog/problems/world_data/landlocked2_1/common.py index 5c17886..3c5b3e2 100644 --- a/prolog/problems/world_data/landlocked2_1/common.py +++ b/prolog/problems/world_data/landlocked2_1/common.py @@ -4,8 +4,8 @@ import prolog.engine from server.hints import Hint import server.problems -id = 12539 -number = 39 +id = 10006 +number = 60 visible = True facts = 'mondial' diff --git a/prolog/problems/world_data/similar_population_3/common.py b/prolog/problems/world_data/similar_population_3/common.py index 2226a30..a984f1c 100644 --- a/prolog/problems/world_data/similar_population_3/common.py +++ b/prolog/problems/world_data/similar_population_3/common.py @@ -4,8 +4,8 @@ import prolog.engine from server.hints import Hint import server.problems -id = 12519 -number = 40 +id = 10008 +number = 80 visible = True facts = 'mondial' -- cgit v1.2.1 From f4216395fcf2fec2f512d0c88f53021dfda6ad7b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 16:28:43 +0200 Subject: Prolog: change ID and number for whoSpeaks_3 --- prolog/problems/world_data/whoSpeaks_3/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/whoSpeaks_3/common.py b/prolog/problems/world_data/whoSpeaks_3/common.py index b80e5d5..79e4410 100644 --- a/prolog/problems/world_data/whoSpeaks_3/common.py +++ b/prolog/problems/world_data/whoSpeaks_3/common.py @@ -4,8 +4,8 @@ import prolog.engine from server.hints import Hint import server.problems -id = 12549 -number = 369 +id = 10004 +number = 40 visible = True facts = 'mondial' -- cgit v1.2.1 From f7307b5a3226f7768176325550682d04a372bef0 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 16:40:11 +0200 Subject: Prolog: reorder problem groups --- prolog/problems/algol/common.py | 2 +- prolog/problems/clp_fd/common.py | 2 +- prolog/problems/clp_r/common.py | 2 +- prolog/problems/dcg/common.py | 2 +- prolog/problems/denotational_semantics/common.py | 2 +- prolog/problems/family_relations/common.py | 2 +- prolog/problems/license_plates/common.py | 2 +- prolog/problems/lists/common.py | 2 +- prolog/problems/lists_advanced/common.py | 2 +- prolog/problems/sets/common.py | 2 +- prolog/problems/sorting/common.py | 2 +- prolog/problems/trees/common.py | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/algol/common.py b/prolog/problems/algol/common.py index 2885432..0085483 100644 --- a/prolog/problems/algol/common.py +++ b/prolog/problems/algol/common.py @@ -1,2 +1,2 @@ id = 1001 -number = 12 +number = 130 diff --git a/prolog/problems/clp_fd/common.py b/prolog/problems/clp_fd/common.py index eec07f0..4f3096c 100644 --- a/prolog/problems/clp_fd/common.py +++ b/prolog/problems/clp_fd/common.py @@ -1,2 +1,2 @@ id = 8 -number = 9 +number = 100 diff --git a/prolog/problems/clp_r/common.py b/prolog/problems/clp_r/common.py index 2238250..fe95da6 100644 --- a/prolog/problems/clp_r/common.py +++ b/prolog/problems/clp_r/common.py @@ -1,2 +1,2 @@ id = 9 -number = 8 +number = 90 diff --git a/prolog/problems/dcg/common.py b/prolog/problems/dcg/common.py index a55cdef..8a0f57f 100644 --- a/prolog/problems/dcg/common.py +++ b/prolog/problems/dcg/common.py @@ -1,2 +1,2 @@ id = 10 -number = 10 +number = 110 diff --git a/prolog/problems/denotational_semantics/common.py b/prolog/problems/denotational_semantics/common.py index 86c7532..9e282d0 100644 --- a/prolog/problems/denotational_semantics/common.py +++ b/prolog/problems/denotational_semantics/common.py @@ -1,2 +1,2 @@ id = 11 -number = 11 +number = 120 diff --git a/prolog/problems/family_relations/common.py b/prolog/problems/family_relations/common.py index 5aff819..611c856 100644 --- a/prolog/problems/family_relations/common.py +++ b/prolog/problems/family_relations/common.py @@ -1,2 +1,2 @@ id = 1 -number = 1 +number = 10 diff --git a/prolog/problems/license_plates/common.py b/prolog/problems/license_plates/common.py index e35a349..42bf4e7 100644 --- a/prolog/problems/license_plates/common.py +++ b/prolog/problems/license_plates/common.py @@ -1,2 +1,2 @@ id = 7 -number = 7 +number = 80 diff --git a/prolog/problems/lists/common.py b/prolog/problems/lists/common.py index 4788fc4..ed64b41 100644 --- a/prolog/problems/lists/common.py +++ b/prolog/problems/lists/common.py @@ -1,2 +1,2 @@ id = 2 -number = 2 +number = 30 diff --git a/prolog/problems/lists_advanced/common.py b/prolog/problems/lists_advanced/common.py index d4e77fa..f25a4a0 100644 --- a/prolog/problems/lists_advanced/common.py +++ b/prolog/problems/lists_advanced/common.py @@ -1,2 +1,2 @@ id = 1000 -number = 3 +number = 40 diff --git a/prolog/problems/sets/common.py b/prolog/problems/sets/common.py index b3335ec..1110721 100644 --- a/prolog/problems/sets/common.py +++ b/prolog/problems/sets/common.py @@ -1,2 +1,2 @@ id = 5 -number = 5 +number = 60 diff --git a/prolog/problems/sorting/common.py b/prolog/problems/sorting/common.py index 4e5aa88..cbe679b 100644 --- a/prolog/problems/sorting/common.py +++ b/prolog/problems/sorting/common.py @@ -1,2 +1,2 @@ id = 3 -number = 4 +number = 50 diff --git a/prolog/problems/trees/common.py b/prolog/problems/trees/common.py index 9cf57f5..7a974d4 100644 --- a/prolog/problems/trees/common.py +++ b/prolog/problems/trees/common.py @@ -1,2 +1,2 @@ id = 6 -number = 6 +number = 70 -- cgit v1.2.1 From 1715d2bfca32984db436acb89a32d3bf6a5ca981 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 16:40:31 +0200 Subject: Prolog: add database description for world_data --- prolog/problems/world_data/intro_sl.html | 48 ++++++++++++++++++++++++++++++++ prolog/problems/world_data/sl.py | 9 +++--- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 prolog/problems/world_data/intro_sl.html (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/intro_sl.html b/prolog/problems/world_data/intro_sl.html new file mode 100644 index 0000000..2d27780 --- /dev/null +++ b/prolog/problems/world_data/intro_sl.html @@ -0,0 +1,48 @@ + + + + + Prolog: države sveta + + + + + +

    Prolog: države sveta

    +

    +Podatkovna baza za ta sklop vsebuje podatke o državah in geografskih +značilnostih iz CIA World Factbook. Dejstva so podana z naslednjimi predikati: +

    + +
    +country(Name, Code, Capital, Province, Area, Population)
    +population(CountryCode, GrowthRate, Births)
    +economy(CountryCode, GDP, Agriculture, Services, Industry, GDPperCapita, Inflation, Unemployment)
    +language(CountryCode, Language, Percentage)
    +ethnicGroup(CountryCode, Ethnicity, Percentage)
    +religion(CountryCode, Religion, Percentage)
    +borders(CountryCode1, CountryCode2, Length)
    +continent(Name, Area)
    +encompasses(CountryCode, Continent, Percentage)
    +city(Name, CountryCode, Province, Population, Latitude, Longitude, Elevation)
    +cityothername(Name, CountryCode, Province, OtherName)
    +province(Name, CountryCode, Population, Area, Capital, CapitalProvince)
    +provinceothername(Name, CountryCode, OtherName)
    +sea(Name, Depth)
    +river(Name, FlowsToRiver, FlowsToLake, FlowsToSea, Length, Basin,
    +      SourceLatitude, SourceLongitude, SourceName, SourceElevation,
    +      MouthLatitude, MouthLongitude)
    +lake(Name, Area, Depth, Elevation, Type, River, Latitude, Longitude)
    +riverthrough(River, Lake)
    +island(Name, Group, Area, Elevation, Type, Latitude, Longitude)
    +mountain(Name, Range, Height, Type, Latitude, Longitude)
    +desert(Name, Area, Longitude, Latitude, Longitude)
    +geo_sea(Sea, CountryCode, Province)
    +mergesWith(Sea1, Sea2)
    +located(City, Province, CountryCode, River, Lake, Sea)
    +islandIn(Island, Sea, Lake, River)
    +mountainOnIsland(Mountain, Island)
    +
    + + + diff --git a/prolog/problems/world_data/sl.py b/prolog/problems/world_data/sl.py index a2f3f71..9796f98 100644 --- a/prolog/problems/world_data/sl.py +++ b/prolog/problems/world_data/sl.py @@ -1,9 +1,10 @@ name = 'Države sveta' description = '''\

    -Naučimo se vprašati prolog po različnih dejstvih o našem svetu, npr. skozi katere države teče neka reka ali -kateri dve državi sta si čimbolj podobni po številu prebivalcev. Za ta namen je naložena baza podatkov iz -almanaha svetovnih dejstev "The World Factbook". +Naučimo se vprašati prolog po različnih dejstvih o našem svetu, npr. skozi +katere države teče neka reka ali kateri dve državi sta si čimbolj podobni po +številu prebivalcev. Za ta namen je naložena +baza podatkov +iz almanaha svetovnih dejstev "The World Factbook".

    ''' - -- cgit v1.2.1 From ccd7f9701b43c19546e9e36906c1be47a850b73b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 18 Oct 2016 19:16:10 +0200 Subject: Prolog: fix world_data group ID --- prolog/problems/world_data/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/common.py b/prolog/problems/world_data/common.py index c13c356..006b9f5 100644 --- a/prolog/problems/world_data/common.py +++ b/prolog/problems/world_data/common.py @@ -1,2 +1,2 @@ -id = 1001 +id = 1002 number = 20 -- cgit v1.2.1