Google Code Jam in Picat

Google Code Jam is an international programming competition hosted and administered by Google. GCJ has become extremely popular among programmers; over 23,000 people participated in the competition in 2015. GCJ has created a repository of problems that can be used by programmers to sharpen their programming skills. Unlike many other programming contests, GCJ allows contestants to use any programming language. This makes GCJ an ideal platform for testing and evaluating new programming languages.

Picat is a new logic-based multi-paradigm programming language that integrates logic programming, functional programming, constraint programming, dynamic programming with tabling, and scripting. It provides facilities for solving combinatorial search problems, including tabling for dynamic programming, a module for planning that is implemented by the use of tabling, and solver modules for constraint problems that are based on CP (constraint programming), SAT (satisfiability), and MIP (mixed integer programming).

In Spring 2015, about one year after the release of Picat's first stable version, Sergii Dymchenko and Mariia Mykhailova published an article in PADL'15 titled "Declaratively Solving Google Code Jam Problems with Picat", which summarizes their experience as follows: "in some cases the use of Picat simplifies the implementation compared to conventional imperative programming languages, while in others it allows to directly convert the problem statement into an efficiently solvable declarative problem specification without inventing an imperative algorithm. An increasing number of programmers, inspired by this article, have started paying attention to Picat; In GCJ 2015, five participants used Picat, while only one contestant used Prolog.

This page collects example solutions in Picat for some of the GCJ problems, including the programs given in Dymchenko and Mykhailova's paper. The GCJ solutions are concise, easy to read, and efficient enough to pass the tests. They demonstrate well Picat's modeling and solving capabilities. These examples will be of interest to GCJ participants who want to gain a competitive edge with Picat, and helpful for programmers who are interested in learning how to use the Picat language effectively in solving problems.

Contributions are welcome. Please send your GCJ solutions to or