# Mazes 2

Mazes #2

Assignment: Do any 5 of the  required assignments. To get an A you must do “Spiral Inwards” assignment (see second from bottom)

You can also, skip everything and try the bottom map which is extra credit (and very, very hard). If you do that, you do not need to solve any other maps. Note: this is a very, very hard map, and I don’t recommend most people trying to do the extra credit until they’ve done the required ones.

Bismark’s Map

Struhl Map:

• Start   20, 18
• go around the interior, get the flower, pick it up.
• 1 loop only

Heeyeon’s Map:

• start Jeroo at (23,1) and pick up the flower  at that location
• go to (1,23)
• you may NOT pick a flower or visit a cell that has a flower

Picture at start:

Picture at end:

Brett’s Maze 2

Description: Start at 0,0, pick all the flowers then use them to toss() your way through the nets.

George’s Map  : Start at ( 10,0) , facing SOUTH,  Use 1 loop and pick the flower.

Paul’s Diagonal Map

Matt’s All Flower Map

To get an A you must do the following assignment.

Diagonal Inwards
Fill up the Map
• * Use a blank map and have 2 Jeroos fill up every spot with a flower.
• Use a single loop (not an infinite one either)

Sota

EXTRA CREDIT:

Description:Pick all of the flowers in the map below.
The Kukai Method

The Sam Smith Method

The Hamza Method

Cody Smith Method

Christian’s Bismarck  Solution

# Mazes 1

Objective: To use while loops to get the Jeroo to pass through each maze and get the flower. It is possible to write a solution to both of these mazes using a single while loop–albeit this loop will have several( about 5 or 6) if tests! It is important for this problem that you do NOT simply hand code this. To get an A on both of these assignments you must use 1 single while loop per maze.

1) island3-A

2) Mazes 2 (start in top left, 1 loop to pick flower)

3) island-3-D (start in the top left, and get to the bottom right)

4) ZigZag   : Use 1 while loop (not infinite), follow the flowers, picking them up and use those flowers traverse over the nets

5)  Spell Z (Blank Map)

1. start at 0 , 0 with 70 flowers.
2. Use a single while loop to spell a letter z

Last and most definitely not least:

island3-C ** A+ assignment.

This is the deceptively hard and should be done last and only if you want that A+

Done all of the maps? Start on the next set here

# Systematically Visit All Cells [Java]

Description: It’s harvest time and Adam must pick all of the flowers on the island. Unfortunately for Adam, he doesn’t know where the flowers are growing. Flowers could be growing anywhere on the island. In order to keep from being too exhausted, he can only visit each cell once, and he cannot try to pick from an empty cell. There are no nets, water features, or other Jeroos on the island. The purpose of this program is to find a systematic way for Adam to visit every cell exactly once, and pick the flowers from the cells that have flowers.

The Maps

Note: Do not be fooled by how similar the next map is. You will probably have to rewrite some code to complete the next one.

# Extra Credit (GOOD LUCK!)

Note first try addition , also worth some (though less) extra credit.

** int[] multiply(int[] num1, int[] num2, int base) throws ArithmeticException

@precondition `1 < base < 11`
@precondition `num1.length = 5 and num2.length = 5`
@postcondition: the returned array has 5 elements representing the product or an ArithmeticException is thrown

Description: This method attempts to replicate multiplication. Both num1 and num2 represent five digit numbers. Each element in the array stores one of the digits. For instance, the number 143 would be represented as {0,0,1,4,3 }. Numbers can be in any base between 2 and 10 inclusive , and the number 101102 in binary would appear in an arrays as : {1, 0, 1 , 1, 0 } . Let’s assume the numbers are positive. You should return an array representing the digits of the product of num1 and num2. If the number of digits in the product exceeds the maximum number of digits (5) , you should throw an arithmetic exception as shown in the code below:

Note: You may not use any kind of helper or utility methods that are built into pre-defined Java classes for converting numbers between bases. Only use techniques taught in this class.

 Method Call return value/output multiply ( {0,0,0 , 4,2},{0,0,0,5,1}, 10) {0 , 2 ,  1 ,  4 ,  2}    (42 *51= 2142) multiply ( {0,0,0, 3,1} , { 0 ,0,0,2,4}, 10) {0 , 0 ,  7 , 4 ,  4}    (31 *24= 744) multiply ( {6,5,1, 3,1} , { 0 ,0,0,2,4}, 10) throw an ArithmeticException

### Tool for checking work

Use programmers calc to check your work. This is an awesome 64 calculator and you can multiply in binary, decimal or octal to help you see if you did your work correctly.

# Climb the Stairs

Start you jeroo in the bottom picture and have it climb to the flower. Use 1 and only 1  while loop.

 climb-the-stairs__1.jev climb-the-stairs__2.jev climb-the-stairs__3.jev climb-the-stairs__4.jev

# Hurdles

Objective: A Jeroo starts at the southwest corner of the island, location (23,0), facing East with no flowers. There is a flower somewhere east of the Jeroo. There are zero or more hurdles, represented by nets, between the Jeroo and the flower. Each hurdle is a rectangular arrangement of nets with its base along the Southern Sea. The height and width of each hurdle is unknown. The number of hurdles and the spacing between the hurdles is unknown. There is at least one row of empty cells along the top and sides of each hurdle. There are no water features and no other Jeroos on the island. The only nets are those that define the hurdles. The goal of this program is to have the Jeroo jump all of the nets, pick the flower, and stop. A representative island is shown in figure 1.

• start at bottom left
• with zero flowers
• use a single while loop
• you may only hop() a single space (ie no hop(2), hop(3), hop(n) )
•  pick the flower that is (generally) located on the right

OneHurdle.jev

ManyHurdles.jev

Extreme Hurdles.jev    8/10

Description:Write an infinite loop that makes your Jeroo travel around the perimeter of the island.  9/10

• this gets you the 10/10
• use 1 while loop
• the Jeroo should travel in an infinite loop around the perimeter of the map.

jacob_icejet_map2 Extra credit

• this is extra credit
• 1 while loop
• pick the one flower in the top right and use that to access the flower that is in the bottom middle.

# Two Friends Meet

One Saturday morning, two friends, Bugs and Daffy, decide to meet and plant flowers to beautify Santong island. Daffy starts in the Northwest corner facing East with 90 flowers in his pouch. Bugs starts in the Northeast corner facing West with 90 flowers in his pouch. Bugs and Daffy begin hopping toward one another. As they hop, each plants exactly one flower at every location it enters, including its starting location. They meet, facing each other, roughly in the middle of row 0. After a handshake and a little small talk, Bugs and Daffy both turn toward the south and continue planting flowers all the way to the southern edge of the island. When both reach the South Sea, the say goodbye and part. Daffy turns west and plants flowers all the way to the Western Ocean. Bugs turns east and plants flowers all the way to the Eastern Ocean. This is where our story ends. Your task is to write a Jeroo program that will illustrate this story.

One possible solution to this project is represented in the picture below

# Luhn Check

Luhn Check starter Code

It is possible to tell if a number could be a valid credit card. Credit cards numbers can be validated against an algorithm known as a Luhn.  Read this first.

Luhn Number Generator

http://www.datagenetics.com/blog/july42013/index.html

Counting from the check digit, which is the rightmost, and moving left, double the value of every second digit.

Sum the digits of the products together with the undoubled digits from the original number.

If the total ends in 0 (put another way, if the total modulo 10 is congruent to 0), then the number is valid according to the Luhn formula; else it is not valid.

Mod 10+5 Variant Some credit cards use the “Mod 10 plus 5” variant to extend the space of valid card numbers.[citation needed] In this variant, if the sum ends in 0 or 5, the number is considered valid

Before handing in your code, first test it with the LuhnChecker–which I will also use when grading.

A more extensive analysis with good images and an online Luhn Checker

# Jeroo Walk The Lake with Loops

Original Project Descriptions is here

Acknowledgement This problem is adapted from one that was created originally by Erica Eddy of The University of Wisconsin – Parkside.

Your jeroo is exploring the outer perimeter of the lake. It starts next to a flower and travels the entire way around the lake. Have your jeroo stop immediately before the flower (using a loop) and then, after the loop is over,  your jeroo should pick the flower.

 Map #1 : rectangular-lake.jev
 recangular-lake-if2.jev
 For this one, your Jeroo should travel around the entire outer rim of the island and stop immediately before the flower. rim-of-lake-1.jev

 rectangular-lake-bumps1.jev
 Remember Nets kill Jeroosrectangular-lake-bumps2.jev
 Write a loop that makes the jeroo travel around the lake below. This loop should never end. walk-the-lake-jacks-map.jev

# Printing Digits Of Numbers in Java Assignment

Let’s write the following method

public void printDigits( int n){

}

Walk through of how the code should work:

the algorithm inolves

1) extract last digit

2) print last digit

3) remove last digit

keep doing this until there are no more digits

Example :

Let’s look at printDigits( 345)

Walk through of how the code should work:

the algorithm inolves

1) extract last digit ‘5’

2) print last digit print ‘5’

3) remove last digit now n should be ’34’

do this for ‘4’ and then ‘3’ until there are no more digits

You need a while loop. Think about it. What is the value of n when there are no more digits?