Postmodern Sysadmin

A blog about servers and junk

Decoding Balanced Payments Puzzle 1

A strange string appeared at the bottom of a Balanced Payments blog post:


One of those puzzles to attract coders I guess. The guys at Hacker News spilled the beans, so lets spill them some more.

First though,** Mad Props** to the Balanced team for thinking “outside” the unit-test-box. Plus Jenkins rocks. The world needs more Jenkins. 


I’m not a developer, so my first instinct was to use the existing set of tools that people have already written to solve this puzzle:

curl -s \
| html2text | grep -P '[^.*]=$' | head -n 1 | base64 -d \
| sed 's/../0x& /g' | xxd -r -c 100 | rev

I love the command line.


The Balanced guys look like they are Python people. That’s cool. BeautifulSoup is the only Python html parser I’ve used:

import urllib2
import BeautifulSoup
import re, base64
content = urllib2.urlopen('').read()
soup = BeautifulSoup.BeautifulSoup(content)
# Last pre has the base64 string
string = soup.findAll('pre')[-1].getText()
print base64.b64decode(string).decode('hex')[::-1]


Hpricot is the only Ruby html parser I’ve used. Also, I love_ .map_:

require 'hpricot'
require 'open-uri'
require 'base64'
thehtml = open('') { |f| Hpricot(f) }
string ="//pre")[1].to_plain_text
puts Base64.decode64(string).scan(/../).map {|a| a.to_i(16).chr}.join.reverse


Solving puzzles is a fun way to learn new things! If you are hungry for more excuses to learn how to use languages, check out Project Euler.