Download (right-click, save target as ...) this page as a jupyterlab notebook from: Lab4-HW


Laboratory 4: Input and Output

LAST NAME, FIRST NAME

R00000000

ENGR 1330 Laboratory 4 - Homework

Exercise 1 : Find the Treasure Part 1

Consider the structure below (a treasure map)

              +-------------------------+
              ¦ 34 ¦ 21 ¦ 32 ¦ 41 ¦ 25  ¦
              +----+----+----+----+-----¦
              ¦ 14 ¦ 42 ¦ 43 ¦ 14 ¦ 31  ¦
              +----+----+----+----+-----¦
              ¦ 54 ¦ 45 ¦ 52 ¦ 42 ¦ 23  ¦
              +----+----+----+----+-----¦
              ¦ 33 ¦ 15 ¦ 51 ¦ 31 ¦ 35  ¦
              +----+----+----+----+-----¦
              ¦ 21 ¦ 52 ¦ 33 ¦ 13 ¦ 23  ¦
              +-------------------------+

Background

Eventually we will write a program to explore the above matrix for a treasure, but first lets understand the map structure. The values in the array are clues.

Each cell in the matrix contains an integer between 11 and 55; for each value the ten's digit represents the row number and the unit's digit represents the column number of the cell containing the next clue.

For example starting in the upper left corner (at row = 1,column = 1), use the clues to guide your search of the array. So (1,1) contains 34. Next move to (3,4), which contains 43. Move to (4,2), which contains 15, and so on.

The treasure is a cell whose value is the same as its coordinates.

The program must eventually read in the treasure map data into a 5 by 5 array, and should output the cells it visits during its search, and a message indicating where you found the treasure.

The "Treasure Hunt Problem" is from the HackerRank.com avaiable at https://www.hackerrank.com/contests/startatastartup/challenges/treasure-hunt

Now for your problem Write a script to take input from user in terms of row number and column number. Return contents of treasure map at position indicated by the row and column to the user.

Exercise 2 -- Following the Clues

Using your treasure map script and start at (1,1). Use the output clues as input and rerun the script. Stop when you have found the treasure. Here are a few to work with, remember to use the interactive input version that you created, you can add cells as needed, and cut and paste to generate the necessary sequence of cells