Tuesday, May 30, 2017

Something a Little Different

Some of you may know that I recently started Hack Reactor Remote, an online computer coding bootcamp, with the aim of changing careers and becoming a software developer.  The reasons for doing so are myriad and I won't go into them now, but if you want to know, just ask!  (But don't expect an answer anytime soon as my schedule is now jam-packed.)

I want to write about one of the modules I just completed, called n-queens, which is a mathematical question that asks, "For an n x n chessboard, how many different ways can I place n number of queens in such a way that they cannot attack one another?"  You could also ask the same question for rooks as well, which is what I will be focusing on in this post.

One could fairly easily draw the problem out on pen and paper for small values of n (i.e., the number of solutions for n values of 1, 2, 3, 4 are 1, 2, 6, 24, respectively).  However, that quickly gets out of hand, as the number of solutions for an n of 5 and 6 are 120 and 720, respectively.

This is where programming and computers come into play, as they can find those 720 solutions in a matter of seconds, and won't complain about you wasting their time either.

To start the problem, we were given an outline for helper functions that would work together to find a solution for us.

Below is the "hasAnyRooksConflicts" function:


As you can see, it calls on two helper functions itself, which check for any column and row conflicts to make sure a given rook placement is valid and does not conflict with any other rooks on the board.

Using this helper function we can then write a function "countNRooksSolutions" that uses recursion to check for valid solutions, as such:


You can see we call "hasAnyRooksConflicts" on line 60.  When we run the given tests, which give the function an n values of 1 through 8, it takes my computer almost 16 seconds to find all the solutions, as seen in the red box below:


As I mentioned above, it takes this long because there are a lot of solutions for my computer to calculate, here are just how many, as seen in the console of my Chrome dev tools:


Over 40,000 solutions for an n of 8!  Told you it gets out of hand quickly.  

Now, my computer is brand new, and it still took 16 sec to complete.  Imagine how much harder an older computer would have to work.  Saving time and computing power would be even more essential.  What if I said there was a way to cut that time in half?  

Let's take a look at our function again.  The way it's written, with each iteration of the for loop in lines 57 to 64, we are looking at the next row of the board.  Since we're already skipping rows, we don't need to check for row conflicts.  

So let's replace "hasAnyRooksConflicts" on line 60 with "hasAnyColConflicts" which just checks for column conflicts, because that's what we're really interested in:  


When we run it now, it takes less than 7 seconds: 
We cut our run time by over half!  To be honest, I'm slightly surprised by our result as I expected it to be closer to 7.7 seconds.  Perhaps the mechanics of what exactly are going on here would make a good future post.  In the meantime, I hope this helps some of my Hack Reactor classmates who's computer fans scream at them when they run this function. 

Saturday, October 1, 2016

Planter Time!

Now that we have an actual backyard, we decided that the next rational step to nesting was to start an outdoor herb garden. I knew I wanted some kind of planter, but after scouring the internet for hours, I realized that in order to get the exact planter I wanted, we would have to build it ourselves.

Thus began our new project - the planter. I found a couple of plans online and ended up combining the two that looked the most promising. We loaded up on lumber and supplies at Home Depot, and started the building process. It ended up taking us a couple of days to build (because we kept getting rained out), but we finally finished the job!

Our shopping list:
Qty
Description
Part
2
4x4x10
Legs
2
2x4x8
Rails
2
1x6x10
Bottom
18
1x4x8
Slats
1
1x2x8
Door support
3
6" gate hinges

100+
Deck screws



And the best part was that Pat finally got to buy that circular saw that he'd been wanting for a while because we had to cut each board multiple times (and he didn't trust the Home Depot guys to cut it perfectly).


The cut list:

Pat cutting the legs for the planter
Once all the pieces were cut, we were able to start assembling the pieces - starting with the frame (which would serve as the platform where we would assemble the slats for the dirt to rest on - since we wanted to have the bottom of the planter available for storage).


Then Pat attached the legs to the frame




Once all the legs were securely screwed onto the frame, we started nailing the side slats to the legs. We were on a roll - but then Houston decided it was time to rain which meant that it was time for a lunch break :)


After we filled our bellies with delicious Chik-Fil-A, we returned to work and started to add the longer slats. 


Pat used clamps to hold the slats in place to make it easier to nail them down.


After we finished three sides, Houston decided to start raining again - so we gave up for the night. I had to go back to work the next day, so Pat decided to tackle the hardest part of the project by himself - building the door to the storage compartment.


He then attached it to the planter using the clamp/nail technique


Done!


The next step was to stain the planter. We used a one-step combination stain and polyurethane to seal the wood (Miniwax PolyShades in Pecan Satin 320).


Once that was fully dry, we lined it with planters fabric - making sure to overlap all the edges by at least 3-4 inches to make sure no leakage occurs.


We were finally ready to unload the handcart of goodies.


We added pond pebbles to the bottom to help with drainage. In retrospect, we probably should have bought 2 bags of pond pebbles - but by then, I just wanted to plant herbs so we decided against going back to Lowes (for the 3rd time) to get more supplies. We might regret this decision later on, but that's a situation for future Michelle and Pat to sort out.


Then we covered everything with a garden soil/manure combo and realized that the planter was too large, and that our calculations had been lacking - so we ended up going back to Lowes anyway to buy two more bags of soil.

Finally, we were able to transplant a few potted herbs (mint, basil, cilantro, rosemary) and sow some seeds (more basil - because you can never have enough, arugula, and a very hopeful peach pit).


And inspired by our good friends, Ale and Drew, we wanted to install some rain barrels as well (because water conservation is extremely important) - and we happened to find a pair Craigslist, woohoo!

Pat re-routed our gutter drains to dump into one of the rain barrels.


Then, built a beautiful stand for the rain barrels to sit on, and connected the two barrels with PVC pipes. It's only rained once or twice since the project's been completed, but the barrels are each already about 1/4 full!


And that's it! Hopefully this planter will keep our herb garden safe from slugs and possums for years to come!


Monday, September 5, 2016

Mango Mousse Mirror Cake

So much has happened in the past year. We sold our beautiful first homestead in Detroit and moved back to Houston. Between the move and re-nesting, we've definitely neglected the blog during the past year. Now that we're finally settled down in Houston, the posts will hopefully be a little more frequent - especially since we have so many home projects planned in the coming months :)

The new Houston home has a beautiful kitchen (one of my favorite rooms in the house). I haven't gotten a chance to do any real baking, and since today was my father-in-law's birthday, I figured it'd be the perfect opportunity to test out the new kitchen!

I've been drooling over Olga Noskovaa's mirror cake pictures on Instagram and have been itching to try it myself. After hours of watching youtube videos (and falling down multiple unrelated rabbit-holes), I finally found a couple of promising recipes and compiled them into something I thought might work well.
Mango Mouse Mirror Cake
(6 inch round cake)
Line your 6-in springform cake pan with parchment paper and line a receptacle of similar dimensions with cling wrap (this is for the mango jelly later). In the picture below, I also lined two 3-in springform pans with parchment paper because I knew I'd have some leftover batter, and I wanted to make a small test cake. I also lined a 3-in springform pan with clingwrap for the mango jelly.

Note the beautiful kitchen scale that Pat bought me for my birthday last month. I'd been craving one for YEARS!

Ingredients:
Almond sponge cake layer
  • Egg white portion:
    • 3.5 egg (whites)
    • 1/2 tsp cream of tartar
    • 1/4 cup sugar
  • Egg yolk portion:
    • 3.5 egg (yolks)
    • 1/4 cup sugar
    • 2 tbs + 2tsp oil
    • 2 tbs cup milk
    • 2/3 cup cake flour
    • 1/2 tsp baking powder
    • 1/4 tsp vanilla
    • 1/8 tsp almond extract

Directions for sponge cake:
1. Preheat oven to 350 deg F
2.Prepare the egg yolk portion first. In a medium bowl, whisk the egg yolks and sugar. Once incorporated, whisk in oil
3. Sift in the milk, flour, and baking bowder and whisk until evenly incorporated. Mix in vanilla an almond extract. Set batter aside.
4. Prepare the egg white portion next. Using a mixer, beat egg whites and cream of tartar together until soft peaks form
5. Add in sugar slowly (I do this in 2 separate steps, beating well in between)
6. Beat until stiff peaks form (do not over-beat).
7. Gently fold in 1/3 of egg white batter into yolk batter (you want to keep the mixture as fluffy as possible)
8. Fold the combined product into the rest of your egg white batter.
9. Pour into parchment-lined springform cake pan
10. Bake for 25-30 minutes.



Mango Jelly Layer
  • 200 grams strained mango puree
  • 30 grams sugar
  • 7 grams gelatin + 3 tbsp cold water
Mango Mousse
  • 300 grams strained mango puree
  • Juice 2 limes
  • 250 mL heavy whipping cream
  • 50 grams sugar
  • 1 packet (1 tbsp) powdered gelatin

Directions for mango jelly:
1. Bloom gelatin by adding water to gelatin powder. Set aside.
2. Make all of your mango puree at once. Peel and cut 2 large mangoes and measure out 500 grams. Add mango and 30 grams of sugar in a small pot. Cook on low heat until sugar dissolves. Place everything in a blender and puree until smooth. Divide into 2 bowls (one for jelly and one for mousse)
3. Add gelatin to one of the pureed mango bowls, mix well (adding low heat if needed), and pour into your prepared receptacles












Directions for mango mousse:
1. Bloom gelatin and set aside
2. Heat mango puree in small pan. Add gelatin to puree, stirring until dissolved.
3. Add lime juice and continue heating for a couple of minutes to firm up the puree and remove excess moisture
4. Allow mango mixture to cool.
5. In the meantime, whisk heavy whipping cream and sugar in mixer until soft peaks. Once mango mixture has cooled, fold puree into whipped cream mixture.

Assemble Cake!
1. Cut half an inch off the outside of your cake (you want the smoothness of the mango puree on the outside in order to obtain optimal glossiness when you pour your mirror glaze later (or if you were lucky enough to have a 7-in springform pan, you can place your 6-in cake in the middle of it instead). 

2. Cut sponge cake in half to give you two round cakes. Place the top half somewhere safe. 
3. Sprinkle a few pieces of mango on top of the 1st layer of sponge cake. Cover with mango mousse and top with your piece of mango jelly. Place the top half of the cake on top of the jelly and top it all off with the rest of your mousse. The top of the cake should be as flat as possible.
4. Cover and place in freezer overnight (or at least 4 hours).


Mirror Glaze
  • 100 grams of sweetened condensed milk
    • 150 grams granulated sugar
    • 75 grams water
    • 175 grams white chocolate chips
    • 9.5 grams gelatin (+1/4 cup water to bloom)
    Directions for mirror glaze
    1. Remove your cake from the freezer

    2. Bloom gelatin with water and set aside (~5 min)
    3. Heat milk, sugar, and water over saucepan on medium heat, and bring to a simmer. Place chocolate chips in large, heat-proof bowl
    4. Stir-in bloomed gelatin until dissolved
    5. Pour hot mixture over chocolate and let sit for about 5 minutes. Once softened, use a hand whisk to smooth mixture - try to minimize the amount of bubbles.
    6. Remove a small portion of the mixture (if you want to do 2 separate colors). Add gel food coloring to each bowl and mix well.
    7. Pour mixtures through sieve to remove any lumps.
    8. Allow glaze to cool to 32-34 C before pouring. While waiting, (the mixture took over 30 minutes to cool down - I think the thermometer I was using was broken, because it was reading 120F after 30 minutes, AND the mixture was lukewarm to the touch - I gave up and just poured the mixture onto the cake anyway) pop your cake out of the springform pan and position the cake on a pedestal (ie: upside down Pyrex containers) over a lined cooking sheet (for easier cleaning later).

    8. Pour glaze. Start the pour around the OUTSIDE of the cake and work towards the center. Make sure the glaze covers cake down to the base


    9. Let glaze drip for at least 5 minutes. Cut drips off from under the plate and place on serving plate
    10. Serve immediately or place in refrigerator.


    Whew! And after a million steps, you're finally done, and your kitchen will look like a disastrous mess. I stopped taking pictures halfway through because the kitchen counter was just too messy.


    This was the smaller "test-cake"



     

    Goodnight all!

    Wednesday, October 21, 2015

    Edge Grain Cutting Board

    We're back with another woodworking project!  Our cutting board which has served us well for several years is starting to come apart and I figured it would be a perfect opportunity for a new project.

    First step was to get some wood, reclaimed, preferably.  I went to a place here in town called Architectural Salvage Warehouse and picked up one big oak board, and another board that came from the top of a piano lid, also oak i think:


    I took the boards and cut them up into strips like so:


    Then I played around with the arrangement and applied a bunch of glue:


    And clamped them up:


    After letting it sit overnight i took it out of the clamps and used this planer to smooth out and flatten the board:


    Nom nom nom: 


    Squared off the the ends on a miter saw and here we are:


    Oiled it up with some mineral oil and let it soak in overnight:


    Wiped off any excess and we're done! (hat tip to Michelle for the arranging the picture)



    This is where i chose to stop, with an edge grain board.  If I felt inclined, I could have done another round of cutting and gluing to create an end grain board, but then the final step of flattening the board would have taken much longer as the planer is not meant to handle end grain.  

    If you're interested in a more detailed step by step, you can refer to this Instructable, which is what I used to do this project.

    Overall, very pleased with the way it turned out, and how quick it was.  It only took two separate trips to Techshop (and only about 1-2hrs each time), with the gluing and oiling doing their thing overnight.