CIT 590 Assignment 5: Squarelotrons
Fall 2016, David Matuszek

# Purpose of this assignment

To give you experience with unit testing and TDD (Test-Driven Design)

# General idea of the assignment

Anita is the baby sitter of Baron Von Hauser’s kids. Von Hauser is a famous physics professor, so the Von Hauser kids have weird toys, all of which Anita has to master to be able to effectively entertain the kids.

While Anita was cleaning the bathtub she found a new toy, a Squarelotron game. It is extremely weird, and posses a lot of mathematical symmetry. She is determined to understand this new toy, otherwise she won´t be able to play with Von Hauser’s kids. However the complexity of such an extreme toy makes it difficult to play.

A Squarelotron consist basically of a matrix of numbers. This matrix can be decomposed as square rings which can rotate independently in 4 different ways: Upside-Down (↕), Left-Right (↔), reflected through the Inverse Diagonal ( `/` ), and reflected through the Main Diagonal ( `\` ) . As a puzzle, the object of the squarelotron is to take one that is scrambled, and return it to its original state. Here's what the original state looks like: The green line shows the main diagonal. Flipping the outer ring through the main diagonal means interchanging 2 and 6, 3 and 11, ..., 20 and 24. The inverse diagonal would be a line running through 5, 9, 19, 17, and 21.
The squarelotron has two rings and a center piece. The outer ring contains the numbers 1, 2, 3, 4, 5, 6, 10, 11, 15, 16, 20, 21, 22, 23, 24, 25, while the inner ring contains 7, 8, 9, 12, 14, 17, 18, 19. The number 13 is by itself in the center.

The following are examples of flips. They are not cumulative; each flip is shown as being from the initial state.

A Upside-Down Flip of the outer ring of the squarelotron yields: A Left-Right Flip of the inner ring of the squarelotron yields: A Flip through the Main Diagonal of the outer ring of the squarelotron yields: An Inverse Diagonal flip of the inner ring yields: Anita wants you to do a program which performs the following. It will  print out the initial squarelotron. Then the program will let you tell it which flips to perform, and it will print out the new squarelotron after each flip. Finally, the program will let you start with a new squarelotron, or quit.

# Details

Write and unit test the following functions. You should try using TDD, Test-Driven Design, as illustrated in class:

2. Write a test for the function.
3. Run the test, and make sure it fails.
4. Add code to the function to try to make the test pass.
5. Run the test again.
1. If the test fails, debug the function (or the test) until the test passes.
2. If the test passes, continue.
6. Is the function complete (does it do everything it should do)?
1. If the function isn't complete, add code to the test to check the new functionality. Go to step 3.
2. If the function is complete, you are done with this function.

Follow the specifications exactly, because we will also be using my unit tests to check your work. Also as before, the design of the user interface is up to you--but the program must provide clear instructions on how to use it. Write a `main()` function that we can use to begin your program. To simplify running both the program and the uint test, put the following lines at the end of your program:

```if __name__ == "__main__":     main()```

# Functions

Notice that in the squarelotron there are two rings that can be flipped (the center is immobile). In each of the following functions, the `ring` should be one of the two strings `'outer'` and `'inner'`, all lowercase, with the obvious meanings.

`make_squarelotron(list)`
returns A "squarelotron"
Given a "flat" list of 25 numbers, make and return a squarelotron. You probably want to represent the squarelotron as a list of lists, but that's up to you: Represent it however you like. It could even be just the list given as an argument. The first 5 numbers are the top row of the squarelotron, the next 5 numbers are the second row, etc. Calling this function should not result in any input/output.
```make_list(squarelotron) ``` returns A "flat" list of numbers
This function is the inverse of `make_squarelotron`. It returns a list of 25 numbers. (Note: Since I have not specified how to represent your squarelotron, I will depend heavily on the `make_squarelotron` and `make_list` functions to check all the rest of your functions; so get them right!) Calling this function should not result in any input/output.
```upside_down_flip(squarelotron, ring) ``` returns A new squarelotron.
This function performs the Upside-Down Flip of the squarelotron, as described above, and returns the new squarelotron. The original squarelotron should not be modified (I will check for this). Calling this function should not result in any input/output.
```left_right_flip(squarelotron, ring) ``` returns A new squarelotron.
This function performs the Left-Right Flip of the squarelotron, as described above, and returns the new squarelotron. The original squarelotron should not be modified (I will check for this). Calling this function should not result in any input/output.
```inverse_diagonal_flip(squarelotron, ring) ``` returns A new squarelotron.
This function performs the Main Inverse Diagonal of the squarelotron, as described above, and returns the new squarelotron. The original squarelotron should not be modified (I will check for this). Calling this function should not result in any input/output.
```main_diagonal_flip(squarelotron, ring) ``` returns A new squarelotron.
This function performs the Main Diagonal Flip of the squarelotron, as described above, and returns the new squarelotron. The original squarelotron should not be modified (I will check for this). Calling this function should not result in any input/output.

You may want to write some helper functions. For each helper function that does computation, use TDD and write unit tests first. The functions that primarily interact with the user (and do no significant computation) do not need to be unit tested, and can do any required input/output.

# Reference

This assignment is a modified version of the problem "10016 - Flip-Flop the Squarelotron," from Online Judge.

# Due date

Zip your two files and turn them in to Canvas before 11:59pm Tuesday, October 4.