Wednesday, December 12, 2012

a fun math card game and a computer program to solve it.

My wife has been playing this fun card game ever since she was a kid, and I just learn about it recently. The game can be played with 2 or more people.

1) Start with a normal deck of card and remove all the face cards, so only cards 1 to 10 remains
2) Shuffle the cards
3) Set 4 cards face-down and apart in a square fashion so all 4 cards can be see at once
4) Everyone turn over the cards at the same time
5) Use all 4 cards, and any combination of +, -, *, and /,
6) When a player to find a solution that results as 24, the player must slaps the table and calls out the solution.
7) First person slaps and provides the correct answer wins the round and keeps the 4 cards.
6) Play until all the cards gone and the winner is the person with the most number of cards

Here is another variation for younger kids.
5) Allow only +, and - for math operations and you don't have to use all 4 cards
6) find a solution that results as 5
7) the 1st person that slaps, provides the correct answer, and uses the most cards, wins the round and keeps number of cards used in the solutions. The unused cards goes into a junk pile.

Needless to say, I didn't win any games. So I decided to write this little C# program to find all possible solutions to sooth my ego a bit. :)

This recursive program can handle any number of cards (not just 4) and solve for any value (not just 24).
It can find all possible solutions or just the 1st one. This is brute force algorithm to checks for all combination, I imagine there must be a more elegant solution.

If you need a refresher on recursion, here is a link with good description. I referenced this model when I wrote this code.

Here is the code.

Monday, December 10, 2012

My reflection after reading "Battle Hymn of the Tiger Mother"

I just finished reading "Battle Hymn of the Tiger Mother". This is not a book review, there are enough reviews already. This is much more personal in nature. My reasons for reading book and what I got out of it.

I picked up the book because for last few years, I became more and more like my Chinese parents in my parenting style. I also remember that as a kid, I vowed that I would NEVER do what my parents did to me when I was a kid. However, patterns have a way of repeating itself. Along came, Amy Chua, an accomplished person set out to raise accomplished children. I wondered for the longest time, torn between, wanting to read this for parenting tips or disavowing it because I don't want to be a Tiger Dad. But the simple truth is that we naturally repeat the patterns that we have been given, unless a vast and conscious effort is applied to CHANGE. I thought, I must read this book to see how can "Chinese parenting" really succeed or if not, how can I become my own change agent to become a better parent.

In order to change, a goal must be clearly defined. Until I can clearly articulate the type of parent that I want to be, I can't succeed. I admired Amy Chua because she was unapologetically clear about what kind of parent she wanted to be. It's easy to criticize, but I haven't met any parent who is as clear about their style or purpose as Ms Chua. All the parents I have met say ambiguous things like "Just teach them right and wrong", "I just want them to be happy", or "I just want them to be a good (productive, honest, hard working, etc) person". For right or for wrong, Ms Chua was clear in her goals, purposes, objectives and she did everything in her power to move that way. When the battle was lost, she had the grace to retreat.

I don't feel that I got any useful parenting tips or deep insights about what kind of parent that I want to be. In the end, I realized that, selfishly, my happiness is as important is my children's. My happiness would be enjoying my time with them but also seeing them grow up and be more successful and happier than me. The "Chinese way" seems to dictate these are opposing roads, parents must pick one or the other, and that the end justifies the means. After reading the book, I confirms that I must search for my own middle road. Beyond the taskmaster of the Chinese parenting, beyond the positive hopefulness of the American parenting. Somehow, I will blend these two seemingly opposite paradigms. 

Ms Chua admitted as much at the end of the book, for her, these are two opposing paradigm. I still holding out of the hope there is a path where I can be loving, affirming, disciplining, taskmaster, and drill sergeant that can inspire and prepare my children to have chances for the best possible future outcome.