KLIC PROGRAMMING CONTEST '98

Programming Subjects


INDEX
  1. ENTRY CATEGORY
    1. Lights Out
    2. The program
      2.1 Predicate Interface
    3. Judgment
    4. Other information (Programs Released on Sep.25.)
  2. SPEED CATEGORY
    1. Example
    2. Rules on Word Arrangement
    3. Rules on Programs
    4. Programming Restrictions
    5. Programs for Your Aids (Released on Aug.28.)
    6. Acknowledgements
  3. IDEA CATEGORY
    You can program on any subject either in a sequential or in a parallel environment.
    (No subject in this category)

ENTRY CATEGORY

Problem:Lights Out

Write a program that implements a part of the game "Lights Out." The program will receive "button click" inputs from the player, and should generate outputs to control the lights. 1. Lights Out The "Lights Out" board consists of 5x5 light-buttons (Fig. 1). When players click the button, the lights turn on or off. The purpose of the game is to make all lights go off. --> Column 0 1 2 3 4 | 0 [][][][][] | 1 []******** ** ON V 2 [][][][]** [] OFF Row 3 [][]****** 4 [][][][]** Fig. 1 Lights Out The rules for transition of the lights when buttons are clicked are as follows. [Rules] When a button is clicked, the lights of the button itself and those of the four adjacent buttons switch their state. Here is an example. Suppose that we express the position of light-buttons by the notation (Row, Column). When button (0,4) is clicked, lights of buttons (0,3), (0,4) and (1,4) will also switch state (Fig. 2 (a)). 0 1 2 3 4 0 1 2 3 4 0********** 0******[][] 1********** click(0,4) 1********[] 2********** --> 2********** 3********** 3********** 4********** 4********** Fig. 2. (a) 0 1 2 3 4 0 1 2 3 4 0******[][] 0******[][] 1********[] click(2,2) 1****[]**[] 2********** --> 2**[][][]** 3********** 3****[]**** 4********** 4********** Fig. 2. (b) 0 1 2 3 4 0 1 2 3 4 0******[][] 0******[][] 1****[]**[] click(4,2) 1****[]**[] 2**[][][]** --> 2**[][][]** 3****[]**** 3********** 4********** 4**[][][]** Fig. 2. (c) Fig. 2 Transition of the board When button (2,2) is clicked, lights of buttons (1,2), (2,1), (2,2), (2,3), and (3,2) will switch state (Fig. 2 (b)). When button (4,2) is clicked, buttons (3,2), (4,1), (4,2), and (4,3) will switch state (Fig. 2 (c)). In this exercise, we define the initial state of lights as all "on" (Fig. 5). 0 1 2 3 4 0********** 1********** ** ON 2********** [] OFF 3********** 4********** Fig. 5 Initial state of lights 2. The program 2.1 Predicate Interface Contestants should supply the one-arity predicate: lo:game(Event) Here, the argument "Event" is the input stream. The output is generated from the variables that come from the input stream. 2.1.1 Interface of Input Stream The input stream is defined as follows: Button click click(Row,Column,Output) "Row" and "Column" specify the position in the board (Row,Column). "Output" is the variable for output. Redraw of board redraw(Output) Redraw the board "Output" is the variable for output. (This is the input for the redraw request. When this request comes, the board is in the all "on" state.) 2.1.2 Interface of Output The output is generated by binding the output variable with the list of messages. The message is defined as follows: set(Row,Column) Turn the light on. (Row,Column) specifies the position on the board. reset(Row,Column) Turn the light off. (Row,Column) specifies the position on the board. 2.1.3 Example of the predicate interface lo:game([click(0,4,O1), click(2,2,O2), click(4,2,O3), ... ]) O1 = [reset(0,3),reset(0,4),reset(1,4)] O2 = [reset(1,2),reset(2,1),reset(2,2),reset(2,3),reset(3,2)] O3 = [set(3,2),reset(4,1),reset(4,2),reset(4,3)] ... 3. Judgment The secretariat of the KLIC Programming Contest will check the correctness of contestants' programs by executing the test program. Programs that work correctly will be candidates for the prize winner. 4. Other information "Lights Out" is a trademark of Tiger Electronics, Inc. (This exercise is written with the permission of Tiger Electronics, Inc. Please see "http://www.game.com" for their games.) Occasionally, we will put up some programs on the WWW/FTP server of AITEC. These will include the module for playing the Lights Out game under the X Window System, and a test program to check its operation. You can get new information about the programs if you subscribe to the mailing list prepared for this contest. Good luck & have fun!

The software package is made by 'tar' and 'gzip' commands.

Please see the README.e file in detail after uncompression.

The software may be revised without previous notice, but you will be able to get up-to-date information if you subscribe to the mailing list dedicated to this contest. Please contact the contest secretariat.(klic-contest@icot.or.jp)


SPEED CATEGORY

Problem:Skeleton Contest

Write a program that makes arrangements similar to crossword puzzles using some of the words given as runtime arguments on a square board whose size is also given as an argument. Each word is associated with certain points. The objective of the program is to maximize the sum of points of words used in the arrangement. 1.Example Consider making an arrangement using the following words on a nine by nine square board. FIFTH 5 GENERATION 17 KLIC 13 SPEED 4 CONTEST 9 PROBLEM 4 SOLUTION 15 YOURS 3 WINNER 21 OR 1 LOSER 2 A possible solution may look like the following. 0 1 2 3 4 5 6 7 8 0 ______________ Y__ 1 __ K L I C____ O R 2 ________ O____ U__ 3 ____ W I N N E R__ 4 ________ T____ S__ 5 ____ S P E E D____ 6 ________ S________ 7 __ F I F T H______ 8 __________________ In the above figure, "__" is a square with no character in it. The point of this solution is computed by summing up points of the words used, as follows. 5 + 13 + 4 + 9 + 3 + 21 + 1 = 56 points 2.Rules on Word Arrangement (1) Words should read up to down or left to right. Diagonal or reverse readings are not allowed. (2) The same word may be used only once. (3) All the words in an arragement should be connected somehow. A solution with separate "islands" is not valid. (4) When two or more words are in the same row or column, one or more squares should be left blank in between them. (5) No two characters should be in adjacent squares except for those constituting a word. 3.Rules on Programs Predicate Interface Programs of contestants should define a three argument predicate with its name "solve" in a module "skeleton". skeleton:solve(Size, WordList, SolutionStream) With the first and the second argument as input, solutions should be output as a stream to the third argument. Size: Input The size (width and hight) of the board given as an integer value. This argument does not exceed 20. Example) 9 WordList: Input A list of elements with the following format. word(Id, Spelling, Points) "Id" is an atom identifying the word. "Spelling" is a string of eight bit characters whose length is less than or equal to the size of the board. Characters are all in uppercase. The same id or spelling will never appear twice. "Points" are given as a positive integer number. The sum of points of all the words will never cause arithmetical overflow. The number of words does not exceed 200. Example) [ word(fifth, "FIFTH", 5), word(gener, "GENERATION", 17), word(klic, "KLIC", 13), word(speed, "SPEED", 4), word(cont, "CONTEST", 9), word(prob, "PROBLEM", 4), word(solut, "SOLUTION", 15), word(yours, "YOURS", 3), word(winner,"WINNER",21), word(or, "OR", 1), word(loser, "LOSER", 2) ] SolutionStream: Output A stream with elements representing solutions of the following format. [ place(Id, Row, Column, Direction), ... ] "Id" is the identifier of the word given in "WordList". "Row" and "Column" are integers specifying the starting position of the word. Rows and columns are numbered from zero. "Direction" is an atom telling whether the word should be read top to bottom (tb) or left to right (lr). The order in the list does not matter. Example) [ place(klic, 1, 1, lr), place(winner, 3, 2, lr), place(speed, 5, 2, lr), place(fifth, 7, 1, lr), place(cont, 1, 4, tb), place(yours, 0, 7, tb), place(or, 1, 7, lr) ] Any number of solutions may be output in the stream. The points of the program is the points of the last solution output within given time. Each solution should be completely instantiated before being output, that is, it should not be an incomplete term including unbound variables. To realize this, a solution may be inspected using a guard predicate "wait" before being output. 4.Programming Restrictions - Inline C code should not be used. - The following form of pragma should not be used. GOAL@priority(ABSPRIO) For priority specification, the following forms may be used. GOAL@lower_priority GOAL@lower_priority(RELPRIO) - Programs should not perform any input/output operations. - Modules names used in advertised test programs should not be used. 5.Programs for Your Aids This program displays solutions which are find by participants' program in the Speed Category. Please remark that using this program for the contest judgement is not guaranteed. Further more, when you submit your program, please DO NOT include this program. Program for displaying solutions (ver.1)(ftp) README of Program for displaying solutions: [English][Japanese]

The software package is made by 'tar' and 'gzip' commands.

Please see the README.e file in detail after uncompression.

The software may be revised without previous notice, but you will be able to get up-to-date information if you subscribe to the mailing list dedicated to this contest. Please contact the contest secretariat.(klic-contest@icot.or.jp)

6.Acknowledgements The rules of this Skeleton Contest are designed originally by Nikoli Inc. We deeply appreciate their permission to use the rules.