[Week 4]

dbisazza
Design Computing
Published in
2 min readMar 30, 2017

This week the main focus was working on the Holy Wars assignment. The topic I had is long variable names vs short/abbreviated names. It was pretty straight forward in its nature but there was a few interesting arguments online that were a good read.

Looking at the previous weeks pyramid solutions from other students was an eye opener to the different ways you can go about the problem. It also helped me see how I could improve my code — e.g. using the absolute value rather than doing the two different cases separately.

In terms of this weeks exercises, there wasn’t too much to do thankfully as it allowed more time to work on the assignment. The guessing game was relatively straight forward after looking at and understanding the exercise 2 code. The code I wrote is a bit messy so I would want to fix it style wise. One problem I faced was that I didn’t seem to be passing the tests even though the game seemed to be operating perfectly fine. After going through asking for help with 2 of the tutors — Ben came to the rescue. It turned out that we were supposed to return “You got it!” not the value of the number guessed. And that is how I wasted the whole tutorial.

Diagram to solve example 3

Exercise 4 I found a bit funner as it required a more logical thinking process. The first step was to fully understand the steps involved in a binary search after that it wasn’t too difficult to translate into code. On problem I did face was how make the value of the middle value an integer (since I wasn’t sure whether to floor or ceil). After a bit of research I ended up using a new notation I hadn’t seen “//” which is equivalent to floor division/integer division.

Diagram to solve example 4

--

--