Week review
Ok so, it was the last day of the week, everybody is pretty messed up thanks to the huge amount of content, to the Engineer Empathy, etc…
Yesterday, we started with a review session with Sea Lions, the cohort prior to us who’s on the bootcamp with us. During that session, what came out was :
- Sea lions are happy to be around us
- Week 1 of Phase 2 was awesome
- Week 1 of Phase 1 was awesome, even though it was a bit overwhelming
- Engineer Empathy affected every one of us, big time
I could explain more right now but I think I’ll just do a quick recap during the weekend if I can.
Sudoku day!
So, today was the last day of this first week of DBC. One of the “initiation rituals” of that first week seems to be that first friday theme : Sudoku. The idea is that we worked hard all week on challenges here and there, and on this friday they gave us the “Ultimate challenge of the week”. For this challenge, you have 2 assignments :
- In the morning, you have to write code that reads a sudoku data line, then builds a grid and solves it without guessing.
- For the rest of the day… Implement guessing!
I was to pair with Nic, a guy who chose to redo phase 0 to make sur he got all the knowledge he could get from it. But then, Nic already completed that challenge on the last cohort. So the rules we went for were :
- We don’t check any of the code he did before
- His thoughts may very well just end up being guided by what he already did, so I found the suggestions, he would just comment, agree, debate, etc…
Let me tell you guys : That went well! We ended up implementing an object-oriented piece of code that actually ran faster (50%) than the one he had last year!
If you want more info on that :
We created a cell object that had the value for that cell, and all the info about its position as its attributes. This way, a simple call and we got all the cells in this array, in this row, or in this column.
Geek talk : My take on people’s solutions
People actually implemented the same algorithm over and over again. To sum it up I’ld say :
- Select a cell
- Get the values of the non-empty cells in the same row, column, and box
- Subtract the values you found from an array of the possible values (1 to 9)
- If there is only one remaining possible value, assign it to that space
- Do it again until all the spaces are taken
That was common for every one of us that I saw. But then the huge difference was : The data structure. You had to make a choice there that would make the code change big time, but let me explain that :
This data structure can be put in one of 3 different groups.
- Nested array. You make arrays in an array, and so you get a 2D array
- Something hybrid from 1 and 3
- Cells as an object that you put in an array
Obviously, the 1 is the easiest way to go to put and get the data, right? And the last one may just end up being the most complicated one (What do I need my object to know? How do I create it? And how do I call the attributes of that object? Do I calculate them on the go? …).
Now, the interesting part is that, for this problem, the easiest the data structure, the hardest the rest of your code will be. Because when you have a nested array, how do you call a block? How about a column? How do you check if all the blank spaces have been filled? Do you do some kind of nested loop to go through your nested arrays?
But then if you chose the 3, this method just ends up selecting whatever you need in one line.
In the end, since the rest of the code was basically the same, the main difference was there.
If you check the code of people in the cohort, most of the people chose something around 2. Some were pushing in the direction of 3, some in the direction of 1, but mostly doing 2.
One did go through with 0 (Way to go Armando and Chermaine!), and one did actually do something that could be a “0” in my list : A simple array. You calculate the row,column and box from the index every time you need one of them.
Anyway, that was what I found and I would be happy to share more if you have any more question!
I’ll just end this post with this very profound quote : “Today was a good day”