10/29/2022 0 Comments Block world problem in prolog![]() ![]() It tokeĪround 2 minutes to find the solution, and take around 6 minutes to prove that there is on other % 591 inferences, 0.000 CPU in 0.000 seconds ( 98 % CPU, 17776040 Lips ).ĭifficulty level 10/10 Killer Sudoku from the daily killer sudoku website. ?- problem ( wiki, Rows, Splits, Sums ), killer_sudoku ( Rows, Splits, Sums ), | append ( Rows, Vs ), time ( label ( Vs )), maplist ( portray_clause, Rows ). Problems, it may take minutes even hours to solve. How well the solver can tackle the problems.įor the problem from wiki, it solve the problem instantly, but for some harder So I do some test to solve various Killer Sudoku I found from online, and see The hardest one may take hours even days to crack. Varies, simple Killer Sudoku may even be simpler than normal Sudoku, but #BLOCK WORLD PROBLEM IN PROLOG CODE#Lines more code than the standard Sudoku solver, and we can already solveĪnd also we should notice, despite it’s name, Killer Sudoku’s difficult levels ![]() Sum information, and build the constraint relation for them. So we only need to pass the additional cages’ information and their corresponding 9, append ( Splits, Ks ), pairs_keys_values ( Pairs, Ks, Vs ), sort ( 1, Pairs, SortedPairs ), group_pairs_by_key ( SortedPairs, Regions ), maplist ( all_distinct, Rows ), transpose ( Rows, Columns ), maplist ( all_distinct, Columns ), Rows =, blocks ( As, Bs, Cs ), blocks ( Ds, Es, Fs ), blocks ( Gs, Hs, Is ), maplist ( region_constrain ( Sums ), Regions ). killer_sudoku ( Rows, Splits, Sums ) :- length ( Rows, 9 ), maplist ( same_length ( Rows ), Rows ), length ( Splits, 9 ), maplist ( same_length ( Splits ), Splits ), append ( Rows, Vs ), Vs ins 1. region_constrain ( Sums, X - Vs ) :- get_value_by_key ( Sums, X, Value ), all_distinct ( Vs ), sum ( Vs, #=, Value ). get_value_by_key (, X, Y ) :- Z \ = X, get_value_by_key ( Ps, X, Y ). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |