Create a program that prints the number of characters it has, in words

37

5

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?

Andrew

Posted 2019-10-19T13:29:19.077

Reputation: 2 067

Proper spacing is also required. Does this mean no trailing spaces in the output? – Engineer Toast – 2019-10-23T12:14:24.467

Answers

64

Google, 11 9 8 6 bytes

-3 bytes thanks to 12Me21.

-2 bytes thanks to Deckerz.

6=wrds

Try it online!

Just in case Google changes something in the future, this is how it looks like now:

Google six in words

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

45

Poetic, 400 bytes

Type fourhundred chars? I say, I think I have an angle.
I say "Gosh, could I just go create some poem? Clearly it comes a long way, writing stuff I say."
I compose the entire written poem, and someone reads a tiny, tiny portion.
"Surely, it all is garbage," cried a big fat crybaby.
Would HE frankly notice how many long, tedious hours I took?
The crybaby whined a lot. I watched, then I ignored him.

Try it online!

Prints Four HunDrED. (I tried to make it print some number in the 300s, but I can't seem to do so in under 400 bytes.)

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.

JosiahRyanW

Posted 2019-10-19T13:29:19.077

Reputation: 2 600

3Clearly it comes a long way, writing stuff I say. Beautiful poem, have a +1. – None – 2019-10-20T01:56:09.570

2@A_ Thanks, it's always fun to create coherent sentences based on pre-determined word lengths. – JosiahRyanW – 2019-10-20T02:01:40.413

30

brainfuck, 40 bytes

+[+++++>++<]>.+++++++++.+++.++.+++++.+++

Try it online!

The last three characters don't actually do anything useful, but it's easier to output forty than thirty seven.

The ascii code for f is 102, which is 2/5 of 255, found by the initial loop. After that, all the characters in the output just happen to be in ascending alphabetical order.

Level River St

Posted 2019-10-19T13:29:19.077

Reputation: 22 049

Whoops, I don't know why I was trying to use different cells for each letter... Nice – HiddenBabel – 2019-10-19T18:46:24.080

@HiddenBabel Thanks. forty turned out really well. I think for NINETY the optimum would be one cell for NNTY and one cell for IE – Level River St – 2019-10-20T02:16:33.037

So I guess you already looked for thirty with one cell for trty and one for hi? I can't find a singular loop that will set both of them close by. – HiddenBabel – 2019-10-20T02:33:54.433

2Indeed, forty is the only number whose letters are in ascending alphabetical order. – Neil – 2019-10-20T09:45:38.497

28

MathGolf, 2 bytes

Well, MathGolf has a string compression library that seems to compress "two" to 1 byte. You need a command to decompress this.

╩_

Try it online!

user85052

Posted 2019-10-19T13:29:19.077

Reputation:

7Now we're looking for a language where there's a 1-char command that prints one, or where the empty program prints zero. That's going to be interesting. – my pronoun is monicareinstate – 2019-10-19T14:03:56.303

1

@Nat MathGolf can use Code Page 437, in which is one byte (0xCA)

– pizzapants184 – 2019-10-20T20:39:09.697

2

@Nat MathGolf has a built-in dictionary, the first 256 words of which can be accessed using followed by one byte. The word at index 95 (the code point for _) is "two", so "two" is pushed to the stack and implicitly printed when the program exits. (I think, I haven't used MathGolf)

– pizzapants184 – 2019-10-20T21:25:07.653

17

Google Translate (3 bytes)

Try it online!

It's the Chinese character for "one" (matching the number of characters in the source code), though the score's due to the character itself being 3 bytes.


Google Translate (3 bytes)

tre

Try it online!

It's Italian for "three".

Nat

Posted 2019-10-19T13:29:19.077

Reputation: 499

2

You can add a &tl=en at the end of your URLs to force it to show in English. My Google translate was set to English to Persian from a previous translation and after opening your links, it was showing the resulting numbers in Persian :P Here is also a 2 chars version, converting Persian دو to English Two.

– Night2 – 2019-10-20T13:59:26.717

2

...also (Latin-ised) Hindi "do".

– Jonathan Allan – 2019-10-20T22:11:40.650

1and albanian dy – ev3commander – 2019-10-20T22:36:13.077

1to is Norwegian and Danish for two (and we also say tre for three). Google translate doesn't autodetect that one, though. – Arthur – 2019-10-21T16:17:23.933

1cinco, that means five in Spanish – JuanCa – 2019-10-22T19:43:06.043

15

CSS, 30 bytes

body::after{content:'thirty';}


CSS (Google Chrome only), 26 bytes

This should be saved in an empty file between <style> and </style> tag, doesn't work on FireFox or Stack Exchange's code snippets. Tested on Windows Chrome 77.

:after{content:'twenty six

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

1Never would have thought of this one: +1 – Redwolf Programs – 2019-10-19T13:44:33.000

14

PHP, 4 bytes

four

Try it online!


PHP, 9 bytes

<?= nine;

Try it online!

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

14

Python 3, 15 bytes

exit("fifteen")

...prints to STDERR.

Try it online! (see the "debug" panel)

Jonathan Allan

Posted 2019-10-19T13:29:19.077

Reputation: 67 804

1I had print('sixteen'), you win :) – Jylo – 2019-10-22T06:52:47.453

1print'ten', in Python 2? – JuanCa – 2019-10-22T19:47:17.970

1

@JuanCa yes

– Jonathan Allan – 2019-10-22T20:05:44.917

14

COW, 800 bytes

MoO!!
MoO MoO!!
MoO MoO MoO!!
MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MMM MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO Moo MoO MoO MoO MoO Moo MOo MOo!!
Moo MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO Moo MMM Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO!!
Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo!!
MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo Moo MMM!!
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MMM MoO Moo MOo Moo!

Try it online!

Prints EIGHT HUNDRED

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

4I think ONE THOUSAND is expected. – None – 2019-10-20T08:08:47.730

1@A_ EIGHT HUNDRED then! Mooooo! – Night2 – 2019-10-20T08:47:08.670

12

Wolfram Alpha, 6 bytes

Apparently Wolfram Alpha isn't a language according to our meta, but we have a Google entry in this challenge and part of the argument against Wolfram Alpha is "What's preventing me from solving something in google".

spell6

Try it

Note that this returns a single result, unlike most Wolfram Alpha "queries".

enter image description here

Jonathan Allan

Posted 2019-10-19T13:29:19.077

Reputation: 67 804

11

Malbolge, 40 bytes

(CB%#9]~}5:3Wyw/4-Qrqq.'&Jkj(h~%|Bd.-==;

dingledooper

Posted 2019-10-19T13:29:19.077

Reputation: 421

3Is it possible to add a code break-down, or if you can't say how it works then how it was produced? – Jonathan Allan – 2019-10-22T08:55:51.950

There exists a certain Malbolge generator. It is very useful in generating short Malbolge code. :)

– dingledooper – 2019-10-22T22:26:02.520

10

Labyrinth, 10 bytes

84.69.78.@

Try it online!

How?

  - initially the main stack contains infinite zeros    [0,0,0,...]
8 - multiply the top of the stack by ten and add eight  [8,0,0,...]
4 - multiply the top of the stack by ten and add four   [84,0,0,...]
. - pop, mod 256, print character                       T
6 - multiply the top of the stack by ten and add six    [6,0,0,...]
9 - multiply the top of the stack by ten and add nine   [69,0,0,...]
. - pop, mod 256, print character                       E
7 - multiply the top of the stack by ten and add seven  [7,0,0,...]
8 - multiply the top of the stack by ten and add eight  [78,0,0,...]
. - pop, mod 256, print character                       N
@ - exit

Jonathan Allan

Posted 2019-10-19T13:29:19.077

Reputation: 67 804

11As an IP address range this answer geolocates to the United Kingdom with Vodafone wireless broadband. – Purple P – 2019-10-19T16:38:09.873

@PurpleP Ha ha awesome. – Jonathan Allan – 2019-10-19T16:42:48.487

5@PurpleP First thing I thought of when seeing this answer (IP address, not UK Vodafone) – Redwolf Programs – 2019-10-19T19:18:08.613

10

Emoji, 18 bytes

⛽eighteen➡

Try it online!


Emoji, 8 chars

⛽eight➡

Try it online!

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

5⛽➡ ...gasoline makes the car go? – Darrel Hoffman – 2019-10-21T17:11:35.977

8

Brainf***, 90 bytes

+[+[>>+<+<-]>]>[>+>+>+>+>+>+<<<<<<-]>.>-----.>.>---------.>++++++.>+++++++++++.<+><><><><>

Try it online!

HiddenBabel

Posted 2019-10-19T13:29:19.077

Reputation: 603

7

SOGL V0.12, 3 bytes

Well, SOGL has a string compression library that seems to compress "three" to 3 bytes.

@0‘

Try it Here!

my pronoun is monicareinstate

Posted 2019-10-19T13:29:19.077

Reputation: 3 111

Gratz, unless a language exists which prints zero, nowt, or nought with an empty program this is probably as good as it'll get. – Jonathan Allan – 2019-10-19T13:56:15.230

1

...I stand corrected!

– Jonathan Allan – 2019-10-19T14:04:03.753

6

Keg, 3 bytes

-1 from Jono2906 for reminding me the string compression

2 can play the 3 byte game!

‘0⅀

TIO

Old answer, 4 bytes

You can't get shorter than 4. (Without using string compression of course.) 4 is the smallest English word that is the same length as the number it represents.

Just some good old-fashioned Ascii/auto-pushing Keg golfing!

four

Try it online!

Explanation

four#   Push 4 onto the stack
#Implicit Print

user85052

Posted 2019-10-19T13:29:19.077

Reputation:

Ah, didn't see your answer when I posted mine. Good job! – Lyxal – 2019-10-20T00:31:32.477

6

Jelly, 4 bytes

“Ɱ9»

Try it online!

Jonathan Allan

Posted 2019-10-19T13:29:19.077

Reputation: 67 804

5

JavaScript, 16 10 bytes

-6 each from Night2's suggestion in the comments

Try it online! (alert doesn't work in TIO, so I'm using print)

alert`ten`

Javascript, 26 20 bytes

Try it online!

console.log`twenty`;

Redwolf Programs

Posted 2019-10-19T13:29:19.077

Reputation: 2 561

@Night2 The JS print function is used for printers, not console output, I think. – Redwolf Programs – 2019-10-19T19:10:09.283

1@Night2 Ah, makes sense. I'll update the TIO, but keep it as alert on here since it's more recognizable (sort of) – Redwolf Programs – 2019-10-19T20:11:14.607

Where can I find some explanation regarding the syntax used here? I've never seen this before (ommiting the brackets), but it indeed works with any function. What's it called? – Tomáš Zato - Reinstate Monica – 2019-10-21T13:50:07.480

1

@TomášZato They're called tagged templates. I found some info on them here, in the Tagged templates section

– Redwolf Programs – 2019-10-21T15:42:22.023

5

C# (.NET Core), 64 bytes

class P{static void Main(){System.Console.Write("sixty four");}}

I had to see what a non-competative language would score.

Try it online!

Hand-E-Food

Posted 2019-10-19T13:29:19.077

Reputation: 7 912

3sixty? – Night2 – 2019-10-20T06:53:21.880

1

Would be nine if lambdas were allowed.

– Neil – 2019-10-20T09:44:09.550

5

Lost, 30 bytes

v<<<<<<<>>>>>>>
>%?"thirt/J"+@

Contains the unprintable character ESC with unicode value 27 after the ^ on the second line. Thanks to @JoKing getting rid of the unprintable (for the same byte-count).

Try it online or verify that it's deterministic.

Explanation:

Explanation of the language in general:

Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.

A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.

In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.

Explanation of the program:

All arrows, including the reflect / in the string, will lead the path towards the leading > on the second line. From there the program flow is as follows:

  • >: travel in an east/right direction
  • %: Put the safety 'off'. In a Lost program, an @ will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character @ would immediately terminate without doing anything. The % will turn this safety 'off', so when we now encounter an @ the program will terminate (if the safety is still 'on', the @ will be a no-op instead).
  • ?: Clean the top value on the stack. In some program flows it's highly likely we have a partial string on the stack, so we use this to wipe the stack clean of that potential string.
  • ": Start a string, which means it will push the integer code-points of the characters used.
  • thirt/J: Push the code-points for these characters, being 116 104 105 114 116 47 74 respectively
  • ": We're done pushing code-points of this string
  • +: Add the top two values together: (47+74=) 121
  • @: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the -A program argument flag, these code-points will be output as characters instead.

Two things to note:

The top part could also have been v<<<<<<<<<<<<<< instead. Lost will wrap around to the other side when moving in a direction. So using v<<<<<<<>>>>>>> could be a slightly shorter path, and since it's the same byte-count anyway, why not use it. :)
Also, the first line contains an additional trailing > to make the byte-count from 29 to 30.

Kevin Cruijssen

Posted 2019-10-19T13:29:19.077

Reputation: 67 575

This is a nice find! – ouflak – 2019-10-21T13:07:09.427

@ouflak Thanks, although I must admit it's very similar as the Hello World! answer in Lost. It took a while before I realized I could use an unprintable to output thirty, though. Otherwise I would have had to settle with forty with a bunch more no-op trailing >. – Kevin Cruijssen – 2019-10-22T07:23:45.390

You can do /J to avoid the unprintable if you like

– Jo King – 2019-10-22T23:02:33.243

@JoKing Ah, I tried some combinations with both addition and subtraction of the arrow, but forgot about the reflects / and \. Thanks, that indeed looks better. :) – Kevin Cruijssen – 2019-10-23T06:19:55.797

5

Piet, 90 codels

enter image description here

Try it online!

In pseudo-code:

The characters are pushed onto stack. To save space, their ASCII values minus 100 are stored. When the string is built, a loop pops, adds 100 to, and prints each character to STDOUT.

    ; Place sentinel 0 on stack
    push 1
    not

    ; Place 21 (y) on stack
    push 7
    push 3
    mul

    ; Place 16 (t) on stack
    push 4
    dup
    mul

    ; Place 1, 10, 5, 10 (e, n, i, n) on stack
    push 1
    push 10
    push 5
    push 10

    ; Check if top of stack is non-zero
    ; Place a 1 if it is, a 0 otherwise
    dup
    not
    not

write_loop:
    ; Turn DP (Direction Pointer) as many steps
    ; clock-wise as value on top of stack
    ; If we had a zero on stack, we continue into
    ; the yellow area and get trapped, ending execution
    pointer

    ; If not, we continue
    ; Add 100 to top of stack
    push 5
    push 4
    push 5
    mul
    mul
    add

    ; Pop and print character
    outc

    ; Turn DP one step to the right
    push 1
    pointer

    dup
    not
    not

    ; Check if top of stack is non-zero
    ; Place a 1 if it is, a 0 otherwise
    dup
    not
    not

    ; We're now back at beginning of the writing loop, sort of like a jmp write_loop

gastropner

Posted 2019-10-19T13:29:19.077

Reputation: 3 264

How many bytes is this? – Jo King – 2019-10-22T22:56:56.743

1@JoKing Depends on the fileformat for the image, which is why Piet is generally counted in codels. – gastropner – 2019-10-22T23:24:27.550

Yes, but this is [tag:code-golf], so it is measured in bytes

– Jo King – 2019-10-22T23:29:25.480

@JoKing That is curious. I have not seen that comment on any other Piet answers. – gastropner – 2019-10-22T23:36:41.873

4

Batch, 10 bytes

@ echo ten

If you think the extra space after the @ is ugly, the next possible answer is:

@echo twelve

Neil

Posted 2019-10-19T13:29:19.077

Reputation: 95 035

Why not just echo nine? – Night2 – 2019-10-19T15:20:25.503

@Night2 Because that echos the command echo nine as well as its output. – Neil – 2019-10-19T16:36:22.537

But running directly from command prompt, doesn't do that (unless it doesn't count as Batch). – Night2 – 2019-10-19T17:38:10.647

1@Night2 No, that would be a snippet, or a REPL, or something along those lines. – Neil – 2019-10-19T18:33:07.950

4

05AB1E (legacy), 3 bytes

“„í

Try it online!

Using dictionary

AZTECCO

Posted 2019-10-19T13:29:19.077

Reputation: 2 441

4

Shakespeare Programming Language, 800 bytes

Try it online!

(Whitespace added for readability)

800 Bytes---- filler.Ajax,.Puck,.Act I:.
Scene I:.[Enter Ajax and Puck]Ajax:
You is the sum ofthe sum ofthe cube ofa big big cat a big big cat a cat.Speak thy.
You is the sum ofyou a big big cat.Speak thy.
You is the sum ofyou a big pig.Speak thy.
You is the sum ofyou a cat.Speak thy.
You is the sum ofyou twice twice the sum ofa big cat a cat.Speak thy.
You big big big big big cat.Speak thy.
You is twice the sum ofyou a big big cat.Remember you.Speak thy.
You is the sum oftwice you the cube ofthe sum ofa big pig a pig.Speak thy.
You is the sum ofyou the sum ofa big big big pig a cat.Speak thy.
Recall.You is the sum ofyou a big big pig.Remember you.Remember you.Speak thy.
You is the sum ofyou twice the sum ofa big big big cat a pig.Speak thy.
Recall.You is the sum ofyou a cat.Speak thy.
Recall.Speak thy.

Prints EIGHT HunDRED. The math to get from one letter to another was very complicated and there was little room for error. This is probably improvable in terms of code, but 700 is most likely impossible. Little improvement saving 2 bytes in the actual code because I missed out on optimizing 2*(4+2) to 2*2*(2+1) for some reason.

Hello Goodbye

Posted 2019-10-19T13:29:19.077

Reputation: 442

3

Python 3, 16 bytes

print("sixteen")

Try it online!

Also works in Proton.

HyperNeutrino

Posted 2019-10-19T13:29:19.077

Reputation: 26 575

1I think you just beat me to this. Same code works in both Python 3 and Lua. – ouflak – 2019-10-19T15:41:35.750

3

GolfScript, 6 bytes

Push six. Implicit print.

 'six'

Try it online!

user85052

Posted 2019-10-19T13:29:19.077

Reputation:

3

ink, 4 bytes

Four

Try it online!

Predictably enough, it prints Four

Sara J

Posted 2019-10-19T13:29:19.077

Reputation: 2 576

3

Bash, 15 9 bytes

echo nine

Try it online!

Thanks to:
- @Night2 for saving me 6 bytes

Delta

Posted 2019-10-19T13:29:19.077

Reputation: 543

39 bytes. By the way you can click on icon in https://tio.run and copy/paste "Code Golf submission (Stack Exchange)" section here to have auto generated answer with correct formatting. – Night2 – 2019-10-19T17:41:58.583

@Night2 Thank your for the improvment and the tip :) – Delta – 2019-10-19T18:05:23.757

3

Lua, 10 bytes

print"ten"

Also works in many BASIC dialects that don't have a ? shortcut for PRINT

12Me21

Posted 2019-10-19T13:29:19.077

Reputation: 6 110

3

Shaggy

Posted 2019-10-19T13:29:19.077

Reputation: 24 623

3

R, 7 6 bytes

 "six" #space before the text

Previously:

"seven"

stuart stevenson

Posted 2019-10-19T13:29:19.077

Reputation: 131

Also works in PHP without the opening PHP tag. In fact, with PHP you could have simply four – Shaun Bebbers – 2019-10-21T13:53:16.223

3

Hexagony, 9 bytes

n;i;@;e\\

Try it online!

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

Not How it works

This Hexagony program looks almost like normal code!

n;i;@;e\\
n;i;       Pushes n and prints it, then pushes i and prints it
    @;     Retrieves the bottom of the stack (n) and prints it
      e\\  Pushes e and terminates the program, printing implicitly

How it works

nine.png

Input starts on the blue path, storing the value n then printing it with ;. It picks up the value i, then jumps to the third line where it hits a mirror. This takes it to the diagonal path, reentering the value i then printing it with ;.

From the bottom left corner, since the current value of i is truthy, it jumps to the red stream starting in the top-left corner, taking n then printing it with ;. The two mirrors redirect it and then it jumps to the e. Finally, it jumps from the middle of the bottom edge to the middle of the top edge, printing the e with ; and terminating with @.


Thanks to Timwi for their HexagonyColorer.

boboquack

Posted 2019-10-19T13:29:19.077

Reputation: 2 017

2

Ruby, 6 bytes

Ruby has an extremely convenient builtin p that prints the string.

p'six'

Try it online!

user85052

Posted 2019-10-19T13:29:19.077

Reputation:

1Are the quotes allowed? – Eric Duminil – 2019-10-20T07:00:35.987

2

Red, 10 bytes

print 'ten

Try it online!

Galen Ivanov

Posted 2019-10-19T13:29:19.077

Reputation: 13 815

2

Turing Machine Code, 60 50 bytes

0 _ f r 1
1 _ i r 2
2 _ f r 3
3 _ t r 4
4 _ y r 50

Try it online!

As an added bonus, if that counts for anything, it has the number in the code as well. Edit: Found a shorter solution which still contains the number of bytes in the code.

ouflak

Posted 2019-10-19T13:29:19.077

Reputation: 925

It doesn't count but nice stuff. – Andrew – 2019-10-19T17:29:50.917

2

Japt, 5 bytes

"five

Try it online!

AZTECCO

Posted 2019-10-19T13:29:19.077

Reputation: 2 441

Welcome to Japt :) I'll be reopening my bounty (with slightly lower rep) for new users on Monday or Tuesday if you'd like to try for it. I'll count any solutions you post between now and then towards it, including this one. You're welcome to my solution, if you'd like; didn't see yours before posting. – Shaggy – 2019-10-19T22:01:51.033

Thank you @Shaggy ! I'll try it for sure even if I'm scared by the characters used since I do everything from a phone.. Btw I was sure there was some compression available in Japt, my bad I didn't checked. – AZTECCO – 2019-10-20T08:22:37.943

1This also works in TI-Basic (with all caps) "FIVE – pizzapants184 – 2019-10-20T21:31:42.477

2

Zsh, 6 bytes

<<<six

Try it online!

GammaFunction

Posted 2019-10-19T13:29:19.077

Reputation: 2 838

2

C (gcc), 25 20 bytes

f(){puts("twenty");}

Try it online!

GammaFunction

Posted 2019-10-19T13:29:19.077

Reputation: 2 838

2"twenty" works – 12Me21 – 2019-10-19T21:19:41.977

@12Me21 I am a fool. – GammaFunction – 2019-10-19T22:08:58.160

2

Backhand, 6 bytes

"s"xiH

Try it online!

Outputs "six".

Jo King

Posted 2019-10-19T13:29:19.077

Reputation: 38 234

2

APL (Dyalog Unicode), 12 9 6 bytes

Took me a little searching and I don't like requiring the extra spaces, but such are the vagaries of English numbers.

Edit: -3 bytes thanks to Night2. -3 bytes thanks to ngn.

⊢'six'

Try it online! And a slightly different version to get it to work on Try it online!

Sherlock9

Posted 2019-10-19T13:29:19.077

Reputation: 11 664

is ⎕← required? dyalog prints results by default. if not: ⊢'six' – ngn – 2019-11-18T00:35:56.303

@ngn Not in TIO https://tio.run/##SyzI0U2pTMzJT////1HXIvXizAr1//8B

– Sherlock9 – 2019-11-18T05:50:39.473

but. or. generally, in kolmogorov complexity challenges we don't add ⎕←. – ngn – 2019-11-18T11:25:31.657

@ngn In that case, I've added both. – Sherlock9 – 2019-11-18T13:08:39.983

2

R, 10 bytes

cat("ten")

Try it online!

Prints ten. This simple answer is much shorter than all the other options I could think of.

If a bit of fluff around the answer is allowed, we can go with

R, 6 bytes

"six";

Try it online!

which prints [1] "six".

If a lot of fluff is allowed, we could even go with

R, 4 bytes

four

Try it online!

which prints to STDERR Error: object 'four' not found.

Robin Ryder

Posted 2019-10-19T13:29:19.077

Reputation: 6 625

2

Brain-Flak, 80 bytes

((((((((()()()())))((({({}){}}()){}){}()))[[]])())[][][])[]){({}<>)<>}<>........

Try it online!

The code to push eighty is 72 bytes and we add an extra 8 bytes to bring it to the correct amount.

Brain-Flak, 80 bytes

(((())()()()())((([]())())[][][])){({}(([]([]<>[])[]{}()){}){})<>}<>............

Try it online!

This version pushes EIGHTY and requires 12 bytes of padding.

Post Rock Garf Hunter

Posted 2019-10-19T13:29:19.077

Reputation: 55 382

2

Excel, 4 bytes

four

Uninteresting answer, not using a formula.


Excel, 5 bytes

'five

Using a formula, requires at least 3 extra bytes (=, ", ").

Excel, 6 bytes

="six"

Excel, 12 bytes

="tw"&"elve"
=T("twelve")

Excel, 14 bytes

=T("fourteen")

Excel, 16 bytes

=IF(1,"sixteen")

Excel, 18 bytes and upwards

=TRIM(" % ")

Insert required text, padded with required whitespace.

Wernisch

Posted 2019-10-19T13:29:19.077

Reputation: 2 534

2

Whitespace, 151 60 bytes

[S S S T    T   S N
_Push_6_Y][S S S T  N
_Push_1_T][S S S T  S T N
_Push_5_X][S S T    T   S T S N
_Push_-10_I][S S S S S N
_Push_0_S_(with_two_additional_no-op_spaces)[N
S S N
_Create_Label_LOOP][S S S T S T S S T   T   N
_Push_constant_83][T    S S S _Add_top_two][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Whopping -91 bytes thanks to @JoKing by using an < instead of == check in my Java program below and adding no-ops.

Shortest program generated with this Java program, which uses the printing approach of this Whitespace tip to output in full uppercase.

Kevin Cruijssen

Posted 2019-10-19T13:29:19.077

Reputation: 67 575

2

cat, 4 bytes

four

There are plenty of literal "four" answers already, but not one written in cat yet.

user253751

Posted 2019-10-19T13:29:19.077

Reputation: 818

Also works in Text

– Hello Goodbye – 2019-11-18T14:54:38.770

2

Hexagony, 6 bytes, 17 cycles

s;i>x@

Try it online!

Now the letters six are in more natural order, and the program finishes one cycle faster.

How it works

For more thorough explanation, see the previous answer below.

 A B
C > D
 E .
Execution path: ABC>CBAD>ADB.>.CE
                ^^  ^^    ^^    ^
                s;  i;    x;    @

Hexagony, 6 bytes, 18 cycles

x>i;s@

Try it online!

Inspired by boboquack's 9-byte solution. The following quote was a big hint:

I'm slightly disappointed that I couldn't get six to work (that would be pushing it with three characters, one output, one redirection and one termination).

How it works (or, How I got to this solution)

A 6-byte program is laid out on a hexagon of side length 2, and the 7th instruction is necessarily a no-op:

 ? ?
? ? ?
 ? .

Since I needed at least one mirror, I tried out various mirrors placed at various places, until I found this:

 A >
B C D
 E .

Assuming the current memory is always positive (and there are no branches/mirrors/IP changers among ABCDE), the IP follows the path

A>ADCB>.CAD>DAC.BE

The cell C is run exactly three times, and the cells right before C are D, B, and A respectively. And the cell E is first run after three runs of C. This is exactly what we want: write one of s, i, or x on the memory and print it, and then terminate!

Now back to the actual source code:

 x >
i ; s
 @ .

And the execution path, linearized, with significant instructions emphasized:

x>xs;i>.;xs>sx;.i@
   ^^^  ^    ^^  ^
   ^^              Print 's'
     ^  ^          Print 'i'
             ^^    Print 'x'
                 ^ Terminate

Bubbler

Posted 2019-10-19T13:29:19.077

Reputation: 16 616

1

Python 2, 10 bytes

print'ten'

Try it online!

Jonathan Allan

Posted 2019-10-19T13:29:19.077

Reputation: 67 804

1

Lua, 16 bytes

print('sixteen')

Try it online!

ouflak

Posted 2019-10-19T13:29:19.077

Reputation: 925

1

Retina 0.8.2, 5 bytes


five

Try it online! Simply substitutes the empty input with the word five, which is the first word to have one fewer letter than its value.

Neil

Posted 2019-10-19T13:29:19.077

Reputation: 95 035

1

BASIC, 6 bytes

?"SIX"

(Specifically tested in SmileBASIC: should work in most dialects, though ? is often expanded to PRINT, I think it's usually still stored as one byte)

12Me21

Posted 2019-10-19T13:29:19.077

Reputation: 6 110

1

Cascade, 9 bytes

"
n
i
n
e

Try it online!

Jo King

Posted 2019-10-19T13:29:19.077

Reputation: 38 234

1

Scheme, 5 bytes

This works in any Scheme implementation, but Chicken Scheme is what I used.

'five

EDIT: Alternative 4-byte solution

four outputs this:

Error: unbound variable: four

I think this counts, but if you don't like errors, the above solution is for you.

SYZYGY-DEV 333

Posted 2019-10-19T13:29:19.077

Reputation: 71

1

bit**, 30 bytes

#116/#104/#105/#114/#116/#121/

Try it online!

Night2

Posted 2019-10-19T13:29:19.077

Reputation: 5 484

1

PowerShell, 6 bytes

Note the space before the first quotation mark.

 "six"

Try it online!

gastropner

Posted 2019-10-19T13:29:19.077

Reputation: 3 264

1

Ruby, 9 bytes

puts:nine

Try it online!

Longer than the other answer, but does not output extra characters

G B

Posted 2019-10-19T13:29:19.077

Reputation: 11 099

1

Ceylon (Web IDE), 18 bytes

The Ceylon Web IDE allows to omit all the boilerplate which makes up a normal program, so we can use just the actual print statement:

print("eighteen");

Try it online!

Ceylon (with run function), 30 bytes

void run() { print("thirty");}

Try it online!

Paŭlo Ebermann

Posted 2019-10-19T13:29:19.077

Reputation: 1 010

1

Commodore BASIC (TheC64/Mini, C64/128, VIC-20, PET, C16/+4) 25 tokenised and BASIC bytes

 0 print"seventeen

I could use the abbreviated ? but when listed the program will show the full print keyword. In any case it would make no difference to the byte count as ? and print use the same number of BASIC tokens.

Shaun Bebbers

Posted 2019-10-19T13:29:19.077

Reputation: 1 814

1

Perl 5, 9 bytes

say"nine"

Try it online!

Chris

Posted 2019-10-19T13:29:19.077

Reputation: 1 313

1

T-SQL, 10 bytes

print'ten'

I guess is correct, right? :)

JuanCa

Posted 2019-10-19T13:29:19.077

Reputation: 169

What kind of SQL is this? I'm not aware of such a command/query, but I know you can do SELECT'fifteen'. – Night2 – 2019-10-21T17:45:49.137

1@Night2 It's Microsoft SQL Server. And yes, but that's 5 bytes more :P – JuanCa – 2019-10-21T18:01:24.153

you should probably make this T-SQL as the language – MickyT – 2019-10-21T20:53:22.640

@MickyT Thank you! – JuanCa – 2019-10-22T16:01:58.960

1

Cubix, 20 bytes

/o;."uytnewT.p^@!<..

Try it online!

This wraps onto the cube as follows

    / o
    ; .
" u y t n e w T
. p ^ @ ! < . .
    . .
    . .

Watch it run

  • "uytnewT open string and start pushing uytnewT onto the stack
  • "u close the string and u-turn onto the lower line
  • p bring the bottom of the stack to the top
  • <! beginning of the print loop and test for 0
    • @ halt if tested 0
    • ^y;/oe redirect up, no-op, pop TOS, reflect right, output character, no-op and then onto the beginning of the print loop

MickyT

Posted 2019-10-19T13:29:19.077

Reputation: 11 735

1

Erlang, 5 bytes

five.

Enter this code at interpreter prompt.

Yuri Ginsburg

Posted 2019-10-19T13:29:19.077

Reputation: 121

1

dc, 6 bytes

[six]P

prints:

six

Radovan Garabík

Posted 2019-10-19T13:29:19.077

Reputation: 437

1

Hexadecimal Stacking Pseudo-Assembly Language, 80 bytes

200079400000200074400000200068400000
200067400000200069400000200045400000
140000

Try it online!

Dorian

Posted 2019-10-19T13:29:19.077

Reputation: 1 521

1

Taxi, 164 bytes

"One hundred sixty four" is waiting at Writer's Depot.
Go to Writer's Depot:w 1 r 3 l 2 l.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 r 2 r 1 l.

Try it online!

This also throws an error because I don't return the taxi to the garage so my boss fires me. It's not a requirement to not throw errors, though, so I guess I'm fired.

Engineer Toast

Posted 2019-10-19T13:29:19.077

Reputation: 5 769

Yeah, that's all and well. – Andrew – 2019-10-22T14:52:00.127

Surely you can just.. remove the four – Jo King – 2019-10-22T22:55:01.003

@JoKing Ha! You're right. I'll fix that tomorrow. (And don't call me Shirley.) – Engineer Toast – 2019-10-22T23:57:25.560

1

Inform 7, 21 bytes

To q:say 21 in words.

This creates a function which takes no arguments and returns nothing, which prints the word "twenty-one".

Some boilerplate showing how to call the function:

X is a room.
When play begins: q.

Unfortunately, hardcoding the string tends to put me at a number of characters that's harder to print.

Draconis

Posted 2019-10-19T13:29:19.077

Reputation: 561

Does this output a hyphen? If so, that's against spec unfortunately. – boboquack – 2019-10-24T07:12:42.837

1

Python, 20 bytes

print("twenty")#lol.

hey! that's python code length is actually 20 characters. I know, It's cheating but the comment is still a text.

print("twenty") 

prints the number. (15 chars)

#lol.

a useless comment. (5 chars)

so 5+15=20 and 20 is twenty, right?

yarr33

Posted 2019-10-19T13:29:19.077

Reputation: 21

3Please include the byte count in your submission. There's no reason to think that comments are cheating. As a hint, can you think of a smaller number that has a longer word, but fits without the comments? – Jo King – 2019-10-23T06:25:49.230

Welcome to CGCC, I have updated your answer to include bytes count in the title and look better. If you like, you can use https://tio.run to provide an online working example of your code too. It also allows you to copy an auto generated answer with all the formatting ready to be posted. When you are done with your code, you can click on icon and copy "Code Golf submission (Stack Exchange)" section here to post as an answer.

– Night2 – 2019-10-23T08:42:34.917

1

Some answers with "production" (i.e. non-golfing) languages still not mentioned here:

C++ (clang), 55 bytes

#include<iostream>
int main(){std::cout<<"fifty five";}

Try it online!

Scala, 23 bytes

println("twenty three")

Try it online!

Haskell, 27 24 bytes

main=putStr"twenty four"

Try it online!

trolley813

Posted 2019-10-19T13:29:19.077

Reputation: 225

1For Haskell you could do main=putStr"twenty four" – Sara J – 2019-10-25T11:05:14.483

@SaraJ Thanks! Fixed. – trolley813 – 2019-10-25T11:12:26.927

2For all of these you can remove the digits part and just leave the fifty/twenty – Jo King – 2019-10-26T04:55:05.707

1

Tcl, 9 bytes

puts nine

prints

nine

Try it online!

Tcl, a lot more bytes (not finished yet) currently 42

this will read the source code counts the characters and convert the number into an actual number word.

content of c.tcl:

puts [string length [read [open c.tcl r]]]

prints:

% 42

Patrick Herda

Posted 2019-10-19T13:29:19.077

Reputation: 11

1

Runic Enchantments, 6 bytes

"Six"@

Try it online!

This ended up being both much shorter and much less interesting than I anticipated. 3 bytes are required for syntax, making it impossible to go lower.

Draco18s no longer trusts SE

Posted 2019-10-19T13:29:19.077

Reputation: 3 053

1

W, 5 bytes

five"

Implicitly prepends a quote. In order to specify your input, find prog.py and do this:

read = []

prog = 'five"'

Wren, 26 bytes

Just a method that outputs a string literal.

System.write("twenty six")

Try it online!

user85052

Posted 2019-10-19T13:29:19.077

Reputation:

The number of quotes in your first program is definitely not odd... – Hello Goodbye – 2019-11-18T15:02:25.800

W automatically "prepends" a quote z. – None – 2019-11-18T23:15:59.503

Ah, that makes sense. Interesting! – Hello Goodbye – 2019-11-19T20:39:28.763

0

MSM, 11 9 6 bytes

xsi/..

The 3 letters are pushed on the stack, / swaps s and i to get the correct (reverse) order and the two 3 dots concatenate them to a single string. There are variants such as '.xis. or ?..xis.

Try it online!

Edit: -3 bytes thanks to @Night2

nimi

Posted 2019-10-19T13:29:19.077

Reputation: 34 639

0

SWI-Prolog, 15 bytes

write(fifteen).

Try it online!

Anderium

Posted 2019-10-19T13:29:19.077

Reputation: 81

Ten: write(ten)? – Night2 – 2019-10-20T09:17:27.990

1Apparently that works in the online version :) But in the terminal versions, we have to close it with a dot. – Anderium – 2019-10-20T09:25:31.213

You can always limit your answer to a specific version. This is code golf, doesn't matter if the answer is not cross-compatible. – Night2 – 2019-10-20T13:53:59.147

0

Pyth, 5 bytes

"five

Try it online!

I don't think it's possible to get shorter than this. The overhead for compressed strings is 4 bytes already, so it's impossible to also get a 4-byte message in it.

randomdude999

Posted 2019-10-19T13:29:19.077

Reputation: 789

0

Husk, 3 bytes

¨◊ė

Try it online!

Fyr

Posted 2019-10-19T13:29:19.077

Reputation: 561

0

Java 8 (full program), 75 bytes

interface M{static void main(String[]a){System.out.print("seventy five");}}

Try it online.

Java 8 (lambda function), 9 bytes

v->"nine"

Try it online.

Java 5/6 (full program), 40 bytes

enum M{A;{System.out.print("forty");}}//

No online compiler, because I don't know any for Java 5 or 6..
The trailing // are no-ops, but outputting forty is shorter.

Kevin Cruijssen

Posted 2019-10-19T13:29:19.077

Reputation: 67 575

0

Pepe, 50 bytes

reeEEeeEEereeEEeEeeEreeEEeeEEereeEEEeEeereeEEEEeeE

Try it online!

RedClover

Posted 2019-10-19T13:29:19.077

Reputation: 719

0

C (gcc), 29 bytes

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

It's an actual program...

Try it online!

S.S. Anne

Posted 2019-10-19T13:29:19.077

Reputation: 1 161

0

pocki_c

Posted 2019-10-19T13:29:19.077

Reputation: 121

0

Gaia, 5 bytes

five”

Just a string literal that gets implicitly output.

Try it online!

Business Cat

Posted 2019-10-19T13:29:19.077

Reputation: 8 927

0

Java, 168 bytes

An all too trivial answer, I know. But I'm a noob.

System.out.println("thirtytwo");

Edit: Wow I just realized this does not have the right spacing!

I also wrote these map/reduce ones instead.

byte b[] = "One Hundred Sixty Seven".getBytes();
System.out.println(IntStream.range(0, b.length).mapToObj(x->new String(new byte[] {b[x]})).reduce((x, y)->x+y).get());
System.out.println(IntStream.range(0, 23).mapToObj(x->"One Hundred Twenty Five".substring(x,x+1)).reduce((x, y)->x+y).get());

In response to Jo King, I have added a method declaration.

public static void main(String[] args) { System.out.println(IntStream.range(0, 23).mapToObj(x->"One Hundred Sixty Eight".substring(x,x+1)).reduce((x, y)->x+y).get()); }

Disco Mike

Posted 2019-10-19T13:29:19.077

Reputation: 19

1I don't think any of these work without the boilerplate, which needs to be included – Jo King – 2019-10-27T12:10:32.853

You mean I need to put a function? Or the main method? Sorry I am new. – Disco Mike – 2019-10-27T14:31:09.907

It needs to be either a full program or a function. Only the last one is a function, though I don't think it counts as a serious attempt at golfing – Jo King – 2019-10-27T21:09:56.350

0

Malbolge, 30 bytes

('B;_#!~[|:9zVw/.uQrOqon&Jl6"'

Try it online!

Created with ZB3's Malbolge Tools

ceilingcat

Posted 2019-10-19T13:29:19.077

Reputation: 5 503

0

Underload, 6 bytes

Try it online! (six)S

Explanation

(six)  Puts the text "six" onto the stack.
S      Prints it.

Madison Silver

Posted 2019-10-19T13:29:19.077

Reputation: 139

0

Charcoal, 4 bytes

four

Try it online

The program just implicitly prints the string literal.

mabel

Posted 2019-10-19T13:29:19.077

Reputation: 1 489