david.segonds.org Chronicles of an Agile Software Development Manager

27Nov/090

Programming Puzzle

Tonight, I found a programming puzzle while reading the blog "It's common sense, stupid". I solved the puzzle, but I don't know what to do next. Do you know what I am supposed to do once the puzzle is solved?

Here is the puzzle for your enjoyment:

                      ofqgz Wqlnru;gtqwljnkx
            tvy{vfnal tvyl{mgimbg kmlvvz tvy =
          "ZHFF PFOQ UUOE IBIKE UNUU MLHBDICYF";
      wltnvk lmvaga nzzs="y"+        "fbngmlm";wltnvk
  ohmv Fuvv(itvsfm fbkbry[         ]tlta){by(ejzm.Ymgzxz
==0)Fuvv(tkk,skam);meli            {ay(ueol[0]=="")kilnla
;qy(tvyl[1]=="")ueol[               1]=tvys;pnz tkkm=tlta[
   0][0];otv skat=65;qgm            ejzj=nzzn-ejza;  vvm
    tvylm=nzzl[1][0]-97;          mx(Vbnz.BlPwmnrz(tkkm
    ))tltx=(tkkh-tltal+26)    %26;Vsfliym.Pkmlx((wuik
        )(tvyi+ueoz));Feag(ueol[0].Lytlneqgz(1),
             ejzm[1].Fculxjbht(1));}}}}

The solution to the puzzle is the following C# program. The puzzle is a simple cryptogram where the jey is 'unittest'.

using System;
namespace arg
{
    class args
    {
        static string arg = "GNSX WMKY BABW PIESL AAMB THPIJVUFM";
        static string argz = "u" + "nittest";
        static void Main(params string[] args)
        {
            if (args.Length == 0) Main(arg, argz);
            else
            {
                if (args[0] == "") return;
                if (args[1] == "") args[1] = argz;
                var argu = args[0][0];
                var argg = 65;
                int argp = argu - argg;
                int argss = args[1][0] - 97;
                if (Char.IsLetter(argu)) argp = (argp - argss + 26) % 26;
                Console.Write((char)(argp + argg));
                Main(args[0].Substring(1),args[1].Substring(1));
            }
        }
    }
}

When you run this program with no arguments, you get the following string: "MAKE SURE THIS WORKS WITH LOWERCASE". Ironically, the program does not process strings contains lowercase.

I used cryptanalysis and a bit of python script to solve the puzzle. This was entertaining.

  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • Digg
  • Twitter

No related posts.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.