Skyline in Processing

Click the image to view the animation.

skyline

Click here to see the code (long and not documented).

Arduino

Over the weekend, I was introduced to Arduino, an “open-source electronics prototyping platform”.

2013-05-12 14.06.28

I have sincerely disliked dealing with hardware in the past, but the Arduino is surprisingly easy to use. People have created some amazing projects with Arduino. The most impressive one that I’ve seen so far is Pinokio. A description can’t do it justice.

As for me, my first project was a Simon game: a sequence of lights is randomly generated, and the player has to repeat the sequence. After every correct repetition, the light sequence is extended by one, and the game repeats until the player gets the sequence wrong.

The kit I used only came with two colors of LEDs, and I only used three of them whereas the original commercial Simon had four. This took me about an hour and a half to assemble and code and then maybe another hour to debug and refine:

I’ve Been Waiting for This

I stumbled upon MathJax today and couldn’t be happier! It’s a “JavaScript display engine” for math. It takes LaTeX code embedded in HTML and formats it. Here’s the quadratic formula:

\[\begin{aligned} x = \frac{-b \pm \sqrt{b^2-4ac}}{2a} \end{aligned} \]

Here’s the probability density function for the standard normal distribution:

\[\begin{aligned} P(x) = \frac{1}{2 \pi} e^{\frac{-x^2}{2}} \end{aligned} \]

And here’s Euler’s identity, \(e^{i \pi} + 1 = 0\), formatted in the flow of normal text.

Beautiful!

π day

This past holiday season, I received a very thoughtful gift: π cufflinks!

Photo Mar 13, 7 33 51 AM

Today, I brought in four pies for students to consume after they had finished their exams. At one point, we had approximately π pies!

Photo Mar 14, 10 41 52 AM

Speedcubing

Ever since I learned how to solve a Rubik’s cube, I have wanted to do it as fast as possible, but it has only been within the past few months that I had a tangible goal: being able to consistently solve a scrambled cube in 30 seconds or less.

A quick search will reveal that this is not very fast in the context of the most competitive speedcubers. In fact, the world record is 5.66 seconds. But for me as a hobbyist, this is plenty fast and plenty challenging.

If you have never been exposed to the subculture of speedcubing, then here’s a brief outline of the parameters of the challenge:

  1. A solved cube is scrambled, usually using a sequence of moves randomly generated by a script (I use csTimer).
  2. You have up to 15 seconds to inspect the cube and plan out initial turns.
  3. You start the timer when you’re ready to begin solving and before the 15 seconds of inspection is over; you stop the timer when you recognize that the cube has been solved.
  4. A trimmed mean of the times of either five or twelve solves is used as the measure of your true speed.

The method I use to solve the cube is called CFOP. Each letter of the acronym stands for one of four steps in the solution process. In short, CFOP solves the cube from the bottom layer up. As you move up the cube, you execute different algorithms that move pieces into their correct positions while maintaining the solved state of the lower layers. Here is a sample solve, which I was able to complete in 24.82 seconds.

The CFOP method leads to solutions that require around 50 to 60 quarter or half-turns of the cube. However, you’ll notice from the video that I spend nearly one-third to one-half of the time not turning any layers at all! Instead, I am trying to discern the current state of the cube and visualize what I have to do.

Currently, my best single solve is 21.94 seconds; my best average of five is 28.52 seconds; and my best average of twelve is 30.59 seconds.

Around the Unit Circle

gwclogo

Through my school’s participation with Girls Who Code, my students and I have been exposed to programming with ProcessingJS.

When I consider new technologies for use in teaching, I usually judge them on three criteria:

  • Is it visual?
  • Does it offer instant and informative feedback?
  • Can a student do something cool after a few lessons?

Khan Academy’s interface for ProcessingJS answers “yes” to all three questions, and I’m quite excited to see how it can be used. The language is fairly easy to learn for beginners (and very intuitive for those who already know either Java, JavaScript, or Processing), and code can be run and updated on the fly.

Here’s my own first program: a visualization of angles in standard position and the unit circle.

Around the Unit Circle

Made using: Khan Academy Computer Science.

Playing with Pentominoes

Inspired by this article by George Hart, I pulled the 12 pentominoes from my copy of Blokus and tried to make a 6 by 10 rectangle out of them.

pentomino1

This was a lot more difficult than I had originally thought. I gave myself quite the headache.

pentomino2

And that’s only one of 2,339 different solutions!

The fact that the Blokus pieces fit together so well added to my frustration because I would lose track of which pieces I had already used. When I was done, I decided to use the other colors to make the solution easier to see. Of course, I had the desire to make sure that no two adjacent pieces were of the same color. Since there are four colors to use, this was not a problem (thanks graph theory!).

pentomino3

Next challenge? Making a rectangle out of all the Blokus pieces?

Complex KenKens

complex_kenken

The article Triangular Numbers, Gaussian Integers, and KenKen by John Watkins includes three KenKen puzzles at the end that use Gaussian integers. Instead of completing this 4×4 puzzle with the numbers 1, 2, 3, and 4, we have to use 1, 1+i, 1-i, and 2 instead!

A 6×6 KenKen uses 1+2i and 1-2i in addition to those four complex numbers. This brings up an interesting question: why these 6 complex numbers? I’m fairly sure complex numbers do not have a natural ordering.

Solving a 4x4x4 Rubik’s Cube

Just after the New Year, I bought a 4x4x4 Rubik’s Cube.

2013-02-07 22.12.13

Learning to solve it was quite simple: one popular method of solving the 4×4 is to first reduce it to a 3×3. A classic strategy of mathematical problem solving! The pieces of the 4×4 are grouped in such a way that the groups are isomorphic to a scrambled 3×3. For example, these two cubes can be viewed as identical:

2013-02-07 22.20.24