44
\$\begingroup\$

Create a program which prints the amount of characters its source has in English words.

If your program is nine letters long it should print "nine".

Capitalization is ignored: in case you're printing "one" (somehow) you can print "one", "oNe", "ONE" or anything else.

Base ten is required.

Proper spacing is also required.

In the (unlikely but just for specification) case your program reaches one billion characters or more, use the American number scale. A billion here is 10^9 and a million is 10^6.

Do not use "one hundred and one": use "one hundred one".

Do not use the hyphen. Print forty four, not forty-four.

Test cases with a fake program:

10.(96 0s later)..01 prints one HuNdreD ONE -- okay: proper spacing, no "and"
10.(96 0s later)..01 prints one HuNdreDONE -- not okay: wrong spacing
10.(96 0s later)..01 prints one thousand two hundred two -- not okay: base 3 rather than base 10
10...(999999996 0s later) prints nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-six: not okay, wrong number and includes hyphens

Golfy challenge, as always: shortest code wins. You're free to post after the green tick has been given, though. This serves more for completeness for hard to program languages. Malbolge, anyone?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Proper spacing is also required. Does this mean no trailing spaces in the output? \$\endgroup\$ Oct 23 '19 at 12:14

101 Answers 101

1 2 3
4
0
\$\begingroup\$

C (gcc), 29 bytes

main(){puts("twenty nine");;}

It's an actual program...

Try it online!

\$\endgroup\$
0
\$\begingroup\$

C# (Visual C# Interactive Compiler), 18 bytes

Write("eighteen ")

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Gaia, 5 bytes

five”

Just a string literal that gets implicitly output.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

International Phonetic Esoteric Language, 8 bytes

"eight"o (push and print "eight")
\$\endgroup\$
0
\$\begingroup\$

Pip, 6 bytes

"six";

Try it online!

; is a comment.

\$\endgroup\$
5
  • \$\begingroup\$ Also a polyglot in R, and this exact 'program' was even already submitted in R \$\endgroup\$ Sep 16 '20 at 6:22
  • \$\begingroup\$ And, as a bonus, the other answer in R is also a polyglot in Pip \$\endgroup\$ Sep 16 '20 at 6:24
  • \$\begingroup\$ I've been trying to find easy challenges for R, but all of them somehow have an R solution \$\endgroup\$
    – Razetime
    Sep 16 '20 at 6:53
  • 2
    \$\begingroup\$ I don't think that should stop you from having a go. I wish there were more challenges with more-than-one answer in R (or any other language). It's really fun & instructive to see the different approaches. Obviously, one of them will always be the shortest, but that isn't a problem. I usually try to deliberately avoid looking at any other R answers if there already are any, and post my own answer if it ends-up different from whatever is already there, even if it's longer (and usually one of the other R golfers then makes it shorter for me anyway...). \$\endgroup\$ Sep 16 '20 at 7:03
  • 1
    \$\begingroup\$ For instance, this recent challenge got 4 independent (and all different) R answers... \$\endgroup\$ Sep 16 '20 at 7:06
0
\$\begingroup\$

MAWP, 30 bytes

99W3M!;98W!;1M;2A!;2M!;11MM3M;

Try it!

prints in capitals.

\$\endgroup\$
0
\$\begingroup\$

Japt, 4 bytes

Lucked out that the string compression found anything to compress in one of the smaller numbers.

`f r
`    // Decompress compressed string
 f r // Compressed string literal for "four"

Try it here.

\$\endgroup\$
0
\$\begingroup\$

Zsh, 6 bytes

<<<six

Try it online!

\$\endgroup\$
2
0
\$\begingroup\$

Barrel, 4 bytes

four

Implicitly prints the unknown instructions "four". However, this could potentially be voided by later modifications, so here's a safe 5-byter that uses a string:

'five
\$\endgroup\$
0
\$\begingroup\$

AWK, 20 bytes

BEGIN{print"twenty"}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Rattle, 5 bytes

five|

Try it Online!

This is pretty simple - it takes "five" as a variable then outputs it implicitly

\$\endgroup\$
1 2 3
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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