From 72a899429bd5c219c718665c037a5e46ad143ed2 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 6 Mar 2017 19:55:07 +0100 Subject: World Data exercises updated. --- prolog/problems/world_data/common.py | 2 +- prolog/problems/world_data/flows_2/common.py | 2 +- prolog/problems/world_data/flows_2/en.py | 2 +- prolog/problems/world_data/flows_2/sl.py | 2 +- prolog/problems/world_data/grant_1/common.py | 2 +- prolog/problems/world_data/holiday_2/en.py | 2 +- prolog/problems/world_data/holiday_2/sl.py | 2 +- prolog/problems/world_data/intro_sl.html | 2 +- .../problems/world_data/people_in_capitals_1/common.py | 8 ++++---- .../problems/world_data/similar_population_3/common.py | 17 ++++++++++------- 10 files changed, 22 insertions(+), 19 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/world_data/common.py b/prolog/problems/world_data/common.py index 0d2730a..006b9f5 100644 --- a/prolog/problems/world_data/common.py +++ b/prolog/problems/world_data/common.py @@ -1,2 +1,2 @@ id = 1002 -number = 140 +number = 20 diff --git a/prolog/problems/world_data/flows_2/common.py b/prolog/problems/world_data/flows_2/common.py index a3cf79b..a3ddc7a 100644 --- a/prolog/problems/world_data/flows_2/common.py +++ b/prolog/problems/world_data/flows_2/common.py @@ -6,7 +6,7 @@ from server.hints import Hint import server.problems id = 10009 -number = 90 +number = 55 visible = True facts = 'mondial' diff --git a/prolog/problems/world_data/flows_2/en.py b/prolog/problems/world_data/flows_2/en.py index f108001..355b238 100644 --- a/prolog/problems/world_data/flows_2/en.py +++ b/prolog/problems/world_data/flows_2/en.py @@ -13,7 +13,7 @@ ending in the Black Sea:

River data is given by the predicate

 river(Name, FlowsToRiver, FlowsToLake, FlowsToSea, Length, Area,
-      SourceLat, SourceLon, SourceElevation, MouthLat, MouthLon).
+      SourceLat, SourceLon, SourceName, SourceElevation, MouthLat, MouthLon).
 
''' diff --git a/prolog/problems/world_data/flows_2/sl.py b/prolog/problems/world_data/flows_2/sl.py index ef46f6b..7af2a7d 100644 --- a/prolog/problems/world_data/flows_2/sl.py +++ b/prolog/problems/world_data/flows_2/sl.py @@ -12,7 +12,7 @@ ki se priključi Donavi, ki teče v Črno morje, zato naj program odgovori tako:

Podatki o rekah so predstavljeni s predikatom

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

Za vsako reko je podan največ en izmed argumentov FlowsToRiver, FlowsToLake in FlowsToSea, ki pove, v katero reko, diff --git a/prolog/problems/world_data/grant_1/common.py b/prolog/problems/world_data/grant_1/common.py index 8c032a3..4b5918a 100644 --- a/prolog/problems/world_data/grant_1/common.py +++ b/prolog/problems/world_data/grant_1/common.py @@ -5,7 +5,7 @@ from server.hints import Hint import server.problems id = 10007 -number = 70 +number = 45 visible = True facts = 'mondial' diff --git a/prolog/problems/world_data/holiday_2/en.py b/prolog/problems/world_data/holiday_2/en.py index ecb248a..a7f4f07 100644 --- a/prolog/problems/world_data/holiday_2/en.py +++ b/prolog/problems/world_data/holiday_2/en.py @@ -10,7 +10,7 @@ ki ima morje.

Neighbour = 'Italy' ; Neighbour = 'Croatia' -

Prav ti znajo priti podatki v obliki borders(Country1, Country2, LenOfBorder) in +

Prav ti znajo priti podatki v obliki borders(CountryCode1, CountryCode2, LenOfBorder) in geo_sea(Sea, CountryCode, Province).

''' diff --git a/prolog/problems/world_data/holiday_2/sl.py b/prolog/problems/world_data/holiday_2/sl.py index ecb248a..a7f4f07 100644 --- a/prolog/problems/world_data/holiday_2/sl.py +++ b/prolog/problems/world_data/holiday_2/sl.py @@ -10,7 +10,7 @@ ki ima morje.

Neighbour = 'Italy' ; Neighbour = 'Croatia' -

Prav ti znajo priti podatki v obliki borders(Country1, Country2, LenOfBorder) in +

Prav ti znajo priti podatki v obliki borders(CountryCode1, CountryCode2, LenOfBorder) in geo_sea(Sea, CountryCode, Province).

''' diff --git a/prolog/problems/world_data/intro_sl.html b/prolog/problems/world_data/intro_sl.html index 2d27780..12a9701 100644 --- a/prolog/problems/world_data/intro_sl.html +++ b/prolog/problems/world_data/intro_sl.html @@ -36,7 +36,7 @@ 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) +desert(Name, Area, Latitude, Longitude) geo_sea(Sea, CountryCode, Province) mergesWith(Sea1, Sea2) located(City, Province, CountryCode, River, Lake, Sea) diff --git a/prolog/problems/world_data/people_in_capitals_1/common.py b/prolog/problems/world_data/people_in_capitals_1/common.py index b38a96f..cda2e06 100644 --- a/prolog/problems/world_data/people_in_capitals_1/common.py +++ b/prolog/problems/world_data/people_in_capitals_1/common.py @@ -13,17 +13,17 @@ facts = 'mondial' solution = '''\ people_in_capitals(N) :- findall(Pop, - (country(_,_,Capital,_,_,_), - city(Capital,_,_,Pop,_,_,_), + (country(_,ID,Capital,_,_,_), + city(Capital,ID,_,Pop,_,_,_), number(Pop)), L), - sum(L, N). + sum_list(L, N). ''' hint_type = { } test_cases = [ - ('people_in_capitals(N)', [{'N': '316277426'}]), + ('people_in_capitals(N)', [{'N': '313163317'}]), # old solution without equal IDs [{'N': '316277426'}] ] def test(code, aux_code): diff --git a/prolog/problems/world_data/similar_population_3/common.py b/prolog/problems/world_data/similar_population_3/common.py index a984f1c..b8a391c 100644 --- a/prolog/problems/world_data/similar_population_3/common.py +++ b/prolog/problems/world_data/similar_population_3/common.py @@ -11,19 +11,22 @@ 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|_]). + country(X,_,_,_,_,PX), + country(Y,_,_,_,_,PY), + X \== Y, + D is abs(PX-PY), + \+ (country(Z,_,_,_,_,PZ), Z \== X, D > abs(PX-PZ)). ''' test_cases = [ - ('simpop(X, Y, D)', - [{'X': "'Grenada'", 'Y': "'Tonga'", 'D': '76'}]), + ("simpop('Tonga', Y, D)", + [{'Y': "'Grenada'", 'D': '76'}]), ("simpop('Slovenia', Y, D)", [{'Y': "'Macedonia'", 'D': '973'}]), - ("simpop(X, 'Australia', D)", - [{'X': "'Taiwan'", 'D': '180541'}]), + ("simpop(X, 'Slovenia', D)", + [{'X': "'Macedonia'", 'D': '973'}, {'X': "'Botswana'", 'D': '20593'}]), ("simpop(X, Y, 1176831)", - [{'X': "'Uzbekistan'", 'Y': "'Venezuela'"}]), + [{'Y': "'Uzbekistan'", 'X': "'Venezuela'"}]), ] def test(code, aux_code): -- cgit v1.2.1