Statistics

Problem Statement for "SimpleRotationDecoder"

Problem Statement

An encryption algorithm is applied on a piece of original text containing only lowercase letters ('a'-'z') and spaces. The original text contains no leading or trailing spaces, and no consecutive spaces. A word is defined as a maximal consecutive sequence of letters. Each word in the original text is between 2 and 8 characters long, inclusive, and contains at least one vowel ('a', 'e', 'i', 'o' or 'u').

The encryption algorithm works as follows. Spaces and lowercase letters all have corresponding numeric values. The number 0 corresponds to a space, and the numbers 1 through 26 correspond to the letters 'a' through 'z', respectively.

First, a password is chosen. The password is a non-empty sequence of lowercase letters ('a'-'z'). Take the first character of the original text and the first character of the password, and add their numeric values together. This sum, modulo 27, corresponds to the first character of the encrypted text. For example, if the first character of the text is 'x', and the first character of the password is 'd', then the first character of the encrypted text will be 'a' ('x' + 'd' = 24 + 4 = 28, 28 mod 27 = 1 = 'a').

Perform the same transformation using the second character of the original text and the second character of the password, and so on. When you run out of letters in the password, cycle back to the first letter of the password.

For example, let's encrypt the text "hello world" with the password "pun":
hello world
punpunpunpu
-----------
xzzainlieay

The encrypted text is "xzzainlieay".

Given the encrypted text as a String cipherText, you must determine the original text without knowing the password. Thanks to frequency analysis, you know that the password contains exactly 3 letters. Return the original text that satisfies the requirements given above. It is guaranteed that a single unique solution exists. All quotes in the problem statement are for clarity only.

Definition

Class:
SimpleRotationDecoder
Method:
decode
Parameters:
String
Returns:
String
Method signature:
String decode(String cipherText)
(be sure your method is public)

Notes

  • The password does not contain spaces.
  • The password is not required to contain vowels.

Constraints

  • cipherText will contain between 3 and 50 characters, inclusive.
  • cipherText will contain only spaces (' ') and lowercase letters ('a'-'z').
  • There will be exactly one correct solution.

Examples

  1. "mmbtvrbhhtgohaktklqegnrmlelojotyeyeiudvtil ey ffg"

    Returns: "the quick brown fox jumps over the lazy dog again"

    This text was encrypted with the password "tex".

  2. "ntgntgntgntofwlfwlfwlnookookook"

    Returns: "he he he heh he he heh he he he"

  3. "cchhapdfwjvqyyvawoewktieltwtnhbamvilf"

    Returns: "bulgstcx imuxpz nsdnos ikk selasqu pe"

  4. "vvzekpufbclfcuoeoacznmtnzxuttray"

    Returns: "abkkra mnisria kvmifzs zedfz cge"

  5. "ujy cqibtvbztscwzhhgogjoimok"

    Returns: "nretkxbj ojfm jpgoaov rvbuvd"

  6. "hlkabhgyeehznvqjksehhwwmr ngqus pfzdao"

    Returns: "adguud qay vgnmccoy dpoiksj iqlslzr ug"

  7. "jmtdstwzlewgmyfahqqmgkrqrkxjljxsv"

    Returns: "namhgm neik qmzewjua ofjvzqn cago"

  8. "picoywoyegyzeazkqqrzjqshpjx"

    Returns: "eqydfrdf wfuuiu ylggef cers"

  9. "d nxxnjqnqrfvudhmhkglppohgu ic"

    Returns: "wjupgub uiamndk wocqshzv qassj"

  10. "wzhsyylzatw aolnf afdvawhtqu"

    Returns: "ptglsxet mqzuikg zu covvanpn"

  11. "ztnshzd po gzrztdgelecevevxsbpqbow"

    Returns: "vygoms eike vwspi aqyzjoa qogimghs"

  12. "djbezahvzvmwmdvawptsvmhsxhssipxujwnli"

    Returns: "wagxqf mdndaev tnulj ezxpzxk uplooeqa"

  13. "ltekrwcodgwpfaksqabgxnfdjmuhpkiycnirr"

    Returns: "inuhll itdqecv pkqzamk tggjej fsskcgo"

  14. "ebtyhwbkcgdlmemgcfdbalrjds "

    Returns: "susl vpcbuwk xluveru zjirkz"

  15. "ikdxdcvqnr nqswipccxhulf jyww"

    Returns: "rzafs dek okzgtrd llec ciyvek"

  16. "nbjktgmlcuxxfna hdwxldwlrpeqavjgydsg"

    Returns: "xe uwxwotd npqrjkuf bnzbasv dltjonvx"

  17. "pwltcdtnysthxeygryshepfcegpeg"

    Returns: "xqhax ahu ndezuolu bax zmalma"

  18. "mobpg ly wiabr wmmrpdby"

    Returns: "vhay zurzeb kkzefl ickr"

  19. "ppmyuuahpbdaqugbikfeisthrcxzyeb"

    Returns: "owfxan oiakupa apdelbr aqjqyeya"

  20. "ywcqpktkdfbjipmydpkzouc etsuvygy o"

    Returns: "dlqweyz rlrxoe dtcqob snkif klmnnu"

  21. "tqenhrgxnpzopub tqoqdbkchhytnabdxe"

    Returns: "eiqz cspzar amnllb ipncot jefmnwiq"

  22. "a ljrpio pkkoj kpjtjiiujftj wk"

    Returns: "mlbvcfu qawa vqwa evzuf re lha"

  23. "jcuozrr xftpb g rivlowdpaxqpccimt"

    Returns: "ilxnhuqi ebsaijz luurvms ftolfhvw"

  24. "jqsxaf l akohhvlvgqhzgpoqmezbze"

    Returns: "kimyt adubcii pmnar thhirez utf"

  25. "okmwvaiw hjwmxhtjkkinm hlfaoehx"

    Returns: "ca kloxmnw janvh yzzaaqv wocvvl"

  26. "wbb kjno xy bweuvhogbstxvw"

    Returns: "ivxmde hvjrvop goca xemshp"

  27. "uyxggiadavjeiwepxekjgqikogyij"

    Returns: "epwryhlv fadtnd odvafa jzyxta"

  28. "syvxe fwbevyaidcdxhmmlpmhpmlm"

    Returns: "mirrpw gyzfuvt xotbxif ib ifx"

  29. "lbqxpbrverxcetczt ouiblznumasqn"

    Returns: "ghosv macmca zauzyj gxrxi kwyoi"

  30. "idohcama iflysdwi wkdea"

    Returns: "avc upesoax qjso oobsxs"

  31. "szxlhlmorsrwifapwyduhwwfjvmvefwh"

    Returns: "xcfqlurs xvenjju giyqa oozv ioal"

  32. "mukebkeaumfsohmqyktidmqdjvn"

    Returns: "ttslasl bte vguxxs hltplquv"

  33. "jvyezcccqjosuleffotpfrsycv"

    Returns: "egj koyobe dpxqar oarmdjyg"

  34. "xaakqkycvs rxecwxnlrsbunnb"

    Returns: "vdfitpwf qcwvhhu sjux xsle"

  35. "wxqgffifdw qxifgjsawwz jgyjlq"

    Returns: "xfkho joyxikyr hsmbeq idhgdmz"

  36. "hlr jodnmtumqvxlflrggbvsaaoyx"

    Returns: "dqtwoq sopzom zhknnliy uxfqub"

  37. "aimdwgrjpvhsxwhmwpbuplsgvdvluqnrf"

    Returns: "texwsrjf ndcpsses uq dorn fdqafnq"

  38. "wadhwijtvzgmibonnwowolzfyqfoyv"

    Returns: "kzvwu yrmnedx fblncuf xxmoxcwm"

  39. "kkpkjuxpgzbupliqmjgbojnr cag "

    Returns: "uxiuwngb ionzyb zcqoht kjpuqm"

  40. "rvlobcgwnpvmrxisrvrnvqhamgzbj"

    Returns: "zzkwfbo mxzlzah vuzruyl ukyjn"

  41. "arlozalpclprsouzeeznwhsgnbreeai"

    Returns: "tmiguydk dkokjrr brit ndfxox ya"

  42. "xklltstkyxgbigfhhohvzrerwtnh"

    Returns: "ormc tkrzonc ngzopzb ilsn oz"

  43. " pgyuikgegzjw tvrttuzxkhosplczf"

    Returns: "eebcjdpw loeapo goyjub cthkqsuk"

  44. "ldjhxsa gsninazzwtghcmyfkksc"

    Returns: "zhcvalod frbaesm mulw bzyolq"

  45. "uylkljteb sv yahpmwqkmdrlktmumciaz"

    Returns: "hijywhgp nctnizv kjai opzvr ekqtzm"

  46. "tvjlzbfjrpehppaxbuyrwnooqpdbj"

    Returns: "wgsokkiv sqqsaj ncaceq xtamev"

  47. "otgpwjhhwwbfunmdrqyglvtfhijrgs"

    Returns: "tluuoxm jautzf ijdczz ltmaxwzf"

  48. "ulwnjbczptibjpfroqlhqabrmivvmntusa"

    Returns: "zdusb hrnya ohdwgoq ofuprat elymqf"

  49. "kcemtei siqgg kibtfn wpatf"

    Returns: "oamqrmmy mookysm ajlh nixd"

  50. "udqujarnxhbxzodlhrjihyxvzxbza"

    Returns: "iqiiwtf pwopnaw ujyv mjnnjunn"

  51. "gjo qser dnbdaipeoiwajpcgkvug"

    Returns: "xiwqp vqhumju qfdwzvi okxjckf"

  52. "ckdnprsnyrmzfwuvbigkentpyr"

    Returns: "wofgttlr kqaz wofk oggxrrv"

  53. "thzwyvlsh vrwrtohdxrltzqtjjjid"

    Returns: "epihfex rlcahzc pnizveg ertvqn"

  54. "opmgiujhdfwwibksiiqiudjzmxkblgktdnzv"

    Returns: "mnseg hfjdubg qqgoog bhekvq jmirjlxa"

  55. "xktlgyrlttzxymovtkywprofxgdnsaj"

    Returns: "ddis nyei smefdbm epeyhvd tulqq"

  56. "fgjccdmefkyermftcjalpbwltbaiotprhe"

    Returns: "ve saubcw wvgkwia qjfrubi rymjepyu"

  57. "qslbzf npkjnvhhbhvrxevuuii"

    Returns: "vesglme wpwu uogubwjl ganv"

  58. "f sgnzslhzquq ydyuinmqiwfyrtdvn"

    Returns: "abkbprnn usmlbqz mdpelkoa jofni"

  59. "hgolbtmlfehhhuydhdj ypsyvsirxckwygc"

    Returns: "vtqzov yhsujvg rufxm ce iekejeyi up"

  60. "spdkkqgzgmhycynrmntglqqvlsjymn"

    Returns: "brnum qaqwjhm xaoxciv sevuthox"

  61. "wjmuwsmuywytytocktcwtugwyufopdt"

    Returns: "yzuwl ojfyna iwe aelawwd jnqelv"

  62. "wzutd qaknx skuqbi umnakycrlcgbcq"

    Returns: "kxjhbpez bvpgije yosbbz mag awqaf"

  63. "dhxoefmwhsceamioeosokmkjo gwleb "

    Returns: "pla ijy ldgimqm isdsoyon dkhpind"

  64. "ucdfacljfurdgzewtko kugxjucfrp"

    Returns: "iwzuuy caikzvs kmfctfi synyukk"

  65. "fxnwexeiohbwhymd fuielkvvlqzyn"

    Returns: "goaxwkf bitjip ertv smbiwcd pa"

  66. "qpl exewnoyaioexneegfapormj"

    Returns: "lapvqa hrjjed iszi sjwasmyn"

  67. "um giq wshfi vitajx lpjgjn"

    Returns: "erjrn kabsksk sdfthev oqus"

  68. "pwsppxaxiqmbbrenhgwpmocxlnihe"

    Returns: "btjbmonu cjtoow eyimda oyk ub"

  69. "nmmzo rxbddstqhoenhvhmkmyww lo"

    Returns: "wqehss aumhkbu xifqz voeg oipg"

  70. "jqafrlzpakvfujcfujktlhumjnotzyqd"

    Returns: "dvo wztuoe tooq zxeyzbz dsbndlki"

  71. "yqjakdhgncgqc dczcitmtweeqtoxfjn"

    Returns: "jufmo tkjokmod oczuxie aqup abvr"

  72. "awwpyncoudk phgqkvibqtyvcsg calxochbel"

    Returns: "yljmna dha nmxun ifrdqni huxsoimb xpba"

  73. " yofrexkfwrjbffyqsvdmxjpddupakkv"

    Returns: "eguk kbtla pgolczy msbsvim ujqpd"

  74. "daxuyxvrazoymmcejjgtyccbcnkldhqt"

    Returns: "arwrowsh wexjcbb idjx ta djiugnj"

  75. "nwimewwwofvlokugizxausin frlryqk"

    Returns: "reoqnb eujdrst kreaj wrtdoxp dut"

  76. "yqbbrhcngqcojgi xvnoituopfsdat"

    Returns: "itvmuanq afhujbk oyrbdxh ilodm"

  77. "gmdsgbabowpaxlncjaatdvhiiuuo"

    Returns: "ka wvyeqk dxa jgyxeh zwemiqs"

  78. "h mmvkbwjurl ixaqmxgoxbqwzibyf"

    Returns: "ljcqeaff yabdsne caqealg izfhw"

  79. "ssrbsubxbtygudrrpaexronkyotzz"

    Returns: "ucpdcsdh viewopt zghpqyi zraj"

  80. "xgksottxghyhpocbcnvjlbiwtcgvbct"

    Returns: "bsix ryiemjfu agol vjguuyoe nay"

  81. "rbttdbnznd i kaehjjkzomgztynbthci ae"

    Returns: "draftj ovqpqm irxrw gabolif rausqmqm"

  82. "xooutii ij zgowjcatpxlgyfavy"

    Returns: "ceh jboqto texhb wgjicb dwuao"

  83. "retxifuneffmmujjwpyytssqruovctgd"

    Returns: "tkozoawt hlho elbk douylt jxioij"

  84. "upaenpnnanobajmdk tjzmmatmpdhcxci"

    Returns: "qi agojg jhaxcl dzpcyif pfo abtwh"

  85. "slexolnsqkv xopytnpiismopmbxpcp"

    Returns: "utqzwxp bmclzwa azrquuu runzxor"

  86. " puuaiingpignaktzvamrrpypjrcxxm"

    Returns: "locf rumpahpz teydml cogai owfy"

  87. "kumpmbykebbtfukaakoqtoiqmmzlmnazzwyaa"

    Returns: "ihbn rwyu pidh zo mdimwfk oj czmoulqz"

  88. "nxxfcv vwhzaruama hhdmcwsehsypiv "

    Returns: "fupy nsso wtjrteys ewe okb kvhass"

  89. "kqlukyrqkjrqyruyzlrbsh ypqrzbaq"

    Returns: "vraelnbr usfisji abchsan rgjcqa"

  90. "pjdgevqdubrtrpgppyyvvmxbhczkj"

    Returns: "zmxqho gnlumas zsrhyow vrfsum"

  91. "lncdqmufnefafgcebhcaukwefsixyehm"

    Returns: "fxiy soptzpg qizlnxk efk borhkbw"

  92. "rxmhdkezhgofmvxqhxujpixurtf"

    Returns: "eyxvevs supq whdihhk wyeeuq"

  93. "yawcwwfmlqfkdlwzmnyjdkowicrumguwlouyvz"

    Returns: "di id lupwnojt eurdrhqw okv uk dpubbag"

  94. "shxnaaeqjlofhhsuurbhpdgt z"

    Returns: "naeiui jrghnca pnzxaxz avs"

  95. "casdehoaswgtnspomlzbnmgnwfmgrrsw"

    Returns: "gokhs sok ulrfhs dcpfquf tekejwj"

  96. "bgkvitxeulwbugozav txpobfhieow"

    Returns: "mbwfdeh fwrneb jwgkoi jnqcupjh"

  97. "bbjpocescxa prhzqzjuuepbeayupuiu"

    Returns: "mip vipzihhf ynjxeua pwhphdew ta"

  98. "aznyvzbocjocirli dk ukkeif"

    Returns: "zhtwde xihxig rgijii itkgo"

  99. "shxnaaeqjlofhhsuurbhpdgt z"

    Returns: "naeiui jrghnca pnzxaxz avs"

  100. "mmbtvrbhhtgohaktklqegnrmlelojotyeyeiudvtil ey ffg"

    Returns: "the quick brown fox jumps over the lazy dog again"

  101. "tmmbtvrbhhtgohaktklqegnrmlelojotyeyeiudvtil ey ffg"

    Returns: "wthe quick brown fox jumps over the lazy dog again"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: