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

Vergelijkbare documenten
Genetic code. Assignment

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.

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

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

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

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

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

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

z x 1 x 2 x 3 x 4 s 1 s 2 s 3 rij rij rij rij

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:

Christmas party. Preparation. Assignment

Buzzword bingo Buzzword bingo bul shit bingo

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

Classification of triangles

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

Chromosomal crossover

Country recognition. Assignment

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

Earth Similarity Index

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

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

Roman numerals. Assignment

Preschool Kindergarten

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

MyDHL+ Van Non-Corporate naar Corporate

ALGORITMIEK: answers exercise class 7

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Solar system. Assignment

Speleology. Assignment

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

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:

L.Net s88sd16-n aansluitingen en programmering.

Handleiding Zuludesk Parent

General info on using shopping carts with Ingenico epayments

Pigpen cipher. Assignment

B1 Woordkennis: Spelling

AE1103 Statics. 25 January h h. Answer sheets. Last name and initials:

Group work to study a new subject.

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

L.Net s88sd16-n aansluitingen en programmering.

Engels op Niveau A2 Workshops Woordkennis 1

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

Bijlage 2: Informatie met betrekking tot goede praktijkvoorbeelden in Londen, het Verenigd Koninkrijk en Queensland

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

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE

Settings for the C100BRS4 MAC Address Spoofing with cable Internet.

Four-card problem. Input

Tentamen Objectgeorienteerd Programmeren

Ontpopping. ORGACOM Thuis in het Museum

Handleiding Installatie ADS

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

Demultiplexing reads FASTA format genome sequencing reads run

Introductie in flowcharts

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

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

Assignment. Example. is surrounded by exactly 3 coloured cells.

Daylight saving time. Assignment

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

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.

Esther Lee-Varisco Matt Zhang

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

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

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

Feathered friends. Assignment

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

Diana Cryptosystem trigraph one-time pad

2019 SUNEXCHANGE USER GUIDE LAST UPDATED

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

Meetkunde en Lineaire Algebra

LDA Topic Modeling. Informa5ekunde als hulpwetenschap. 9 maart 2015

liniled Cast Joint liniled Gietmof liniled Castjoint

Exercise P672 Lightweight Structures. A.P.H.W. Habraken. Report

How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics!

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

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

Intermax backup exclusion files

CHROMA STANDAARDREEKS

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

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

Mounting ceiling & wall

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

PLUS & PRO. Addendum installatie aanvullende MID 65A kwh-meter - Addendum installation additional MID 65A kwh-meter SET

AE1103 Statics. 3 November h h. Answer sheets. Last name and initials:

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculteit Wiskunde en Informatica. Tentamen Calculus B (2WBB1) op maandag 28 januari 2013, 14:00 17:00 uur

Interface tussen Stuurbediening en Sony autoaudio

DBMS. DataBase Management System. Op dit moment gebruiken bijna alle DBMS'en het relationele model. Deze worden RDBMS'en genoemd.

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

Beste ouder / verzorger, Welkom bij Mijnschoolinfo, het communicatie platform voor basisonderwijs.

Plotten. technisch tekenwerk AUTOCAD 2000

Firewall van de Speedtouch 789wl volledig uitschakelen?

FOR DUTCH STUDENTS! ENGLISH VERSION NEXT PAGE. Toets Inleiding Kansrekening 1 22 februari 2013

Leeftijdcheck (NL) Age Check (EN)

Meetkunde en Lineaire Algebra

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Graphic Design. Keuzevak GD1. Raul Martinez-Orozco / raul@thecombine.nl)

Yes/No (if not you pay an additional EUR 75 fee to be a member in 2020

Tentamen T1 Chemische Analysemethoden 6 maart 2014

CTI SUITE TSP DETAILS

Transcriptie:

Bifid cipher The bifid cipher is one of the classical cipher techniques that can also easily be executed by hand. The technique was invented around 1901 by amateur cryptographer Felix Delastelle. The cipher is a combination of substitution and fractionizing. A square $n \times n$ grid ($2 \leq n \leq 10$) is used. In this grid you will find all symbols that occur in the text that needs ciphering. In order to further explain this technique we will use the $9 \times 9$ grid below as an example. Pay attention to the fact that a space occurs as a symbol on the sixth row and the eighth column (rows and columns are numbered from zero). In order to cipher the original text This is a dead parrot!, every symbol of the text is converted to the corresponding row and column number where the symbol can be found. For example, we find uppercase letter T in the grid on row 2 and column 1. These row and column numbers are written vertically under the corresponding symbols from the original text. original text: T h i s i s a d e a d p a r r o t! ------------------------------------------- row: 2 4 4 6 6 4 6 6 4 6 4 4 4 4 6 5 4 5 5 5 6 7 column: 1 7 8 0 8 8 0 8 0 8 3 4 0 3 8 6 0 8 8 5 1 5 After that, the digits are written after each other: first the row numbers, followed by the column numbers. 2 4 4 6 6 4 6 6... 5 5 6 7 1 7 8 0... 8 6 0 8 8 5 1 5 At last, the digits are put together in groups of two, and every pair of digits is converted to the corresponding symbol in the square grid. The first digit of every pair represents the row number in the grid, the second represents the column number. The pair 2 4, for example, corresponds with the uppercase letter W, that we can find in the grid on row 2 and column 4. 2 4 4 6 6 4 6 6... 5 5 6 7 1 7 8 0... 8 6 0 8 8 5 1 5 W g w y o z Q ( $ I } O Here we see how the original text This is a dead parrot! was converted according to the bifid cipher i n the coded text WgwygeexfozQ(%II5D$I}O. In order the decipher the text, we should apply the reverse process.

Assignment Define a class Bifid that can be used to code an decode texts using the bifid cipher with a given square grid. This class must support the following methods: An initializing method init that allows making a bifid cipher for a given square $n \times n$ grid. Two arguments must be given to this method: the value $n$ and a string with length $n^2$ with the symbols of the grid, printed from left to right and from top to bottom. The initializing method should verify $2 \leq n \leq 10$ and that the string given has the correct length. Look at the example below to determine which action the method should take if the conditions aren't met. A method symbol that prints the symbol that can be found in the grid on a given row and a given column. The row and column number must be given to the method as separate arguments. Look at the example below to see which action the method should take if the position given in invalid. A method position that prints a tuple with the row number and the column number of the position in the grid on which a given symbol can be found. The symbol must be given as an argument to the method. Look at the example below to determine which action the method should take if the symbol does not consist of only one character, or if the symbol can't be found in the grid. A method code that prints the coded version of a given text as a result. The text must be coded according to the bifid cipher with the grid that was given when making the Bifid object. The original text must be given to the function as an argument. A method decode that prints the original version of a ciphered text as a result. The text must be decoded according to the bifid cipher with the grid that was given when making the Bifid object. The coded text must be given to the function as an argument. Example Remark: If you use the test examples below for a docstring, you should know that a single quotation mark that is used in the string that was given as second argument to the initializing method of the class Bifid, must get a double escape. In other words, the fragment \' in the string must be replaced by \\'. >>> cipher = Bifid(9, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdef' \ + 'ghijklmnopqrstuvwxyz.,;:?!"\'-()[]{}$=%') >>> cipher.symbol(2, 1) 'T' >>> cipher.symbol(7, 10) AssertionError: invalid position in grid >>> cipher.position('t') (2, 1) >>> cipher.position('wrong') AssertionError: symbol must consist of 1 character >>> cipher.position('~') AssertionError: unknown symbol: '~'

>>> cioher.code('this is a dead parrot!') 'WgwygeexfozQ(%II5D$I}O' >>> cipher.decode('wgwygeexfozq(%ii5d$i}o') 'This is a dead parrot!' >>> cipher = Bifid(20, '...') AssertionError: 2 <= n <= 10 must apply >>> cipher = Bifid(3, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') AssertionError: number of symbols does not correspond to size grid Bifidcodering is één van de klassieke coderingstechnieken die ook makkelijk met de hand kunnen uitgevoerd worden. De techniek werd rond 1901 uitgevonden door amateur-cryptograaf Felix Delastelle. De codering is een combinatie van substitutie met fractionering. Hierbij wordt gebruik gemaakt van een vierkant $n \times n$ rooster ($2 \leq n \leq 10$). In dit rooster worden alle symbolen geplaatst die in de te coderen tekst kunnen voorkomen. Om de techniek verder uit te leggen, zullen we bij wijze van voorbeeld werken met onderstaand $9 \times 9$ rooster. Let hierbij op het feit dat een spatie als symbool voorkomt in het rooster op rij zes en kolom acht (rijen en kolommen worden genummerd vanaf nul). Om de originele tekst This is a dead parrot! te coderen, wordt eerst elk symbool van de tekst omgezet naar het corresponderende rij- en kolomnummer waar het symbool terug te vinden is in het rooster. Zo vinden we bijvoorbeeld de hoofdletter T terug in het rooster op rij 2 en kolom 1. Deze rij- en kolomnummers worden verticaal onder de corresponderende symbolen van de originele tekst geschreven. originele tekst: T h i s i s a d e a d p a r r o t! ------------------------------------------- rij: 2 4 4 6 6 4 6 6 4 6 4 4 4 4 6 5 4 5 5 5 6 7 kolom: 1 7 8 0 8 8 0 8 0 8 3 4 0 3 8 6 0 8 8 5 1 5 Daarna worden de cijfers achter elkaar uitgeschreven: eerst de rijnummers, gevolgd door de kolomnummers. 2 4 4 6 6 4 6 6... 5 5 6 7 1 7 8 0... 8 6 0 8 8 5 1 5 Tenslotte worden de cijfers in groepen van twee samengenomen, en wordt elk cijferpaar omgezet naar het corresponderende symbool in het vierkant rooster. Het eerste cijfer van elk paar stelt hierbij het rijnummer voor in het rooster, en het tweede cijfer het kolomnummer. Zo

correspondeert het paar 2 4 bijvoorbeeld met de hoofdletter W, die we in het rooster terugvinden op rij 2 en kolom 4. 2 4 4 6 6 4 6 6... 5 5 6 7 1 7 8 0... 8 6 0 8 8 5 1 5 W g w y o z Q ( $ I } O Op die manier werd geïllustreerd hoe de originele tekst This is a dead parrot! volgens het bifidcijfer wordt omgezet in de gecodeerde te kst WgwygeexfozQ(%II5D$I}O. Voor decodering van een gecodeerd tekstbericht moet de omgekeerde bewerking uitgevoerd worden. Opgave Definieer een klasse Bifid waarmee teksten kunnen gecodeerd en gedecodeerd worden volgens de bifidcodering met een gegeven vierkant rooster. Deze klasse moet ondersteuning bieden aan de volgende methoden: Een initialisatiemethode init die toelaat om een bifidcodering aan te maken voor een gegeven vierkant $n \times n$ rooster. Aan deze initialisatiemethode moeten twee argumenten doorgegeven worden: de waarde $n$ en een string van lengte $n^2$ met de symbolen van het rooster, uitgeschreven van links naar rechts en van boven naar onder. De initialisatiemethode moet nagaan dat $2 \leq n \leq 10$ en dat de opgegeven string de correcte lengte heeft. Bekijk onderstaand voorbeeld om na te gaan welke actie de initialisatiemethode moet nemen indien niet aan deze voorwaarden voldaan is. Een methode symbool die het symbool teruggeeft dat in het rooster kan gevonden worden op een gegeven rij en een gegeven kolom. De gegeven rij- en kolomnummers moeten als afzonderlijke argumenten aan de methode doorgeven worden. Bekijk onderstaand voorbeeld om na te gaan welke actie de methode moet nemen indien een ongeldige positie in het rooster wordt opgegeven. Een methode positie die een tuple teruggeeft met het rijnummer en het kolomnummer van de positie in het rooster waarop een gegeven symbool kan teruggevonden worden. Het gegeven symbool moet als argument aan de methode doorgegeven worden. Bekijk onderstaand voorbeeld om na te gaan welke actie de methode moet nemen indien het gegeven symbool niet uit één enkel karakter bestaat, of indien het niet in het rooster teruggevonden wordt. Een methode codeer die de gecodeerde versie van een gegeven tekst als resultaat teruggeeft. Deze codering moet gebeuren volgens de bifidcodering met het rooster dat werd opgegeven bij het aanmaken van het Bifid object. De originele tekst moet als argument aan de functie doorgegeven worden. Een methode decodeer die de originele versie van een gegeven gecodeerde tekst als resultaat teruggeeft. Deze decodering moet gebeuren volgens de bifidcodering met het rooster dat werd opgegeven bij het aanmaken van het Bifid object. De gecodeerde tekst moet als argument aan de functie doorgegeven worden. Voorbeeld Opmerking: Indien je onderstaande testvoorbeelden opneemt in een docstring, let er dan op dat het enkele aanhalingsteken dat gebruikt wordt in de string die als tweede argument wordt doorgegeven aan de initialisatiemethode van de klasse Bifid, een dubbele escape moet meekrijgen. Met andere woorden, het fragment \' in de string moet vervangen worden door \\'.

>>> cijfer = Bifid(9, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdef' \ + 'ghijklmnopqrstuvwxyz.,;:?!"\'-()[]{}$=%') >>> cijfer.symbool(2, 1) 'T' >>> cijfer.symbool(7, 10) AssertionError: ongeldige positie in rooster >>> cijfer.positie('t') (2, 1) >>> cijfer.positie('fout') AssertionError: symbool moet uit 1 karakter bestaan >>> cijfer.positie('~') AssertionError: onbekend symbool: '~' >>> cijfer.codeer('this is a dead parrot!') 'WgwygeexfozQ(%II5D$I}O' >>> cijfer.decodeer('wgwygeexfozq(%ii5d$i}o') 'This is a dead parrot!' >>> cijfer = Bifid(20, '...') AssertionError: er moet gelden dat 2 <= n <= 10 >>> cijfer = Bifid(3, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') AssertionError: aantal symbolen komt niet overeen met grootte van het rooster