KöMaL - Középiskolai Matematikai és Fizikai Lapok
Sign In
Sign Up


Problem I. 285. (January 2012)

I. 285. Many of us know about the Logo programming language, in which we can create nice figures by controlling a turtle. The Imagine Logo programming environment is freely downloadable from http://logo.sulinet.hu. Your task now is to teach the turtle to draw a maze and to find its way out of a maze.

First create and draw a random maze on a square grid. The building blocks of each passage and wall are 11×11 squares: this square is either white (passage) or black (wall). The procedure creating the maze is called labkész :n :m with two parameters being the number of horizontal and vertical squares of the maze (n and m are odd integers). The centre of the maze should be in the centre of the Logo sheet. The only exit should be located just below the top left square.

The turtle perceives the color of the actual point on the sheet. With the aid of this, you should create a procedure called elhelyez :n :m, which puts the turtle randomly in the centre of a passage square. The turtle should head north. You should also create a procedure kitalál :n :m, which tries to lead the turtle out of the maze. The turtle should leave a colored trail (being 5 units wide) to show the passages already passed. However, a trail should not be drawn when the turtle is moving just inside a square. The procedure should end if the turtle left the maze.

The algorithm to find the exit can be very simple, it is not required that the turtle should solve any maze. Mazes without loops can be solved, for example, by moving the turtle to have walls always to the right of it.

In your solution you should only use turtle graphics and the functional part of the Logo language. Do not use variables, repetition should be carried out only by recursion. Divide your solution into procedures and functions which are useful on their own, e.g., drawing a square, or determining whether there is a wall in front of the turtle.

You should submit your solution -- as an i285.imp (Imagine Logo Project format) file and as an i285.txt file containing brief descriptions about your procedures and functions -- in a compressed file i285.zip.

(10 pont)

Deadline expired on February 10, 2012.

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

Mintamegoldásként Antal János Benjamin 12. osztályos nyíregyházi versenyző megoldását közöljük (i285.zip ).


6 students sent a solution.
10 points:Antal János Benjamin, Beleznay Soma, Kovács Balázs Marcell.
9 points:Kucsma Levente István.
5 points:2 students.

Our web pages are supported by:   Ericsson   Cognex   Emberi Erőforrás Támogatáskezelő   Emberi Erőforrások Minisztériuma   Nemzeti Tehetség Program    
MTA Energiatudományi Kutatóközpont   MTA Wigner Fizikai Kutatóközpont     Nemzeti
Kulturális Alap   ELTE   Morgan Stanley