[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-504890-105":59,"doc-detail-504890-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","declaratively-solving-google-code-jam-problems-with-picat","Declaratively solving Google Code Jam problems with Picat","","The paper presents declarative techniques for solving algorithmic tasks from Google Code Jam using the Picat programming language. It focuses on constraint logic programming and tabled logic programming, showing how declarative specifications can either simplify implementations compared with imperative languages or enable direct problem-statement translation into efficiently solvable models. Examples include algorithmic modeling and practical solution fragments.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":40,"@type":76,"position":81},"https://docshare.wps.com/document/research-report/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/declaratively-solving-google-code-jam-problems-with-picat/504890/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/declaratively-solving-google-code-jam-problems-with-picat/504890.png","ImageObject",300,407,{"name":92,"@type":93},"Rizky","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-10-20","2026-10-04",true,{"@type":102,"interactionType":103,"userInteractionCount":52},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What declarative techniques does the paper use with Picat for Google Code Jam problems?","Question",{"text":112,"@type":113},"It uses constraint logic programming and tabled logic programming as declarative techniques for building solvable models.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How does the paper demonstrate Picat syntax before presenting Code Jam problems?",{"text":117,"@type":113},"It presents an implementation of the TPK algorithm in Picat and explains how functions, predicates, list comprehensions, loops, and conditional constructs are expressed in the language.",{"name":119,"@type":110,"acceptedAnswer":120},"What makes the “Triangle Areas” problem suitable for constraint logic programming in the paper?",{"text":121,"@type":113},"The problem has discrete variables, non-linear constraints, and the goal is to find any feasible solution, so the constraints can be modeled declaratively to search for coordinates.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},504890,1791306110,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":39,"category_name":40,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":52,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":39,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":143,"read_time":46},962085564807,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","arXiv : 1504 .00977v 1 [ cs .PL] 4 Apr 2015  \nDeclaratively solving Google Code Jam problems with Picat  \nSergii Dymchenko 1 and Mariia Mykhailova2  \n1 Independent Researcher,  \n[sdymchenko@progopedia.com](sdymchenko@progopedia.com)  \n2 Independent Researcher,  \n[michaylova@gmail.com](michaylova@gmail.com)  \nAbstract. In this paper we present several examples of solving algorithmic problems from the Google Code Jam programming contest with Picat programming language using declarative techniques: constraint logic programming and tabled logic programming. In some cases the use of Picat simpli􀀌es the implementation compared to conventional imperative programming languages, while in others it allows to directly convert the problem statement into an e􀀎ciently solvable declarative problemspeci􀀌cation without inventing an imperative algorithm.  \n1 Introduction  \nGoogle Code Jam3 (GCJ) is one of the biggest programming competitions in the world: almost 50,000 participants registered in 2014, and 25,462 of them solved at least one task.  \nGCJ competitors can use any freely available programming language or system (including Picat 4 described in this paper) . We show examples of solving GCJ problems with Picat using constraint logic programming and tabled logic programming.  \nPicat is a new logic-based multi-paradigm programming language. Picat shares many features with Prolog, especially B-Prolog [4], but also has many distinct features: optional destructive assignments, functions in addition to predicates, explicit non-determinism, list comprehensions [5] .  \nPicat implementation of TPK algorithm  \nTo give an idea of Picat syntax to a reader unfamiliar with the language we present an implementation of TPK algorithm. TPK is an algorithm proposed by D. E. Knuth and L. T. Pardo [2] used to show basic syntax of a programming language. The algorithm allows user to input 11 real numbers (a0 . . . a10 ) . After that for i = 10 . . . 0 (in that order) the algorithm computes value y = f (ai ), where f (t) = p |t| + 5t3 , and outputs a pair (i, y) if y 􀀔 400, or (i, TOO LARGE) otherwise.  \n3 [https://code.google.com/codejam](https://code.google.com/codejam)  \n4 [http://picat-lang.org/](http://picat-lang.org/)  \n1 f(T) = sqrt(abs(T)) + 5 * T**3 .  \n2 main =>  \n3 N = 11,  \n4 As = to_array([read_real() : I in 1 . .N]),  \n5 foreach (I in N   -1   1)  \n6 Y = f(As[I]),  \n7 if Y > 400 then  \n8 printf(\"%w TOO LARGE\\n\", I- 1)  \n9 else  \n10 printf(\"%w %w\\n\", I- 1, Y)  \n11 end  \n12 end .  \nListing 1.1 . TPK algorithm in Picat  \nLine 1 de􀀌nes a function to calculate the value of f (a function in Picat is a special kind of a predicate that always succeeds with a return value) . Lines 2–12 de􀀌ne the main predicate. Line 4 uses list comprehension to read 11 spaceseparated real numbers into array As. Line 5 de􀀌nes a header of foreach loop: I goes from 11 to 1 with the step-1 (in Picat array indices are 1-based) . Lines 6–11 calculate the value of y and print the result using an‘if-then-else’ construct. printf is similar to the corresponding C language function; %w can be seen as a“wildcard” control sequence to output values of di􀀋erent types.  \n2 The Problems  \nFor this section we have chosen a set of GCJ problems from di􀀋erent years to demonstrate di􀀋erent useful aspects of Picat: constraint programming, top-down dynamic programming with tabling, and the planner module.  \nTriangle Areas5  \n“Triangle Areas” is a problem from the round 2 of GCJ 2008 . The problem gives integers N , M and A and asks to 􀀌nd any triangle with vertices in integer points with coordinates 0 􀀔 xi 􀀔 N and 0 􀀔 yi 􀀔 M that has an area of A2 , or to decide that it does not exist.  \n“Triangle Areas” is almost perfect for solving with constraint logic programming. Variables are discrete, constraints are non-linear, and we are looking for any feasible solution. To come up with an e􀀋ective model we need to notice that one vertex of the triangle can be chosen arbitrarily. With this observation","cbCaitrDdE2J0aP9","https://ap.wps.com/l/cbCaitrDdE2J0aP9","pdf",128729,"English","# Introduction\n## Picat overview\n## Picat implementation of TPK algorithm\n# The Problems\n## Triangle Areas","[{\"question\":\"What declarative techniques does the paper use with Picat for Google Code Jam problems?\",\"answer\":\"It uses constraint logic programming and tabled logic programming as declarative techniques for building solvable models.\"},{\"question\":\"How does the paper demonstrate Picat syntax before presenting Code Jam problems?\",\"answer\":\"It presents an implementation of the TPK algorithm in Picat and explains how functions, predicates, list comprehensions, loops, and conditional constructs are expressed in the language.\"},{\"question\":\"What makes the “Triangle Areas” problem suitable for constraint logic programming in the paper?\",\"answer\":\"The problem has discrete variables, non-linear constraints, and the goal is to find any feasible solution, so the constraints can be modeled declaratively to search for coordinates.\"}]","Declaratively solving Google Code Jam problems with Picat | PDF",1791077818]