Вспоминается ban request на gen-a или acez-а (точно не помню): "парень вообще ахренел, летает себе с бешеной скоростью, рушит блоки одним ударом, вытаскивает все блоки подряд, срочно забаньте", как-то так) --- Добавлено в 2012-09-11 14:57:28 Решил, используя swi-prolog.  Программа на прологе neighbors(A,B) :- L=[1,2,3,4,5], member(A,L),member(B,L),(A is B+1 ;A is B-1 ). left_right(A,B) :- L=[1,2,3,4,5], member(A,L),member(B,L), A is B-1 .
print_list(Name, Vars_list, Names_list) :- nth1(Index1, Vars_list, 1), nth1(Index2, Vars_list, 2), nth1(Index3, Vars_list, 3), nth1(Index4, Vars_list, 4), nth1(Index5, Vars_list, 5), nth1(Index1, Names_list, Value1), nth1(Index2, Names_list, Value2), nth1(Index3, Names_list, Value3), nth1(Index4, Names_list, Value4), nth1(Index5, Names_list, Value5), format("~0|~s~15|~p~30|~p~40|~p~50|~p~60|~p\n", [Name, Value1, Value2, Value3, Value4, Value5]).
solve :- R_T800 = 3, P_Blacksmith = 1, P_Engineer = H_Stone, P_Miner = S_Helper, P_Builder = R_Human, H_Obsidian = R_Vampir, P_Medic = C_Pumpkin, S_Noob = C_Wheat, C_Tomato = H_Wood, R_Ogre = C_Cacti, left_right(H_SandStone, H_Obsidian), neighbors(H_Marble, P_Blacksmith), neighbors(C_Melon, S_Admin), neighbors(C_Tomato, S_Coder), % defining lists Profs = [P_Engineer, P_Miner, P_Blacksmith, P_Medic, P_Builder], Houses = [H_Stone, H_Obsidian, H_SandStone, H_Wood, H_Marble], Statuses = [S_Noob, S_Helper, S_Admin, S_Coder, S_Cheater], Races = [R_Vampir, R_T800, R_Ogre, R_Human, R_Elf], Crops = [C_Wheat, C_Tomato, C_Melon, C_Cacti, C_Pumpkin],
% defining names Profs_names = ['Engineer', 'Miner', 'Blacksmith', 'Medic', 'Builder'], Houses_names = ['Stone', 'Obsidian', 'SandStone', 'Wood', 'Marble'], Statuses_names = ['Noob', 'Helper', 'Admin', 'Coder', 'Cheater'], Races_names = ['Vampir', 'T800', 'Ogre', 'Human', 'Elf'], Crops_names = ['Wheat', 'Tomato', 'Melon', 'Cacti', 'Pumpkin'], % do permutations permutation(Profs, [1, 2, 3, 4, 5]), permutation(Houses, [1, 2, 3, 4, 5]), permutation(Statuses, [1, 2, 3, 4, 5]), permutation(Races, [1, 2, 3, 4, 5]), permutation(Crops, [1, 2, 3, 4, 5]), % now print results print_list("Proffesions: ", Profs, Profs_names), print_list("Houses: ", Houses, Houses_names), print_list("Statuses: ", Statuses, Statuses_names), print_list("Races: ", Races, Races_names), print_list("Crops: ", Crops, Crops_names).
 Лог  Результаты Единственный возможный результат:
Админ — кузнец, эльф, живет в деревянном домике, выращивает помидоры. Прогер — строитель, человек, живет в мраморном домике, выращивает арбузы. Нуб — инженер (!), Т800 (!!!), живет в каменном доме, выращивает пшеницу. Хелпер — шахтер, огр, живет в доме из песчаника, выращивает кактусы. Читер — медик, вампир, живет в обсидиановом доме (что не удивительно), выращивает тыкву.
|