Weighing 12 Balls (Brain Teaser + Solution)

All the solutions to this I found online were either unnecessarily wordy or confusing due to formatting/syntactical issues. So, I'm adding mine which I will try to keep short and clear. 

The Problem: You are given 12 balls. All of them are identical except one, which is either heavier or lighter than the rest. You are given a simple two-arm balance scale, which you can only use three times. How do you identify the odd ball, and whether it is lighter or heavier?

Solution: Divide balls into three equal groups (A,B,C) and number them (1-4) in each group. 

Step 1. Weigh Group A against Group B:

  • They balance => Odd ball is in Group C
    Step 2. Weigh [C1, C2, C3] against any three normal balls (from groups A or B since they don't contain the odd ball).
    • They balance => C4 is odd
      Step 3. Weigh C4 against any other ball  to see if it is lighter or heavier.
    • [C1, C2, C3] heavier => One of [C1, C2, C3] is heavier
      Step 3. Weigh C1 against C2. The heavier one is the odd ball, otherwise C3 is heavier. 
    • Normal balls heavier => One of [C1, C2, C3] is lighter
      Step 3. Weigh C1 against C2. The lighter one is the odd ball, otherwise C3 is lighter. 
  • Group A heavier => Either Group A contains a heavier ball or Group B has a lighter one
    Step 2. Replace [B1, B2, B3] with three normal balls (let's say [C1,C2,C3] and swap A4 with B4. In other words, weigh [A1, A2, A3, B4] against [C1, C2, C3, A4].
    • They balance => One of the removed balls [B1, B2, B3] was lighter
      Step 3. Weigh B1 against B2. The lighter one is the odd ball, otherwise B3 is lighter. 
    • [A1, A2, A3, B4] heavier => (Odd ball hasn't moved.) One of [A1, A2, A3] is heavier
      Step 3. Weigh A1 against A2. The heavier one is the odd ball, otherwise A3 is heavier. 
    • [C1, C2, C3, A4] heavier => (The odd ball has switched sides.) Either A4 is heavier or B4 is lighter. 
      Step 3. Weighing one of them against a normal ball should tell you which is the case.
  • Group B heavier => This case is the same as Group A being heavier, just swap the A/B labels. 

 

Backlight Timer for Corsair Keyboards

Program and source can be found here.

I've been using a Corsair K95 as my daily driver for a couple of months now, and one thing that has always bothered me was the fact that there is no way to configure the backlight to automatically turn off or dim after a period of inactivity. Manually doing it requires you to press the backlight brightness key four times to cycle through all the brightness levels, not to mention the fact that you have to remember to do it when you leave your computer. Perhaps it's just me, but I find that to be too much of a mental burden. 

  Bundled software: Corsair provides backlight brightness adjustment controls here, but it doesn't do anything that the button on the keyboard can't already do.

Bundled software: Corsair provides backlight brightness adjustment controls here, but it doesn't do anything that the button on the keyboard can't already do.

So having finally gotten tired of pressing that button, I decided to see if I could devise my own solution. Long story short, it was trivially simple given what was already implemented in the keyboard driver. This however, raises the question as to why no such feature is present in Corsair's own software. Surely, someone at Corsair would have thought to implement such a seemingly ubiquitous feature on a keyboard that's clearly designed to be feature-abundant?!? 

Anyways, they must have their reasons and I'm probably just ranting at this point because I'm annoyed that I didn't do such a simple thing sooner.

Wireless Das Keyboard Modification - Build log

As someone with an affinity for both wireless devices and mechanical keyboards, I am saddened that wireless mechanical keyboards are few and far between. Only a handful of models exist, and unfortunately none of them quite fit my tastes. For this reason, I decided to go with a DIY approach. I figured since I had already voided the warranty on my Das a while back (with the vinyl wrap), I'd just go all the way and make the thing wireless.

This build log can serve as a guide for doing wireless mods in general. The process should be the same for most keyboards.

Phase 0: Planning

After a bit of research, I decided upon a method that is essentially replacing the internals of the mechanical board with that of a wireless one. The mechanical switches would be wired to replicate the membrane matrix of the wireless board, and connected to the wireless board's controller. This seemed like a straightforward, reliable, and cost efficient approach.

Being my first attempt at this, I decided to go for the least expensive board I could find. I ended up choosing a HP K2500 to be the donor keyboard since it had the same (104-key) layout as the Das and minimal amount of additional features. The small USB dongle was also nice.

 The donor keyboard - HP K2500

The donor keyboard - HP K2500

 Final shot of the Das before the transformation.

Final shot of the Das before the transformation.

 

Phase 1: Dismantling

Not much to say about the wireless board, everything came apart after removing the screws. 

 K2500 disassembled

K2500 disassembled

Things get a bit complicated with the Das, since all switches had to be de-soldered in order to separate the PCB.

 Underside of the Das' circuit board; K2500 matrix and controller can also be seen

Underside of the Das' circuit board; K2500 matrix and controller can also be seen

There are other ways to isolate the switches from each other, such as scratching out all the connections, which may be more practical on other keyboards. I opted to remove the whole PCB just to be safe. Doing so would also leave me with a functional keyboard controller and PCB in case I ever need it in the future.

 PCB separated

PCB separated

At this point with the PCB off, I noticed that the switches were a bit loose with only the backplate holding them, so I went ahead and secured them with some hot glue. In hindsight, I should have done this after the wiring, as then I could have also glued down the wires at the same time and do everything in one pass. Also, the glue would not have gotten in the way as it did occasionally during the wiring.

 Keys glued in place

Keys glued in place

 

Phase 2: Wiring

Wiring all the switches will easily take up the bulk of the modification process and will depend heavily on one's soldering proficiency. The general procedure I used goes as follows:

For each of the 26 pins on the controller:
{

  • Trace its path on the membrane and make note of all the keys it runs through.
  • Mark the corresponding switches on the mechanical board, and wire them together.

}

 Mapping one continuous run of keys from the wireless membrane to the mechanical switches using red inspection arrows

Mapping one continuous run of keys from the wireless membrane to the mechanical switches using red inspection arrows

Some useful advice for this process:

  • The connection paths on the membrane are often unnecessarily long and winding in order for them not to cross each other. The switches do not have to be wired in any particular pattern, as long as they are all connected.
  • Using a different color of wire for each run will make things easier on the eyes. Either way, double and triple-check before and after soldering.
  • Depending on the keyboard, the space behind the backplate may be tight, it is best to keep the wiring as neat as possible. Thinner wire also helps.
  • Being consistent also goes a long way in keeping the wiring neat. One thing I did was wire all the runs from the top membrane to the thicker pin on each switch (and vice versa).
 All wired!

All wired!

 Close up on controller

Close up on controller

After soldering everything, I hooked up the batteries and did a quick test to see if everything was wired correctly. Once I made sure every key worked as it should, I went ahead with the final assembly.

 

Phase 3: Assembling

Firstly, I did a quick fit to make sure there was room for everything inside the case and finalize the placement of the internals. 

 Testing the fit

Testing the fit

As you can see, everything fit nicely (and with ample room to spare thanks to the Das Keyboard's signature "hump").

Now came the matter of securing the controller and batteries in place. I had originally planned to 3d-print some sort of custom bracket structure. However, since I didn't have access to a printer at the time, I turned to some good ol' improvisational ingenuity...

 The raw materials...

The raw materials...

After scavenging around the house, I settled with two plastic clips that held a pen in its packaging and a cap for the end of a DVI cable. Together, they made a crude but effective battery compartment.

 ...for when you don't have a battery pack.

...for when you don't have a battery pack.

Next, I took an old graphics card cooler that was lying around and cut out a rectangular chunk of plastic. I glued this to the backplate so that it would press down on the controller and secure it in place.

 This area of the cooler here...

This area of the cooler here...

 ...ended up here.

...ended up here.

Finally, I wanted to do something to address the empty slots originally used for the USB passthroughs, as well as the hole at the top where the cable once was. 

 Bits of plastic also cut from the cooler

Bits of plastic also cut from the cooler

Noticing that the plastic from the graphics card cooler was similar enough, I carefully cut out and sanded these pieces to fill the gaps. They actually turned out better than I was expecting since the color and and texture was a near-match. 

  I was quite happy with this until I managed to get glue all over the edge as you can see here. I ended up sanding it down which meant losing the textured finish on the plastic. (Oh well.)

I was quite happy with this until I managed to get glue all over the edge as you can see here. I ended up sanding it down which meant losing the textured finish on the plastic. (Oh well.)

  All done! :D

All done! :D

Final thoughts:

Overall, everything went smoother than I had anticipated. (I think software development has conditioned me to expect roadblocks.) The most challenging aspect of the entire process would be the soldering, since I had limited experience with that. 

For anyone looking for a list of tools and materials used, here is a rough overview of the stuff required since I didn't include an explicit list anywhere:

  • Soldering kit (soldering iron, solder, solder removal tool/wick, wire stripper, tweezers)
  • Lots of wire (I believe I used 30 AWG)
  • Whatever else required to do the job (glue, tape, power tools, etc)

That's it for the build log. I probably could have taken more pictures along the way, but hopefully my explanations are clear enough for most parts.

Some additional pics of the keyboard are here.

Achievement Unlocked: Start a blog


What you see before you is the end-result of a recent splurge in my productivity. Lately I've going through what I can best describe as a "late-adolescence crisis", as it seems to be some combination of adolescent restlessness and existentialism. Either way, a personal website has been on my to-do list for years now. But only in the past few weeks however, has my desire to accomplish anything been powerful enough to actually get off reddit and start being productive. 

In terms of content, I'm still unsure about the various musing I'll be sharing. Hopefully ideas will come to me naturally at a rate that will justify this blog's existence. Until I decide on the tone and level of wisdom carried by my posts, expect anything between guides to rocket surgery, and funny cat pictures.

That's it for now.