26

Re: Re: Gold ingots of Geriona

Hello, Kodt, you wrote: Hello, the Corkcrew, you wrote:> I too found for 2 weighings!>> If you did not tell that it exists, would not find...> Chort. Badly removed a spoiler the Pancake... If you did not tell that you badly removed a spoiler, I would not guess now to look at your decision Well and to tell the truth, I rose on shoulders of giants: looked, what failing responses were in comments at Knopa, and understood, they there did not use what possibility. And I wrote the program which Egor wanted. Then looked at your post about two weighings. And then (after the fifth attempt) program start received at last a normal variant.

27

Re: Re: Gold ingots of Geriona

Hello, Kodt, you wrote: So, an etude for programmers! And show the program, whether that. 1) +100500 2) IMHO the Author: Erop Date: 07.02 22:44, it is more interesting to write the program which checks decisions...

28

Re: Re: Gold ingots of Geriona

Hello, Kodt, you wrote: And show the program, whether that. Yes it is not a pity to me. But as always everything is tangled, made hastily. Added comments. It is the program for decision check, instead of for decision search. At us weighings are given. For a decision refutation we try to find a counterexample - such weight of ingots which transit these weighings and thus an ingot 1 will have other weight. All swaps of scales of ingots (11 are checked! Variants). It is deduced "" or a counterexample - as it is necessary to change weight. import qualified Data. Map as Map import Data. List - the list of weighings actions = [[1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 6], [1, 3, 6], [1, 4, 6]] - is launched main = find_kontrprimer actions of Nothing-> putStrLn "ok" Just mapper-> putStrLn $ "bad solve\n" ++ show mapper - the maximum weight which withstands a bag bag_max_weight = 11 - ingots boxes = [1. . 11] - check that the bag will not be torn bag_unhurt acts = all (<= bag_max_weight) $ map sum acts - swap of ingots in weighings convert_boxes acts mapper = map (map (mapper Map.!)) acts - the list of swaps of scales of ingots, the list of dictionaries (old weight => new weight) mappers = [Map.fromList $ zip boxes new_boxes | new_boxes <- permutation boxes] - check that the given swap is a counterexample for weighings - i.e. at all weighings the bag was not tore also it became possible when the ingot 1 has weight distinct from 1 is_kontrprimer mapper acts = (mapper Map.! 1 / = 1) && (bag_unhurt $ convert_boxes acts mapper) - counterexample search find_kontrprimer acts = find is_kontrprimer mappers UPDATE: made small refactoring that it was more clear

29

Re: Re: Gold ingots of Geriona

Hello, Erop, you wrote: E> 2) IMHO the Author: Erop Date: 07.02 22:44, it is more interesting to write the program which checks decisions... You meant on the contrary? More interesting the program which searches for decisions (or proves impossibility).

30

Re: Re: Gold ingots of Geriona

Hello, the Corkcrew, you wrote: You meant on the contrary? More interesting the program which searches for decisions (or proves impossibility). About proves impossibility - the most interesting. And here that, which checks more artfully, that which searches...