Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?

Problem I. 228. (December 2009)

I. 228. Two players play the following game. There is an even number of stones in a row, each with a known mass. Players in turn take one stone from either end of the row. If there are no more stones left, both players sum the masses of their stones. The winner is who possesses the bigger sum.

Prepare a version of this game which can be played on a web page. Draw the stones together with their masses. If the user clicks on a stone at the end of the row, then that stone should disappear and its mass should be added to the player's sum. If there are no more stones left, your program should display the winner. One of the players should be the computer itself, beginning the game.

Your program should use 16 stones. The computer's strategy (being the winning strategy) should be the following: the starting player sums the masses of stones at even and at odd positions, then takes a stone at the end of the row from the group for which this sum is greater. (In case of equality, the choice is arbitrary.)

You can use HTML and JavaScript elements in your solution.

The file i228.html together with any auxiliary GIF, JPEG or PNG images should be submitted together with a short documentation (i228.txt or i228.pdf) in a compressed folder i228.zip.

(This exercise is based on a problem of the International Olympiad in Informatics 1996.)

(10 pont)

Deadline expired on January 11, 2010.


Sorry, the solution is available only in Hungarian. Google translation

A feladatot majd minden megoldó jól megoldotta, több apró figyelmetlenség azonban előfordult.

Mivel a megoldást alapvetően egy html dokumentum adta, fontos, hogy a böngészőbeli megjelenítés korrekt legyen. Örültünk volna, ha a beküldött megoldások érvényes html dokumentumok (ellenőrzés: http://validator.w3.org/ ), azonban erre a feladat szövegében nem utaltunk, így az értékelésből is kimaradt. A megjelenés kapcsán azt figyeltük, hogy a netbookok képernyőjén (1024 képpont széles) és egy átlagos asztali monitoron (1440 képpont széles), valamint a két legelterjedtebb böngészőben (Internet Explorer és Firefox) egyező képet mutasson.

Fontos szempont volt, hogy a program betartsa a bábu levételének szabályát és a művelet eredményét meg is jelenítse mind képben, mind a választott bábuk össztömegében (ez utóbbit legalább a végén). A győztes megnevezése látszólag egyszerű, hiszen a kezdőnek nyerő stratégiája van, azonban nem szabad megfeledkezni a döntetlen lehetőségéről sem.

Az értékelésben a legnagyobb súllyal a nyerő stratégia követése szerepelt, amelyet megfelelőnek ítéltünk akkor is, ha a program az elején döntött a leveendő bábukról, de akkor is, ha minden lépés előtt újra elvégezte az értékelést.

A mintaként Szabó 928 Attila és Balla Attila megoldását közöljük utóbbi nem teljes értékű a megjelenítéssel kapcsolatos hiba miatt, azonban a kivitel és a dokumentáció teljessége miatt mégis mintaként szolgálhat.

Szabo928Attila.zip BallaAttila.zip


Statistics:

5 students sent a solution.
10 points:Barta 111 János, Szabó 928 Attila.
9 points:Balla Attila.
8 points:1 student.
6 points:1 student.

Problems in Information Technology of KöMaL, December 2009