I presume you've all heard of the Rosetta Stone, an ancient stone found to have essentially the same passage written on it in three different scripts. This challenge is based upon that: you have to write three versions of the same program in different languages.

The three programs must output the first n iban numbers, n being a number input by the user. There are only 30,275 iban numbers, so if n is greater than 30275, the program should return an error.

The challenge of the Rosetta Stone was that the scripts didn't appear to be mutually intelligible–knowing one didn't automatically make the others understandable. Your three programs should similarly be mutually unintelligible. That is, you may not golf down a Python 2 program and then submit it (or a minor modification) as a Python 3 version too, nor a C program as C++, etc. To prevent this, the Levenshtein distance between any two versions should be at least 25% of the length of the shorter of the two versions being compared, and at least 16 as an absolute numerical value. You may check conformance using this online Levenshtein distance calculator.

The winner is the person with the shortest combination of programs.

  • 1
    \$\begingroup\$ What should the output be if n > 30275? \$\endgroup\$ Aug 20, 2014 at 14:54
  • 3
    \$\begingroup\$ The first time around, I read "iban number" as IBAN number, unfortunately. \$\endgroup\$
    – Joe Z.
    Aug 20, 2014 at 15:05
  • 1
    \$\begingroup\$ I think you can save this problem by making the scoring strictly objective. The "popularity" scoring is usually a last resort for fun problems that are otherwise impossible to score. \$\endgroup\$ Aug 20, 2014 at 19:22
  • 1
    \$\begingroup\$ @BetaDecay What about banning the versions of the same language, and supersets (e.g. C++ and C or Objective-C and C), and each program has to differ by at least 10 characters (excluding variable names)? \$\endgroup\$
    – Milo
    Aug 20, 2014 at 21:39
  • 3
    \$\begingroup\$ I've edited the question to provide a way of easily verifying conformance with the spirit of the question, but had to invent thresholds. I think they're reasonable but you may want to tweak them, @BetaDecay. \$\endgroup\$ Aug 22, 2014 at 10:02

1 Answer 1


424 425: Haskell, Python 2, Perl

As they should for a true Rosetta comparison, all three programs work the same way, taking input from the first command-line argument and building up the list with the same rules, and variable names, where possible.

Haskell, 171

import System.Environment
main=do i<-getArgs;putStr.show$[n|n<-[0..777777],all(`notElem`"5689").show$n,all(\d->n`div`d`mod`100`notElem`13:[30..39])[1,1000]]!!(read.head$i)

Python 2, 156

import sys
print[n for n in range(777778)if all([c not in"5689"for c in str(n)])and all([n/d%100not in[13]+range(30,40)for d in[1,1000]])][int(sys.argv[1])]

Perl, 97 98

$i=@ARGV[0];die if $i>30275;for(0..777777){push@n,$_ if!(/[5689]/ or/(13|3.)(|...)$/)}print@n[$i]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.