Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is,

a = 1, b = 2, c = 3, ..., z = 26

(no distinction between lower and upper case letters is made). Every other character is identified with 0.

The "sum" of a word is the sum of its characters, for example: the sum of e-mail is 40 = 5 + 0 + 13 + 1 + 9 + 12, since e = 5, - = 0, m = 13, a = 1, i = 9, l = 12.

The Challenge

Write a program or a function that takes as input an integer n in the range 10-100 and returns a word of the English language whose sum is equal to n

This is codegolf, standard loopholes are forbidden.


  • 8
    \$\begingroup\$ Welcome to code golf! This appears to almost be a good challenge, you just have one significant problem: you haven't defined the English language. I would personally recommend saying the submissions are allowed to take a lexicon of English words as a free argument. For the future, please consider using our sandbox to work through such problems before posting. \$\endgroup\$ Commented Mar 18, 2020 at 15:58
  • 6
    \$\begingroup\$ Essentially, you need to somehow define what is a valid English word. @FryAmTheEggman suggested adding a list of possible English words as an input. \$\endgroup\$ Commented Mar 18, 2020 at 16:05
  • 7
    \$\begingroup\$ @Nik Challenges on this site are required to be objective, with posters being able to validate and score their solutions as they post. We've found that asking voters to vote based on a certain judgment is ineffective and does not make for good quality control. \$\endgroup\$
    – xnor
    Commented Mar 18, 2020 at 16:13
  • 9
    \$\begingroup\$ As an alternative to making the dictionary be an input, I think a good way to go is to specify your own dictionary by linking to a downloadable file (that code is not allowed to access) in the question. Then it becomes a compression-style challenge about finding a good set of words to use for each length. \$\endgroup\$
    – xnor
    Commented Mar 18, 2020 at 16:16
  • 4
    \$\begingroup\$ Due to some confusion, I think you should clearly edit in that only those words in the file count as English words. Thank you for making the suggested changes, so far. \$\endgroup\$ Commented Mar 18, 2020 at 16:58

5 Answers 5


Python 3.8 (pre-release), 262 235 bytes

lambda x:f'JKLmGoPlheAhVegytMtosOdtthfvtWypvttgYsRWspytps    e  eegli ra eehnkPooeoroyyauiuruotoituooup    b   aggd  p ai    mnrwiwpnwsnyotrosturwutr{"":8}d{"":14}gnlz   nht ntkpstmsltty'[(k:=x-10)//46*23+k%23::46].strip()+k//23%2*'er'

Try it online!

Uses words from the list that appear with and without a trailing er, cutting the number of required words almost in half.


05AB1E, 187 51 48 bytes


Try it online. (Pretty slow unfortunately, so no test suite, but here is a list of all the words used.)


  •o‹§d∍(Ì•           # Push compressed integer 13897672729830113
    3в                # Convert it to base-3 as list: [2,1,1,1,1,1,1,1,1,1,1,2,0,1,1,2,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,2]
      ¾7:             # Replace the 0 with a 7
         65Å1         # Push a list of 65 1s
             «        # And append it to the list
              .¥      # Undelta the list (with leading 0): [0,2,3,4,5,6,7,8,9,10,11,12,14,21,22,...]
                žy+   # Add 128 to each: [128,130,131,...]
žĆ                 è  # Index each into the 05AB1E codepage builtin
ã                     # Get the cartesian product with itself, to create all possible pairs
 J                    # Join each pair together
  ε     }             # Map over each pair:
   „'ÿ               '#  Push string "'ÿ", where the `ÿ` is automatically filled with the current pair we're mapping over
      .V              #  And eval it as 05AB1E code, pushing the dictionary word
ʒ       }             # Filter the list of words by:
 A                    #  Push the alphabet
  s                   #  Swap to take the current word we're filtering over
   S                  #  Convert it to a list of characters
    k                 #  Get the index of each letter inside the alphabet
     >                #  Increase it by 1 to make the 0-based indices 1-based
      O               #  Sum them all together
       Q              #  And check if it's equal to the (implicit) input-integer
R                     # Then reverse the list of remaining words (work-around for input n=11,
                      # which otherwise would result in "fda", which is not in OP's list)
 é                    # Then (stable) sort all words based on length, from shortest to longest
  θ                   # And only leave the last one
                      # (after which it is output implicitly as result)

Unfortunately, not all words that can be found in the 05AB1E word list can be found in the provided list as well.

See this 05AB1E tip of mine (sections How to use the dictionary?, How to compress large integers?, and How to compress integer lists?), to understand how the dictionary words and compressed integer list works.

Original 187 bytes answer:


Try it online or verify all test cases.

I've chosen random words which are both in the English dictionary provided, as well as in 05AB1E word list.


“...“     # Dictionary string containing all words, space-separated
     #    # Split it on spaces
      s   # Swap to get the (implicit) input
       è  # And used it to index into the list (0-based and with wrap-around,
          # so 91-100 wrap around to the first few words)
          # (after which the result is output implicitly)

Here is just the dictionary string part of the program.

See this 05AB1E tip of mine (section How to use the dictionary?), to understand how the dictionary string works.


JavaScript (ES6),  217  205 bytes

An idea similar to the one used by ovs.

Most words are used twice: once with the -ty suffix (which is worth \$45\$ points) and once without it.


Try it online!

JavaScript (Node.js),  325 ... 240  235 bytes

Words of \$3\$ to \$5\$ letters ending in either "d" or "y", with the penultimate letter deduced from the other ones.


Try it online!


Perl 5, 361 bytes


Try it online!

Ungolfed program.pl:

use v5.10;
use MIME::Base64 'decode_base64';
use Compress::Zlib 'memGunzip';

# base64-encoded gzip'ed string of 91 words:
my $data=<<'';

say ''.(memGunzip(decode_base64($data))=~/\w+/g)[-10+pop]


for n in {10..100};do echo -n "n=$n "; perl program.pl $n; done
n=95 potsy
n=96 furzy
n=97 luxus
n=98 musty
n=99 mizzy
n=100 buzzy

Improvement: I could have search for words in words.txt that gave shorter gzip'ed $data. Probably shortest AND most similar word from one n to the next.

  • 1
    \$\begingroup\$ You can shave off some bytes: Try it online! \$\endgroup\$
    – Xcali
    Commented Mar 18, 2020 at 21:52

C (gcc), 574 bytes


Wordlist generated using my program run as program < words.txt.

Try it online!

  • \$\begingroup\$ I think you can ditch the char at the beginning. \$\endgroup\$
    – ceilingcat
    Commented Jul 4, 2020 at 4:50

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.