Concentration – Randomly Picking

I spent my entire Friday night mucking around in C++ because I think I saw people in an anime playing Concentration and I wondered, how long would it take you if you went full YOLO and picked cards at completely random? Also I can’t do the math to figure it out.

I think the anime was One Week Friends, but it’s 2 in the morning right now.

It took me 2 days to figure out VS2013.

It took me 2 days to figure out VS2013.

The conditions were as follows:

  • A grid with an even number of total spaces is laid out; maximum 8×8 on this toaster of a Thinkpad
  • The number of copies of a symbol is set to 2, and the number of symbols is half of the total spaces
  • The cards are distributed randomly across the grid
  • Two cards are drawn at random; if they match, those cards are discarded, counters are incremented, and the player picks again; if not, the cards stay on the grid
  • A single card deal is played 1000 times with no knowledge of prior games (read: RNG gods)
  • It is assumed it would take approximately 4 seconds per turn for a human to play in this way

I loved these games as a kid.

I played grids in even increments from 4×4 to 8×8. I tried to do 1 million trials per game, but Windows just gave up and crashed the program every time. The results are shown below:

I wasted waaaay more time than that on this.

Boy, that escalated quickly.


Looks exponential to me. Mission accomplished.

I really think this would’ve been loads easier in Python, but I don’t have that set up on this Windows machine right now. My next steps are to try various algorithms to see how much faster they are. Or really, whatever I figure out how to code past midnight.

UPDATE: My friend Mike, who actually knows statistics, showed me that the expected number of moves to match n symbols at random is n^2. This lines up perfectly with the data for large numbers of moves. Thanks Mike! 

Clothing math

I like to shop at stores such as Winners, Marshalls, or TJ Maxx, where they sell mostly assorted surplus brand-name clothing for huge discounts. Aside, these garments would then be at a reasonable price for what you get. But it’s always really fun to go hunting in a store and finding just the right garment in just the right size at just the right price that just happens to be in the store at that time.

Well, the rest of it is uninteresting or doesn’t fit you.

Sometime last fall, I bought the following items for about $170 with tax:

  • 2 short-sleeved button shirts, let’s call them “O
  • 2 T-shirts, let’s call them “T
  • 2 shorts, let’s call them “B

Being super stylish, I can wear them in the following combinations:

  • A T-shirt and a shorts (T, B)
  • A button shirt and shorts (O, B)
  • A button shirt, a T-shirt underneath, and shorts (O, T, B)

Unfortunately I don’t have the body aesthetics (read: muscles) to go with just a pair of shorts, and just wearing a shirt and no shorts would be a fast way to have a date with a cop.

I talked to my friend and housemate, who was doing actuarial science and a bunch of probability courses at the time, to figure out how much of a deal I really got, in terms of utility per unit cost. I wanted to find out how much I increased my wardrobe and potential outfits by with my purchase. We do this by simply adding the total possible combinations from each of the three cases.

A. T x B = 4

B. O x B = 4

C. O x T x B = 8

D. Total = 4 + 4 + 8 = 16

So basically I got 16 (mostly) unique outfits for the price of $170. That’s $10.65 per outfit! I gave myself a pat on the back, had a beer, and played video games. Mission accomplished.

Well, one of the shorts was kinda too big around the waist and I ended up not wearing it as much. I swear my belt held it up when I tried it in store…

First gaming computer build

My younger brother is your typical 13-year old boy who likes to play video games (read: a lot). Up until now, he’s been making do with an 8-year old Dell desktop which, until recently, did not even have a discrete graphics card; he’s been playing Call of Duty, Rome: Total War, and other games which definitely outstrip the Dell’s capabilities.

Given that desktop computers are collections of parts which you can mostly upgrade or replace one at a time (taking into account compatibility), I thought to build him something on a reasonable budget that can play his games on relatively high settings while showing him how computers work and how he can upgrade or change it over the years into university. Because hell if I’m buying him another computer for college, that’s my San Franci… tuition budget. Yeah.

We went with the following outline:

  • i5-4670, $239
  • ASUS Z87-A motherboard, $170
  • Corsair Vengeance 2×4 GB RAM, 1600 MHz
  • 128 GB SSD, $100-ish at Canada Computers
  • 1 TB HDD, $65-ish at CC
  • Gigabyte GV-N660OC-2GD graphics card for the NVIDIA GTX 660, $219 (HUEG fans, see below)
  • 850 W power supply at the store, $130-ish
  • Rosewill Challenger mid-size case, comes with 3 fans (one with blue LED), $55
  • Windows 7 Home Premium, $100

With some price matching and substituting of components which I don’t remember, the total came to about $1250 after tax.

I just wanted to take a moment to show a picture of the graphics card. It’s HUEG.

Can be used to exert lift forces on the case when relocating it.

“This is your captain speaking, welcome aboard flight GBN660…”

I chose it because of the huge fans and what we learned in heat transfer: forced air convection is awesome and the bigger the exposed surface area, the more heat is transferred away. Add in the exposed heatsinks and you’ve got one cold card. If there’s one thing I got out of that hated course, it’s that fans + fins = freezing.

Assembling it was real fun (read: scary as hell). Clamping my anti-static wrist strap to the bare metal of the ventilation duct in the floor, I fumbled around with some screwdrivers and managed to get things into place. It didn’t help that I forgot the I/O shield plate for the back of the computer, and had to reseat the motherboard, nor did it help that the I/O shield was weirdly designed and had these prongs sticking out of them making it ten times more difficult to assemble. If these prongs actually fulfill some useful function, someone please tell me.

My legs really hurt after kneeling on the floor for so long.

Loading the power supply into the case. Me in green pajamas on the left.

Finally, after about two hours of fumbling, fiddling, and touching bare metal objects, it started up just fine! Due to its quiet nature despite its 3 fans, and its blazing speed tucked into a steel case, I called it the STARPLATINUM after Jotaro Josuke’s Stand in Jojo’s Bizarre Adventure Part 3.

This is the most powerful computer in the house.


The case’s fans whirred quietly as the computer downloaded updates and restarted repeatedly; initial boot times were about 30 seconds from pressing the switch to moving the mouse on the desktop. Core temperatures were stable at around mid 30 degrees Celsius; when idle under no load, it can dip even into the 20’s.

This thing now runs my brother’s games off Steam at the highest settings with little drop in framerate or performance; the old monitor he’s using can refresh at up to 75 Hz, which this thing seems to handle just fine. It almost makes me want to ditch my currently-dead W530 Thinkpad and just build a better computer for cheaper!

The build was completed shortly before I returned to school for the summer, so that would’ve been around May 4.

Laser-engraved keychains

Here are some keychains I made for my last employer. I ordered dog tag blanks anodized in red off the internet, went to a TechShop, made a jig to hold 20 of them, and laser-engraved the company logo on them. There were several variants, but this is my favorite:


Front side, company logo


Backside with Athos company text


Another variant with the logo inside a circle is shown below.


Circular logo

I left the instructions for making more with the next intern. Everyone at the office seemed to like them!

New one-handed sword design

When designing SWAG-0002, I couldn’t decide whether it should be held with one or two hands. In the end, I compromised and made the handle one-and-a-half hands long. That’s where this next shape comes in.


One-handed sword minus cutouts and hole pattern

The sheet metal outline currently weighs about 0.65 lbs if made out of 1/8″ aluminum, which is about half that of the larger SWAG-0002. I will next put cutouts to make it look cooler, and a hole pattern so two pieces can be bolted together for greater bending resistance (read: moment of area).

Updates to SWAG-0002

So as you may have seen in my first post, or I may have blabbed to you about it, but I’m designing a sword: the SWAG-0002 “Flugel”. (I took German 101 and someone from Germany told me my German was great, so I think I can get away with this)

It’ll be made of two pieces of sheet metal for the blades, some washers for spacing inbetween, and some handle pieces that go around them. Previously there were two symmetrical handle pieces made from round metal stock, but there are compression issues.

Previously there would be three points of contact: the two outer edges of the handles, and the cutouts where the tangs would sit and be fastened through. The handle pieces would either come in contact at their outer edges and not properly secure themselves to the blades, or they grip the tang and have a small gap between them at the outer edges (which could hurt the hand). Using something like adhesive foam would not be practical as the assembly may be taken apart and reassembled repeatedly.

I redesigned the handle to both change the spacing inbetween the blades to 1/16″ instead of relying on SolidWorks’ SmartFastener dimensions, and to be made from rectangular blanks instead of large round stock. This should make the handle pieces easily CNC/hand millable, and maybe easier to 3D prototype.

The next design for the handle is two rectangular pieces that are screwed together to hold the two blades and a middle piece that acts as a spacer and a cover for the exposed areas of the handle. This results in an entirely rectangular handle, but this can be sanded down to be more rounded later.


Handle grip


Handle cover and middle piece


swag-0002_B exploded

Exploded view


The assembly should now look like this:


SWAG-0002, rev B