{"id":8368,"date":"2022-09-13T05:54:57","date_gmt":"2022-09-13T00:24:57","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/"},"modified":"2022-09-13T05:54:57","modified_gmt":"2022-09-13T00:24:57","slug":"solved-endview-game-on-gnu-prolog-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/","title":{"rendered":"[Solved] EndView game on gnu Prolog [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-12797874\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"12797874\" data-parentid=\"12797708\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>you must get transpose\/2 from the other question and replace all_distinct\/1 with fd_all_distinct\/2.<\/p>\n<p>Also, get writeln and replace write here <code>maplist(write, [R1,R2,R3,R4]).<\/code><\/p>\n<p><strong>edit<\/strong> A simple solution would be to extend the &#8216;encoding&#8217; of the finite domain, reserving <strong>two<\/strong> digits as blanks, instead of just the 0, and extending the logic already seen in answer posted to the other question.<\/p>\n<p>For analogy I&#8217;ll call third_end_view, and would be (in <strong>Gnu<\/strong> Prolog)<\/p>\n<pre><code>\/*  File:    third_end_view_puzzle.pl\n    Author:  Carlo,,,\n    Created: Oct  10 2012\n    Purpose: help to solve extended Second End View puzzle\n             https:\/\/stackoverflow.com\/q\/12797708\/874024\n*\/\n\n:- include(transpose) .\n\nthird_end_view_puzzle :-\n\n    length(Rows, 8),\n    maplist(gen_row(8), Rows),\n    transpose(Rows, Cols),\n\n    maplist(fd_all_different, Rows),\n    maplist(fd_all_different, Cols),\n\n    Rows = [R1,R2,R3,R4,R5,R6,R7,R8],\n    Cols = [C1,C2,C3,C4,C5,C6,C7,C8],\n\n    start(R1, 4),\n    start(R2, 2),\n    start(R3, 3),\n    start(R4, 5),\n    start(R5, 3),\n    finish(R1, 6),\n    finish(R2, 4),\n    finish(R3, 2),\n    finish(R5, 1),\n    finish(R7, 2),\n\n\n    start(C2, 3),\n    start(C3, 4),\n    start(C4, 3),\n    start(C5, 5),\n%   start(C6, 4),\n    start(C7, 1),\n%   finish(C1, 3),\n%   finish(C2, 2),\n    finish(C3, 5),\n    finish(C4, 5),\n    finish(C5, 6),\n    finish(C6, 1),\n    finish(C7, 4),\n\n    maplist(fd_labeling, Rows),\n    nl,\n    maplist(out_row, Rows).\n\ngen_row(N, Ls) :-\n    length(Ls, N),\n    fd_domain(Ls, 1, N).\n\nout_row([]) :- nl.\nout_row([H|T]) :-\n    (H &gt;= 7 -&gt; write('-') ; write(H)),\n    write(' '),\n    out_row(T).\n\n% constraint: Num is max third in that direction\nstart(Vars, Num) :-\n    Vars = [A,B,C|_],\n    A #= Num #\\\/ (A #&gt;= 7 #\/\\ B #= Num) #\\\/ (A #&gt;= 7 #\/\\ B #&gt;= 7 #\/\\ C #= Num).\n\nfinish(Var, Num) :-\n    reverse(Var, Rev), start(Rev, Num).\n<\/code><\/pre>\n<p>I have used a simpler condition, without reification, to state the &#8216;third view from direction&#8217;.<\/p>\n<p>As previously, you see that some constraint (those commented out) make the puzzle unsolvable.<\/p>\n<p>test:<\/p>\n<pre><code>| ?- third_end_view_puzzle.  \n\n4 3 - - 5 2 1 6 \n2 1 - 3 - 5 6 4 \n3 5 4 1 - 6 2 - \n5 4 6 2 1 3 - - \n- - 3 6 2 4 5 1 \n1 6 2 4 3 - - 5 \n6 - 1 5 4 - 3 2 \n- 2 5 - 6 1 4 3 \n\ntrue ? \n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">4<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved EndView game on gnu Prolog [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] you must get transpose\/2 from the other question and replace all_distinct\/1 with fd_all_distinct\/2. Also, get writeln and replace write here maplist(write, [R1,R2,R3,R4]). edit A simple solution would be to extend the &#8216;encoding&#8217; of the finite domain, reserving two digits as blanks, instead of just the 0, and extending the logic already seen in answer &#8230; <a title=\"[Solved] EndView game on gnu Prolog [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\" aria-label=\"More on [Solved] EndView game on gnu Prolog [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[2373,1425,2171],"class_list":["post-8368","post","type-post","status-publish","format-standard","hentry","category-solved","tag-clpfd","tag-gnu","tag-prolog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] EndView game on gnu Prolog [closed] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] EndView game on gnu Prolog [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] you must get transpose\/2 from the other question and replace all_distinct\/1 with fd_all_distinct\/2. Also, get writeln and replace write here maplist(write, [R1,R2,R3,R4]). edit A simple solution would be to extend the &#8216;encoding&#8217; of the finite domain, reserving two digits as blanks, instead of just the 0, and extending the logic already seen in answer ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-13T00:24:57+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] EndView game on gnu Prolog [closed]\",\"datePublished\":\"2022-09-13T00:24:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\"},\"wordCount\":119,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"clpfd\",\"gnu\",\"prolog\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\",\"name\":\"[Solved] EndView game on gnu Prolog [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-13T00:24:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] EndView game on gnu Prolog [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] EndView game on gnu Prolog [closed] - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] EndView game on gnu Prolog [closed] - JassWeb","og_description":"[ad_1] you must get transpose\/2 from the other question and replace all_distinct\/1 with fd_all_distinct\/2. Also, get writeln and replace write here maplist(write, [R1,R2,R3,R4]). edit A simple solution would be to extend the &#8216;encoding&#8217; of the finite domain, reserving two digits as blanks, instead of just the 0, and extending the logic already seen in answer ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/","og_site_name":"JassWeb","article_published_time":"2022-09-13T00:24:57+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] EndView game on gnu Prolog [closed]","datePublished":"2022-09-13T00:24:57+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/"},"wordCount":119,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["clpfd","gnu","prolog"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/","name":"[Solved] EndView game on gnu Prolog [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-13T00:24:57+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-endview-game-on-gnu-prolog-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] EndView game on gnu Prolog [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=8368"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8368\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=8368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=8368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=8368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}