Blackjack in jQuery

Just a quick post, here’s a version of Blackjack I made using jQuery, HTML, and JavaScript. Codecademy helped me a lot when I started learning JavaScript and jQuery. In the later lessons when the programming challenges get more complicated, their solution verifier gets a bit finicky. But, if you’re just starting from the beginning it’s a great resource. Now . . .
Play Blackjack!

Conway’s Game of Life in Processing.js

I first learned about Processing at Maker Faire in 2011. I don’t consider myself a visual artist, but Processing made it straightforward to create beautiful graphics using code. However, I didn’t want to go through the hassle of working with the Processing IDE, so I set it aside for a couple years.

Recently, I came across Processing.js and decided to give it another shot. By porting it to JavaScript, the developers have made it easier to get started and publish to the web (though I would guess that the JavaScript version runs slower than native Processing). All I needed was a project.

Continue reading

Approximating Pi in Python, Part 1

Consider a square with an inscribed circle of radius r which itself has an inscribed square rotated 45 degrees. square inside circle inside squareIf we look at just the first quadrant, then the area of the outermost square Aouter is r2. The area of the circle Acircle is πr2/4, and the area of the inner triangle Atriangle is r2/2. Therefore, we can make two equations for π based on the ratios of these areas: π = 4Acircle/Aouter and π = 2Acircle/Atriangle. Notice how neither equation depends on the radius; so, if we can figure out an alternate way to calculate these areas, we can determine the value of π. Python to the rescue!
Continue reading