Peg Solitaire: My New Mini Game Jan 08
Post a comment
Over the holidays I created a new game, Peg Solitaire. Click on the link to go play!
Over the holidays I created a new game, Peg Solitaire. Click on the link to go play!
Everybody loves palindromes, right? I do, at least. That's why I was excited when I learned that every number can be a palindrome when it's written in the appropriate base. There is a trivial proof for this property: any number N > 3 is a palindrome in base N-1 because it may be written "11". So here is my solution, in Haskell, to this CodeChef problem, that finds the smallest base that makes any given number a palindrome.
isPalindromeInBase :: Integer -> Integer -> Bool isPalindromeInBase value base = step leftmost 1 where leftmost = base ^ floor(log(fromInteger value) / log(fromInteger base)) step left right | left <= right = True | digit left == digit right = step (left `div` base) (right * base) | otherwise = False digit position = (value `div` position) `mod` base smallestPalindromeBase :: Integer -> Integer smallestPalindromeBase 1 = 2 smallestPalindromeBase 2 = 3 smallestPalindromeBase value = step 2 where step base | base >= value || isPalindromeInBase value base = base | otherwise = step (base + 1) main = interact (unlines . map (show . smallestPalindromeBase . read) . tail . lines)
This is certainly not the fastest solution possible. Indeed it is downright naive. But hopefully the logic is clear.
I released Fishing Girl just under a month ago and yesterday I broke 5000 sales. Thank you, everyone, for your support! For me, knowing so many people are having fun with my game is the ultimate reward.
I'm also very happy that Fishing Girl was so well received by the gaming press. I've been collecting reviews of the game and I've linked them all below, in vaguely chronolgical order.
Fishing Girl has also appeared elsewhere on the web and I've collected some of those links, too. This certainly isn't an exhaustive collection but it highlights some of the more interesting references I've stumbled on.
Any more Fishing Girl sightings you'd like to point out? Let me know in the comments!
I recently made the transition from running my web server on Apache to running it on Nginx. Well, I made the switch at the start of the summer, but only now is my Nginx configuration stable. One of the biggest obstacles I encountered trying to get Nginx to do what I want was a lack of documentation. The official documentation is anemic and I found examples hard to come by. So now I'd like to share parts of my nginx.conf file that cover some common use cases that I found frustrating to implement.
I would like all of the URLs for ericw.ca to be without the "www." prefix. Indeed, that is their canonical form. This configuration snippet uses the 301 Moved Permanently status to redirect users arriving at "www.ericw.ca" to "ericw.ca".
server { server_name www.ericw.ca; rewrite ^(.*) http://ericw.ca$1 permanent; } server { server_name ericw.ca; # The rest of the configuration... }
You can see this in action if you go to www.ericw.ca.