W2D2: Toy Problem

We had our first toy problem today


For the rest of the 3months the first hour would be spent on solving toy problems. Here is ours today:

Rock Paper Permutation

Given a number of rounds n, return all the possible rock-paper-scissors play possibilities for that number of rounds.

I spent a good amount of thinking, trying to figure what the base case and edge case would be. Visualizing on the whiteboard organized my thoughts but I did not know how to approach this with code.

In the end I could not do it. The hour ended, but this problem plagued my mind. I was thinking it through during lunch and finally came up with an algorithm that works. Here it is in shitty pseudocode.
rps_array = [rock, paper, scissors];
result_array = []
recursion function(array){
    base-case: if array.length = rounds_num, push this array into result_array
    if not, iterate over rps_array to add each one to the array that was passed in, creating 3     new stacks.
    pass in each new array back into the recursion function
}
Each recursion stack would return an array of length 3, which in turn gets passed into another recursion stack. Basically a tree of threes. I was super happy about this achievement but turns out a good number of people finished the assignment during the first hour. Jeez, there are some smart people here.


What we did today:
1. Toy Problem

2. Continue pair programming on the subclass dance party sprint
We ended up creating a page that randomly produces a cat_dancer and a banana_dancer. Ours looked mediocre compared to others', me and my partner justified that this is due to our lack of experience with html and css. Whatever makes us feel better, right?

3. Town Hall

1.19.16

No comments:

Post a Comment