The genesis of the game is unclear. Possibly, dominoes originates from China and the stones were brought here by Marco Polo, but this is uncertain.

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

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

Calculator spelling. Assignment

Genetic code. Assignment

The mitochondrial genome has bases and codes for 37 genes: 13 polypeptides, 22 trnas and 2 ribosomal RNAs.

Country recognition. Assignment

Roman numerals. Assignment

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

Classification of triangles

Centre of mass. Define a class Atom that supports the following methods:

MyDHL+ Van Non-Corporate naar Corporate

ALGORITMIEK: answers exercise class 7

Buzzword bingo Buzzword bingo bul shit bingo

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

The colour of a pixel in a bit map picture can be presented in different ways. For this assignment, we distinguish two categories:

Preschool Kindergarten

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

L.Net s88sd16-n aansluitingen en programmering.

L.Net s88sd16-n aansluitingen en programmering.

Earth Similarity Index

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

Engels op Niveau A2 Workshops Woordkennis 1

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

Christmas party. Preparation. Assignment

Handleiding Zuludesk Parent

Large word squares are dramatically harder to make than small ones. To date, the largest anyone has managed to find are composed of 9-letter words:

Chromosomal crossover

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

MyDHL+ ProView activeren in MyDHL+

Daylight saving time. Assignment

04/11/2013. Sluitersnelheid: 1/50 sec = 0.02 sec. Frameduur= 2 x sluitersnelheid= 2/50 = 1/25 = 0.04 sec. Framerate= 1/0.

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.

Ontpopping. ORGACOM Thuis in het Museum

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

8+ 60 MIN Alleen te spelen in combinatie met het RIFUGIO basisspel. Only to be played in combination with the RIFUGIO basicgame.

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

Chess board distance $\max( x_0-x_1, y_0-y_1 )$

Speleology. Assignment

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

Meetkunde en Lineaire Algebra

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

General info on using shopping carts with Ingenico epayments

Handleiding Installatie ADS

Settings for the C100BRS4 MAC Address Spoofing with cable Internet.

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

Nieuwsbrief NRGD. Editie 11 Newsletter NRGD. Edition 11. pagina 1 van 5.

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:

Solar system. Assignment

B1 Woordkennis: Spelling

Introductie in flowcharts

Voorbeelden van machtigingsformulieren Nederlands Engels. Examples of authorisation forms (mandates) Dutch English. Juli 2012 Versie 2.

Data Handling Ron van Lammeren - Wageningen UR

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

It s all about the money Group work

Meetkunde en Lineaire Algebra

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

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

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

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Reservoir. Assignment

Meetkunde en Lineaire Algebra

Intermax backup exclusion files

CTI SUITE TSP DETAILS

Alle opgaven tellen even zwaar, 10 punten per opgave.

2019 SUNEXCHANGE USER GUIDE LAST UPDATED

VOORSTEL TOT STATUTENWIJZIGING UNIQURE NV. Voorgesteld wordt om de artikelen 7.7.1, 8.6.1, en te wijzigen als volgt: Toelichting:

LDA Topic Modeling. Informa5ekunde als hulpwetenschap. 9 maart 2015

Procedure Reset tv-toestellen:

Demultiplexing reads FASTA format genome sequencing reads run

Teardrop readout gradient waveform design. Ting Ting Ren

OPEN TRAINING. Onderhandelingen met leveranciers voor aankopers. Zeker stellen dat je goed voorbereid aan de onderhandelingstafel komt.

Esther Lee-Varisco Matt Zhang

Assignment. Paul Michael Larson

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

Pure Bending. A beam satisfying above given requirements are shown below: Why this surface is called neutral will be explained later in the lecture.

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Firewall van de Speedtouch 789wl volledig uitschakelen?

Activant Prophet 21. Prophet 21 Version 12.0 Upgrade Information

Value based healthcare door een quality improvement bril

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

Reynolds number. Laminar and turbulent flow in a cigarette's smoke.

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

Find Neighbor Polygons in a Layer

Hoe te verbinden met NDI Remote Office (NDIRO): Apple OS X How to connect to NDI Remote Office (NDIRO): Apple OS X

Relationele Databases 2002/2003

Cambridge Assessment International Education Cambridge International General Certificate of Secondary Education. Published

Tentamen Objectgeorienteerd Programmeren

Pesten onder Leerlingen met Autisme Spectrum Stoornissen op de Middelbare School: de Participantrollen en het Verband met de Theory of Mind.

Relationele Databases 2002/2003

CHROMA STANDAARDREEKS

Lijnenspel. Remco van Groesen ( ) & Ellen Houbiers ( )

Chapter 4 Understanding Families. In this chapter, you will learn

Feathered friends. Assignment

AN URBAN PLAYGROUND AFSTUDEERPROJECT

GOVERNMENT NOTICE. STAATSKOERANT, 18 AUGUSTUS 2017 No NATIONAL TREASURY. National Treasury/ Nasionale Tesourie NO AUGUST

Group work to study a new subject.

28/10/2012. Onderwerpen: Scherpstelling - Focusering Sluitersnelheid en framerate. Sluitersnelheid en belichting

Hoe met Windows 8 te verbinden met NDI Remote Office (NDIRO) How to connect With Windows 8 to NDI Remote Office (NDIRO

Transcriptie:

Domino tiles Dominoes is a game played with rectangular domino 'tiles'. Today the tiles are often made of plastic or wood, but in the past, they were made of real stone or ivory. They have a rectangle shape and are divided in 2 square fields, each marked with zero to six pips. In a standard set, all 28 combinations of stones with 0 to 6 pips occur exactly once. Domino tiles. The genesis of the game is unclear. Possibly, dominoes originates from China and the stones were brought here by Marco Polo, but this is uncertain. Assignment Define a class Domino to represent domino tiles in Python. We choose a design where the tiles are immutable objects. This way, not a single method may change the internal state of an object after is was initialized. The objects of this class should have at least the following methods: An initializing method to which two numbers must be given. We represent a domino tile as two square halves that are next to each other, and the given numbers respectively are the amount of pips on the left and right half. The initializing method must print an AssertionError with the message invalid number of pips, if the number of pips on both halves is not between 0 and 6 (boundaries included). A method repr that prints a string representation of the domino tile. This string representation reads as a Python-expression that makes a new object of the class Domino that has the same state as the domino tiles on which the method was called. A method str that prints a string representation of the domino tile. This string representation uses the templates below to compose both halves of the tile based on their number of pips. o o o o ooo o o o o ooo 0 1 2 3 4 5 6

Here, a dot is represented by a lowercase letter o. The templates that correspond with the left and right half are put next to each other in the string representation, where the right border of the left half coincides with the left border or the right half. A method rotate that prints a new tile (object of the class Domino), of which the number of pips on the left and right half were switched with regard to the tile on which the method was called. A method that allows to add two domino tiles based on the + operator. Two tiles can be added if the number of pips on the right of the first stone is equal to the amount of pips on the left half of the second stone. If this isn't the case, the method must print an AssertionError with the message domino tiles do not match. Adding two domino tiles results in a new domino tile (object of the class Domino) of which the number of pips on the left half is equal to the number of pips on the left half of the first tile, and the number of pips on the right half is equal to the right half of the second tile. Example >>> tile1 = Domino(3, 4) >>> Domino(-1, 7) AssertionError: invalid number of pips >>> tile1 Domino(3, 4) >>> print(tile1) >>> print(tile1.rotate()) o o o o o o >>> print(tile1) >>> tile2 = Domino(1, 3) >>> tile1 + tile2 AssertionError: domino tiles do not match >>> print(tile2 + tile1)

>>> tile3 = tile1.rotate() + tile2.rotate() >>> tile3 Domino(4, 1) >>> print(tile3) Domino is een legspel dat met speciale dominostenen gespeeld wordt. De stenen zijn tegenwoordig vaak van plastic of hout gemaakt, maar vroeger werden ze ook vervaardigd van echte steen of ivoor. Ze hebben een rechthoekige vorm en zijn verdeeld in 2 vierkante veldhelften, ieder gemerkt met nul tot zes ogen. In de standaardset komen alle 28 combinaties van stenen met 0 tot 6 ogen juist eenmaal voor. Dominostenen. De ontstaansgeschiedenis van het spel is onduidelijk. Mogelijk vindt het dominospel zijn oorsprong in China en zijn de stenen door Marco Polo daarvandaan meegenomen, maar dit valt niet met zekerheid vast te stellen. Opgave Definieer een klasse Domino waarmee dominostenen kunnen voorgesteld worden in Python. We kiezen voor een ontwerp waarbij dominostenen onveranderlijke (immutable) objecten zijn. Daardoor mag geen enkele methode de interne toestand van een object aanpassen nadat het werd geïnitialiseerd. De objecten van deze klasse moeten minstens de volgende methoden hebben: Een initialisatiemethode waaraan twee getallen moeten doorgegeven worden. We stellen een dominosteen voor als twee vierkante helften die naast elkaar staan, en de gegeven getallen stellen dan respectievelijk het aantal ogen op de linker- en de rechterhelft voor. De initialisatiemethode moet een AssertionError opwerpen met de boodschap ongeldig aantal ogen, indien het aantal ogen op beide helften van de dominosteen niet telkens tussen 0 en 6

(grenzen inbegrepen) gelegen is. Een methode repr die een stringvoorstelling van de dominosteen teruggeeft. Deze stringvoorstelling leest als een Python-expressie die een nieuw object aanmaakt van de klasse Domino dat dezelfde toestand heeft als de dominosteen waarop de methode aangeroepen wordt. Een methode str die een stringvoorstelling van de dominosteen teruggeeft. Deze stringvoorstelling maakt gebruik van onderstaande sjablonen om elk van beide helften van de steen voor te stellen op basis van hun aantal ogen. o o o o ooo o o o o ooo 0 1 2 3 4 5 6 Hierbij wordt een oog voorgesteld door de kleine letter o. De sjablonen die overeenkomen met de linker- en de rechterhelft worden naast elkaar gezet in de stringvoorstelling, waarbij de rechterrand van de linkerhelft samenvalt met de linkerrand van de rechterhelft. Een methode draai die een nieuwe dominosteen (object van de klasse Domino) teruggeeft, waarvan het aantal ogen op de linker- en rechthelft omgewisseld werd ten opzichte van de dominosteen waarop de methode werd aangeroepen. Een methode die toelaat om twee dominostenen bij elkaar op te tellen aan de hand van de + operator. Twee dobbelstenen kunnen enkel bij elkaar opgeteld worden als het aantal ogen aan de rechterkant van de eerste steen gelijk is aan het aantal ogen aan de linkerkant van de tweede steen. Indien dit niet het geval is, dan moet de methode een AssertionError opwerpen met de boodschap dominostenen passen niet. De optelling van twee dominostenen resulteert in een nieuwe dominosteen (object van de klasse Domino) waarvan het aantal ogen op de linkerhelft gelijk is aan het aantal ogen op de linkerhelft van de eerste steen, en het aantal ogen op de rechterhelft gelijk is aan het aantal ogen op de rechterhelft van de tweede steen. Voorbeeld >>> steen1 = Domino(3, 4) >>> Domino(-1, 7) AssertionError: ongeldig aantal ogen >>> steen1 Domino(3, 4) >>> print(steen1)

>>> print(steen1.draai()) o o o o o o >>> print(steen1) >>> steen2 = Domino(1, 3) >>> steen1 + steen2 AssertionError: dominostenen passen niet >>> print(steen2 + steen1) >>> steen3 = steen1.draai() + steen2.draai() >>> steen3 Domino(4, 1) >>> print(steen3)