In this paper we demonstrate several examples of solving challenging algorithmic problems from the Google Code Jam programming contest with the Prolog-based ECLiPSe system using declarative techniques like constraint logic programming and linear (integer) programming. These problems were designed to be solved by inventing clever algorithms and efficiently implementing them in a conventional imperative programming language, but we present relatively simple declarative programs in ECLiPSe that are fast enough to find answers within the time limit imposed by the contest rules. We claim that declarative programming with ECLiPSe is better suited for solving certain common kinds of programming problems offered in Google Code Jam than imperative programming. We show this by comparing the mental steps required to come up with both kinds of solutions.
翻译:在本文中,我们展示了几个例子,用约束逻辑编程和线性(整数)编程等宣示技术,解决了谷歌规则(Google Communical Communication)与基于Prolog的ECLIPSe系统竞争的具有挑战性的算法问题。这些问题的设计是通过发明智能算法,并以常规的迫切编程语言有效地加以实施来解决的,但我们在ECLPSe提出了相对简单的宣示程序,这些程序在竞争规则规定的时限内足以找到答案。我们声称,与ECLIPSe进行宣示性编程比紧急编程更适合解决谷歌规则(Google Communical Commission)中提供的某些常见的编程问题。我们通过比较提出两种解决办法所需的心理步骤来表明这一点。