Hidato. Assignment. A hidato (left) and its solution (right).

Vergelijkbare documenten
After that, the digits are written after each other: first the row numbers, followed by the column numbers.

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 8 februari 2010

Classification of triangles

Calculator spelling. Assignment

Daylight saving time. Assignment

Group work to study a new subject.

The first line of the input contains an integer $t \in \mathbb{n}$. This is followed by $t$ lines of text. This text consists of:

ANGSTSTOORNISSEN EN HYPOCHONDRIE: DIAGNOSTIEK EN BEHANDELING (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

SAMPLE 11 = + 11 = + + Exploring Combinations of Ten + + = = + + = + = = + = = 11. Step Up. Step Ahead

Add the standing fingers to get the tens and multiply the closed fingers to get the units.

MyDHL+ Van Non-Corporate naar Corporate

Puzzle. Fais ft. Afrojack Niveau 3a Song 6 Lesson A Worksheet. a Lees de omschrijvingen. Zet de Engelse woorden in de puzzel.

ALGORITMIEK: answers exercise class 7

Four-card problem. Input

Engels op Niveau A2 Workshops Woordkennis 1

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Preschool Kindergarten

Example. >>> rowkey('u') 1 >>> rowkey('a') 2 >>> rowkey('z') 3 >>> rowkey('?')

RECEPTEERKUNDE: PRODUCTZORG EN BEREIDING VAN GENEESMIDDELEN (DUTCH EDITION) FROM BOHN STAFLEU VAN LOGHUM

Example. >>> airmap = Map() >>> airmap.eruption(0, 0) >>> airmap.ashcloud {(0, 0)} >>> airmap.spread()

!!!! Wild!Peacock!Omslagdoek!! Vertaling!door!Eerlijke!Wol.!! Het!garen!voor!dit!patroon!is!te!verkrijgen!op! Benodigdheden:!!

The 15 puzzle invented by Noyes Chapman consisted of a $4 \times 4$ grid of which the field are numbered from 1 to 15.

Luister alsjeblieft naar een opname als je de vragen beantwoordt of speel de stukken zelf!

i(i + 1) = xy + y = x + 1, y(1) = 2.

B1 Woordkennis: Spelling

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

(1) De hoofdfunctie van ons gezelschap is het aanbieden van onderwijs. (2) Ons gezelschap is er om kunsteducatie te verbeteren

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 7 februari 2011

20 twenty. test. This is a list of things that you can find in a house. Circle the things that you can find in the tree house in the text.

Opgave 2 Geef een korte uitleg van elk van de volgende concepten: De Yield-to-Maturity of a coupon bond.

L.Net s88sd16-n aansluitingen en programmering.

Ontpopping. ORGACOM Thuis in het Museum

De grondbeginselen der Nederlandsche spelling / Regeling der spelling voor het woordenboek der Nederlandsche taal (Dutch Edition)

Borstkanker: Stichting tegen Kanker (Dutch Edition)

Quality requirements concerning the packaging of oak lumber of Houthandel Wijers vof ( )

DALISOFT. 33. Configuring DALI ballasts with the TDS20620V2 DALI Tool. Connect the TDS20620V2. Start DALISOFT

L.Net s88sd16-n aansluitingen en programmering.

voltooid tegenwoordige tijd

Travel Survey Questionnaires

Settings for the C100BRS4 MAC Address Spoofing with cable Internet.

Love & Like FILE 2 LOVE & LIKE BK 2

Firewall van de Speedtouch 789wl volledig uitschakelen?

Win a meet and greet with Adam Young from the band Owl City!

Academisch schrijven Inleiding

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Zo werkt het in de apotheek (Basiswerk AG) (Dutch Edition)

2019 SUNEXCHANGE USER GUIDE LAST UPDATED

Buy Me! FILE 5 BUY ME KGT 2

General info on using shopping carts with Ingenico epayments

Een vrouw, een kind en azijn (Dutch Edition)

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculteit Wiskunde en Informatica. Examination 2DL04 Friday 16 november 2007, hours.

Online Resource 1. Title: Implementing the flipped classroom: An exploration of study behaviour and student performance

1a. We werken het geval voor het tandenpoetsen uit. De concepten zijn (we gebruiken Engelse termen en afkortingen):

Het beheren van mijn Tungsten Network Portal account NL 1 Manage my Tungsten Network Portal account EN 14

TOEGANG VOOR NL / ENTRANCE FOR DUTCH : lator=c&camp=24759

Esther Lee-Varisco Matt Zhang

Duurzaam projectmanagement - De nieuwe realiteit van de projectmanager (Dutch Edition)

Ius Commune Training Programme Amsterdam Masterclass 16 June 2016

My Inspiration I got my inspiration from a lamp that I already had made 2 years ago. The lamp is the you can see on the right.

Win a meet and greet with Adam Young from the band Owl City!

Ius Commune Training Programme Amsterdam Masterclass 15 June 2018

Taco Schallenberg Acorel

Meetkunde en Lineaire Algebra

LONDEN MET 21 GEVARIEERDE STADSWANDELINGEN 480 PAGINAS WAARDEVOLE INFORMATIE RUIM 300 FOTOS KAARTEN EN PLATTEGRONDEN

EM7680 Firmware Update by OTA

Introductie in flowcharts

Geachte Bezoeker, Adresgegevens

Handleiding Zuludesk Parent

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

S e v e n P h o t o s f o r O A S E. K r i j n d e K o n i n g

Grammatica uitleg voor de toets van Hoofdstuk 1

1. In welk deel van de wereld ligt Nederland? 2. Wat betekent Nederland?

Things to do before you re 11 3/4

9 daagse Mindful-leSs 3 stappen plan training

LDAP Server on Yeastar MyPBX & tiptel 31xx/32xx series

Lists of words from the books, and feedback from the sessions, are on

Comics FILE 4 COMICS BK 2

Academisch schrijven Inleiding

Uw mening telt! Onderwerp: aankondiging vragenlijst wel of niet afsluiten groene hoven. Beste bewoner(s),

MyDHL+ Uw accountnummer(s) delen

Read this story in English. My personal story

should(n t) / should(n t) have to zouden moeten / hadden meestergijs.nl

In the classroom. Who is it? Worksheet

BISL EEN FRAMEWORK VOOR BUSINESS INFORMATIEMANAGEMENT (DUTCH LANGUAGE) (GERMAN EDITION) (DUTCH EDITION) BY REMKO VAN DER POLS, RALPH DONA

Transcriptie:

Hidato Forget about sudoku puzzles. The latest craze in logic puzzles is hidato. Today hidato is featured in over 60 newspapers around the world. At any moment, thousands of people play hidato online. Hidato's slogan "Find the Path Solve the Puzzle!" is now well-known among scores of puzzle-solvers and it will probably bring fun and teach logic skills to many more in the near future. The term hidato originates from the Hebrew word for riddle (Hida, (חידאתו and is the name of a logic puzzle game invented by Dr. Gyora Benedek, an Israeli computer scientist, inventor and adventurer. A hidato consists of a rectangular grid with $m$ rows and $n$ columns. The goal is to fill the grid with the series of consecutive numbers 1 to $m \times n$ adjacent to each other vertically, horizontally, or diagonally. In every hidato the positions of the numbers 1 and $m \times n$ on the grid are given. There are also other given numbers on the grid (with values between 1 and $m \times n$) to help direct the player how to start the solution and to ensure the hidato has a unique solution. A hidato (left) and its solution (right). Assignment In this assignment, we represent a $m \times n$ grid containing the solution of a hidato as a list containing $m$ elements. These elements represent the rows of the grid. Each row is itself a list containing $n$ integers. These represent the numbers which are filled in the successive columns of the row. You may assume that each of the numbers 1, 2,, $m \times n$ occurs just once in the grid. The rows of the grid are indexed from top to bottom, and the columns from left to right. Indexing of the rows and columns always starts from 0. Your task is to determine whether a given $m \times n$ grid represents a valid solution of a hidato. In order to do so, you proceed as follows: Write a function first that takes the solution of a hidato as its argument. The function must return a tuple (r, c) that contains the row index r and the column index c of the cell in the grid that contains the value 1. Write a function successor that takes three arguments. The first argument is the solution of a hidato. The second and third arguments respectively represent the row and column index of a cell in the grid. The function must return a tuple (r, c) that contains the row index r and the column index c of the cell in the grid that follows upon the given cell. If the given cell

contains the integer $v$, its successor is the vertically, horizontally, or diagonally adjacent cell that contains the value $v + 1$. If the given cell has no successor, the function should return the tuple (None, None). Use the functions first and successor to write a function last that takes the solution of a hidato as its argument. The function must return a tuple (r, c) that contains the row index r and the column index c of the cell in the grid that is found by starting from the cell containing the value 1, and repetitively visiting the next cell until a cell is reached that has no successor. The coordinates of the last visited cell must be return by the function. Use the function last to write a function hidato that takes the solution of a hidato as its argument. The function must return a Boolean value that indicates whether or not the given grid is a valid solution of a hidato. This can be determined by starting from the cell containing the value 1, and repetitively visiting the next cell until a cell is reached that has no successor. In case the last visited cell contains an integer that is equal to the total number of cells in the grid, the given grid represents a valid solution of a hidato. Example >>> first([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) (2, 3) >>> first([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) >>> first(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) >>> successor([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]], 2, 3) (1, 3) >>> successor([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]], 1, 3) (1, 2) >>> successor([[5, 4, 11, 2], [6, 10, 3, 12], [7, 8, 9, 1]], 2, 3) (None, None) >>> last([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) (0, 3) >>> last([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) (3, 2) >>> last(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) (0, 2) >>> hidato([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) >>> hidato([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) False >>> hidato(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) Fun Fact When asked by The New York Times where he got the idea for hidato, Dr. Benedek gave the following anwser During SCUBA diving, I noticed a school of fish swimming at amazing speed around me. They were so fast that I could only see them at the spots where they changed direction. In my mind I worked hard to reconstruct their path. I was so fascinated that I hadn't noticed the time and the level of oxygen in my tank. Luckily, my partner

signaled time to surface. I was reluctant to leave behind this amazing dance of fish and it was still in my mind when I noticed a crumpled and wet newspaper in the shower. The only dry spot in the paper was a Sudoku puzzle. And then an idea popped in my mind: How about a printed puzzle where you reconstruct the path of the fish from observed spots? I couldn't wait to get home and start building the puzzle. A couple of weeks later, I knew I had something big. This is how Hidato was born. Vergeet sudoku's. De nieuwste rage op het gebied van logische puzzels is de hidato. Meer dan 60 kranten wereldwijd hebben hun sudokupuzzels reeds vervangen door hidato's en het aantal online hidato-spelers groeit zienderogen. De term hidato is afgeleid van het Hebreeuwse woord voor raadsel (hida, (חידאתו en is de naam van een puzzel uitgevonden door Gyora Benedek, een Israëlische informaticus, uitvinder en avonturier. De opgave van een hidato bestaat uit een rechthoekig rooster met $m$ rijen en $n$ kolommen. De oplossing bestaat erin de reeks natuurlijke getallen van 1 tot en met $m \times n$ in het rooster in te vullen, zodat opeenvolgende getallen horizontaal, verticaal of diagonaal naast elkaar staan. De opgave van de puzzel bevat reeds de posities van de getallen 1 en $m \times n$. Daarnaast worden in het gegeven rooster ook al een aantal andere getallen ingevuld, om de speler op weg te helpen bij het vinden van de oplossing en om te verzekeren dat de hidato een unieke oplossing heeft. Een hidato (links) en zijn oplossing (rechts). Opgave In deze opgave stellen we een $m \times n$ rooster met de oplossing van een hidato voor als lijst met $m$ elementen. Deze elementen stellen de rijen van het rooster voor. Elke rij is zelf ook een lijst met $n$ natuurlijke getallen. Deze stellen de getallen voor die ingevuld zijn op de opeenvolgende kolomen van de rij. Je mag ervan uitgaan dat elk van de getallen 1, 2,, $m \times n$ juist één keer voorkomt in het rooster. De rijen van het rooster worden van boven naar onder genummerd, en de kolommen van links naar rechts. Het nummeren van de rijen en de kolommen start vanaf 0. Gevraagd wordt om te bepalen of een gegeven $m \times n$ rooster een geldige oplossing van een hidato voorstelt. Hiervoor ga je als volgt te werk: Schrijf een functie eerste waaraan de oplossing van een hidato moet doorgegeven worden. De functie moet een tuple (r, k) teruggeven dat het rijnummer $r$ en het kolomnummer $k$ bevat van de cel in het rooster die de waarde 1 bevat. Schrijf een functie opvolger waaraan drie argumenten moeten doorgegeven worden. Het

eerste argument is de oplossing van een hidato. Het tweede en derde argument stellen respectievelijk het rij- en kolomnummer van een cel in het rooster voor. De functie moet een tuple (r, k) teruggeven dat het rijnummer $r$ en het kolomnummer $k$ bevat van de cel in het rooster dat volgt op de gegeven cel. Als de gegeven cel het natuurlijke getal $v$ bevat, dan is de opvolger de cel die horizontaal, verticaal of diagonaal raakt aan de gegeven cel en de waarde $v + 1$ bevat. Indien de gegeven cel geen opvolger heeft, dan moet de functie het tuple (None, None) teruggeven. Gebruik de functies eerste e n opvolger om een functie laatste te schrijven waaraan de oplossing van een hidato moet doorgegeven worden. De functie moet een tuple (r, k) teruggeven dat het rijnummer $r$ en het kolomnummer $k$ bevat van de cel in het rooster die bekomen wordt door te vertrekken vanaf de cel die de waarde 1 bevat, en telkens de volgende cel te bepalen totdat een cel bereikt wordt die geen opvolger meer heeft. De coördinaten van deze laatste cel moeten door de functie teruggegeven worden. Gebruik de functie laatste om een functie hidato te schrijven waaraan de oplossing van een hidato moet doorgegeven worden. De functie moet een Booleaanse waarde teruggeven, die aangeeft of het gegeven rooster een geldige oplossing van een hidato voorstelt. Dit kan bepaald worden door te vertrekken vanaf de cel die de waarde 1 bevat, en telkens de volgende cel te bepalen totdat een cel bereikt wordt die geen opvolger meer heeft. Indien deze laatste cel een getal bevat dat gelijk is aan het aantal cellen van het rooster, dan stelt het gegeven rooster een geldige oplossing van een hidato voor. Voorbeeld >>> eerste([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) (2, 3) >>> eerste([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) >>> eerste(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) >>> opvolger([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]], 2, 3) (1, 3) >>> opvolger([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]], 1, 3) (1, 2) >>> opvolger([[5, 4, 11, 2], [6, 10, 3, 12], [7, 8, 9, 1]], 2, 3) (None, None) >>> laatste([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) (0, 3) >>> laatste([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) (3, 2) >>> laatste(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) (0, 2) >>> hidato([[5, 4, 11, 12], [6, 10, 3, 2], [7, 8, 9, 1]]) >>> hidato([[8, 14, 13, 12], [15, 1, 2, 11], [5, 3, 10, 16], [4, 6, 7, 9]]) False >>> hidato(((18, 19, 20, 4, 5), (17, 1, 3, 6, 8), (16, 13, 2, 9, 7), (14, 15, 12, 11, 10))) Weetje Dr. Benedek beschreef als volgt aan The New York Times hoe hij aan het idee van de hidato

kwam: During SCUBA diving, I noticed a school of fish swimming at amazing speed around me. They were so fast that I could only see them at the spots where they changed direction. In my mind I worked hard to reconstruct their path. I was so fascinated that I hadn't noticed the time and the level of oxygen in my tank. Luckily, my partner signaled time to surface. I was reluctant to leave behind this amazing dance of fish and it was still in my mind when I noticed a crumpled and wet newspaper in the shower. The only dry spot in the paper was a Sudoku puzzle. And then an idea popped in my mind: How about a printed puzzle where you reconstruct the path of the fish from observed spots? I couldn't wait to get home and start building the puzzle. A couple of weeks later, I knew I had something big. This is how Hidato was born.