38
\$\begingroup\$

Print or return the following string:

zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno

This is the first letter of each of the numbers zero, one, two, all the way up to one hundred.

Standard I/O rules apply, but the output must be exactly as shown above, optionally with a single trailing newline. No other variation in output is permitted. This is code golf, shortest code in bytes wins.


Note this has also been cross-posted to Anarchy Golf (by me)

\$\endgroup\$
10
  • 44
    \$\begingroup\$ I thought this was some fake German word. \$\endgroup\$
    – Oskar Skog
    Oct 5, 2022 at 6:16
  • 7
    \$\begingroup\$ @OskarSkog I would have bet on some real city in Iceland. :-p \$\endgroup\$
    – Arnauld
    Oct 5, 2022 at 9:13
  • 2
    \$\begingroup\$ Well then. Neither Oskar's comment nor Arnauld's were visible when I made my first one. I'd have likely phrased it a bit differently if I'd realized I'm essentially composing a verbose "me too." \$\endgroup\$
    – zedmelon
    Oct 5, 2022 at 18:40
  • 2
    \$\begingroup\$ @zedmelon c'est la vie. Enjoy your visit and marvel at the golfers :-) \$\endgroup\$ Oct 6, 2022 at 3:06
  • 9
    \$\begingroup\$ It does look like the concatenation of "Zott" (german dairy company), "fressen" (devour) and "entfesseln" (unleash). At least when you glance over the title :D \$\endgroup\$
    – QBrute
    Oct 6, 2022 at 7:40

34 Answers 34

23
\$\begingroup\$

Python, 58 bytes

a='ttffssen'
print(f"zo{a}te{a+''.join(x*10for x in a)}o")

Attempt This Online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Damn it, beat by Steffan because of the outage :( \$\endgroup\$ Oct 5, 2022 at 3:05
13
\$\begingroup\$

x86-64 machine code, 41 bytes

66 B8 7A 6F 66 AB 48 B8 74 74 66 66 73 73 65 6E 48 AB AA C6 07 65 AE 48 AB 6A 0A 59 F3 AA 48 C1 E8 08 75 F5 B0 6F 66 AB C3

Try it online!

Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string.

In assembly:

f:  mov ax, 'z' | 'o'<<8    # Put these two bytes in AX.
    stosw                   # Write them to the string, advancing the pointer.
    .byte 0x48, 0xB8        # Place the following eight bytes in RAX.
    .ascii "ttffssen"
    stosq                   # Write them to the string, advancing the pointer.
    stosb                   # Write the first byte 't' again, advancing the pointer.
    mov BYTE PTR [rdi], 'e' # Place the byte 'e' at the current output address.
    scasb                   # Advance RDI over the 'e' while comparing with AL.
    stosq                   # Write "ttffssen" again, advancing the pointer.
r:  push 10; pop rcx        # Set RCX to 10.
    rep stosb               # Write AL to the string 10 times, advancing the pointer.
    shr rax, 8              # Shift RAX right by 8 bits; AL (its low byte)
                            #  will be each of "ttffssen" in order.
    jnz r                   # Jump back, to repeat, if the result is nonzero.
    mov al, 'o'             # Set AL to 'o'.
    stosw                   # Write 'o' and a null byte, advancing the pointer.
    ret                     # Return.
\$\endgroup\$
12
\$\begingroup\$

Vyxal, 7 bytes

₁ʀ∆ċvhṅ

Try it Online!

₁ʀ∆ċvhṅ
₁ʀ      # Range [0, 100]
  ∆ċ    # Nth cardinal of each
    vh  # First char of each
      ṅ # Join together

Vyxal sMH, 4 bytes

ƛ∆ċh

Try it Online!

(thanks to lyxal)

sMH, why are there flags for everything

H flag  # Preset stack to 100
ƛ       # Map over 100
M flag  # Make that 100 be a range [0, 100] instead of [1, 100]
 ∆ċ     # Convert to cardinal
   h    # Get the first character
s flag  # Join together
\$\endgroup\$
3
  • \$\begingroup\$ 5 with the right set of flags: Try it Online! \$\endgroup\$
    – lyxal
    Oct 5, 2022 at 2:26
  • 2
    \$\begingroup\$ @lyxal I know, but I wanted a flagless solution. Might as well post though \$\endgroup\$
    – naffetS
    Oct 5, 2022 at 2:27
  • 8
    \$\begingroup\$ 4, if your flags represent how some people would respond to them: Try it Online! \$\endgroup\$
    – lyxal
    Oct 5, 2022 at 2:28
8
\$\begingroup\$

Factor + math.text.english, 39 bytes

[ 100 [0,b] [ number>text first ] map ]

Attempt This Online!

\$\endgroup\$
8
\$\begingroup\$

JavaScript (ES6), 57 bytes

Builds the output recursively from right to left.

f=(k=8)=>k>0?f(k-.1)+`${s}o`[~~k]:`zo${s="ttffssen"}te`+s

Try it online!

Note

Because of floating point errors, we don't reach exactly k = 0 on the last iteration. That's why we have to use the test k > 0 ? instead of just k ?.

This is still 1 byte shorter than the following integer version:

58 bytes

f=(k=81)=>k--?f(k)+`${s}o`[k/10|0]:`zo${s="ttffssen"}te`+s

Try it online!

\$\endgroup\$
6
\$\begingroup\$

Wolfram Language (Mathematica), 49 48 41 bytes

IntegerName@#~StringPart~1&~Array~100<>""

Try it online!

-1 thanks to Steffan

-7 thanks to att!

My Wolfram is rusty and was never great, so probably golfable, but it seemed like the right tool.

TIO shows an error because it can't connect to the internet, but it's still prints the correct answer.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ StringPart[#,1] => #~StringPart~1. The TIO error is because it uses mathematica's libraries and TIO doesn't have access to internet. \$\endgroup\$
    – naffetS
    Oct 5, 2022 at 2:43
  • \$\begingroup\$ Try it on Wolfram Cloud! (use this link if you're logged in and want to edit the code) \$\endgroup\$
    – naffetS
    Oct 5, 2022 at 2:46
  • \$\begingroup\$ @Steffan Thanks. I was surprised I couldn't use Part ([[) there to extract first char -- or that there was no other shortcut. \$\endgroup\$
    – Jonah
    Oct 5, 2022 at 2:47
  • 1
    \$\begingroup\$ Yep, Strings are atoms, and all the String... overhead is part of what makes golfing string-based challenges annoying. 41 bytes (or 46 explicitly printing). \$\endgroup\$
    – att
    Oct 5, 2022 at 3:51
6
\$\begingroup\$

brainfuck, 145 bytes

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

Try it online!

Commented code

--[----->+>+>+>+>+>+>+>+<<<<<<<<]    Set cell 0 to 254 and loop 102 times filling cells 1 to 8 with ascii f
++++++++[->++>+>>>++>++>>+<<<<<<<<]  Set cell 0 to 8 and loop 8 times boosting certain cells to give vnffvvfn 
>++++.                               Move to cell 1; boost and output z
>+.+++++..                           Move to cell 2; boost and output ott
>.>.>---.>---.>-.>.                  From cells 3 to 8 output ffssen modifying values as necessary
<<+.->.                              Move to cell 6; temporarily modify to output t; move to cell 7 to output e
[<]>------                           Move to cell 1 and modify from z to t; cells now contain ttffssen
[.>]                                 Move through ttffssen outputing each character once (12 to 19) until empty cell reached
<[<]>                                Move back to cell 1
[..........>]                        Move through ttffssen outputting each character 10 times (20 to 99) 
<+.                                  Move to cell 8; modify value to o and output 
\$\endgroup\$
5
\$\begingroup\$

Python 3, 68 bytes

print('zottffssentettffssen'+'t'*20+'f'*20+'s'*20+'e'*10+'n'*10+'o')

Try it online!

I'm sure this isn't optimal. Idk.

\$\endgroup\$
5
\$\begingroup\$

sed, 59 bytes

s/^/ttffssen/
s/./&&&&&&&&&&/g
s/.*/zottffssentettffssen&o/

Attempt This Online!

\$\endgroup\$
5
\$\begingroup\$

R + english, 48 50

Edited per Dominic van Essen's comment

cat(substr(english::as.english(0:100),1,1),sep="")

Similar to chunes' answer, this solution uses a library / package to handle integer-to-English mapping, then parses and collapses the resulting vector.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Welcome to Code Golf! \$\endgroup\$ Oct 7, 2022 at 20:45
  • 1
    \$\begingroup\$ Welcome from me, too. You can shorten the code a bit by using cat(,sep="") instead of paste(,collapse=""), but unfortunately it's generally required to include the code to load a library in the byte-count (using library() or ::), like this... \$\endgroup\$ Nov 1, 2022 at 10:23
  • \$\begingroup\$ @DominicvanEssen thanks for the tips! \$\endgroup\$
    – acvill
    Nov 1, 2022 at 16:26
5
\$\begingroup\$

Arturo, 110 65 63 bytes

  • -45 bytes, -2 bytes thanks to Krenium
s:"ttffssen"print~{zo|s|te|s||join map split s=>[repeat&10]|o}

Readable version:

s: "ttffssen"
print ~{zo|s|te|s||join map split s => [repeat&10]|o}

Try it Online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to CGCC, and nice first answer! \$\endgroup\$
    – xigoi
    Feb 26, 2023 at 12:07
  • \$\begingroup\$ Great job! Well done! \$\endgroup\$ Feb 27, 2023 at 9:46
4
\$\begingroup\$

Pyth, 29 bytes

s["zo"J"ttffssen""te"Js*LTJ\o

Attempt This Online!

A near literal translation of 97.100.97.109's Python solution.

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

Ruby, 54 bytes

puts"zo#{a="ttffssen"}te#{a+a.chars.map{|c|c*10}*''}o"

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Python 2, 53 bytes

Identical to my (and @xnor's, presumably) Python solution to the cross-post on Anarchy Golf.

s='ttffssen'
print'zo%ste'%s+s+(('o'+s*10)*8)[-8::-8]

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I really like the idea of mul + slicing to repeat each character. \$\endgroup\$
    – Sisyphus
    Oct 7, 2022 at 0:19
4
\$\begingroup\$

Perl 5, 40 bytes

say+zo,$_=ttffssen,te.$_.s/./$&x10/gre.o

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Can shave a byte by using commas instead of dots: Try it online! \$\endgroup\$
    – Xcali
    Oct 5, 2022 at 13:44
  • \$\begingroup\$ @Xcali – nice! one byte shaved. \$\endgroup\$
    – Kjetil S
    Oct 6, 2022 at 2:09
  • 1
    \$\begingroup\$ 'zo' can be +zo. \$\endgroup\$ Oct 7, 2022 at 0:46
  • \$\begingroup\$ @dingledooper – sure can! thanks \$\endgroup\$
    – Kjetil S
    Oct 7, 2022 at 13:49
4
\$\begingroup\$

C (clang), 106 \$\cdots\$ 77 75 bytes

f(i){for(i=0;i<101;i++)putchar("zottffssentettffssen"[i>99?:i<20?i:i/10]);}

Try it online!

Saved a whopping 22 28 30 bytes thanks to jdt!!!
Saved a byte thanks to ceilingcat!!!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ @jdt Oops, well spotted - thanks! :D \$\endgroup\$
    – Noodle9
    Oct 9, 2022 at 12:06
4
\$\begingroup\$

Lua, 68 bytes

a='ttffssen'print('zo'..a..'te'..a..a:gsub('.',('%1'):rep(10))..'o')

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Bash 5.2, 45 43 bytes

-2 bytes thanks to Sisyphus

ttffssen
echo zo$_\te$_${_//?/&&&&&&&&&&}o

Uses the brand new (set-by-default) shell option patsub_replacement! Look forward to seeing this in many a future Bash golf.

ATO is still on 5.1 at the time of writing, so if you want to try it out yourself, the easiest way is with alpine:edge:

#!/bin/sh
podman run --rm -i alpine:edge << 'EOF'
apk add bash >/dev/null
bash -c 'ttffssen;echo zo$_\te$_${_//?/&&&&&&&&&&}o'
EOF
\$\endgroup\$
2
  • 1
    \$\begingroup\$ I don't have bash 5.2 at hand, but I think removing the x= and using the topic variable $_ should work. \$\endgroup\$
    – Sisyphus
    Oct 5, 2022 at 4:45
  • \$\begingroup\$ That it does! I have a tendency to forget that one, since <<<$_ in Zsh always outputs cat. \$\endgroup\$ Oct 5, 2022 at 4:48
3
\$\begingroup\$

Japt, 29 26 bytes

`zottffÑA`
+h`` +¢®pAÃ+'o

Test it

Note that there is an unprintable character between the `` on line 2

`zottffÑA`     # U = "zottffssen"
               # Start building the output with U implicitly
 h``           # Replace the first 2 characters of U with "te"
+              # Add that to the output
      ¢        # Remove the first 2 characters of U
       ®  Ã    # For each remaining character
        pA     #  Duplicate it 10 times
     +         # Add that to the output
           +'o # Add "o" to the output
               # Print implicitly

I also tried another version which does "U repeated 10 times, grouped by index % 8, then joined" for the 20-99 portion, but it didn't golf as well

\$\endgroup\$
2
  • \$\begingroup\$ 26 bytes \$\endgroup\$
    – Shaggy
    Oct 6, 2022 at 13:40
  • \$\begingroup\$ @Shaggy Nice, I always struggle to find ways to make the interpreter insert U for me. \$\endgroup\$ Oct 6, 2022 at 15:11
3
\$\begingroup\$

Excel, 77 71 bytes

Saved 6 bytes thanks to JvdV

=LET(a,"ttffssen",CONCAT("zo",a&"te"&a,REPT(MID(a,ROW(1:8),1),10),"o"))

This is only slightly more efficient than just typing the 101 characters manually.

  • LET(a,"ttffssen" stores the string ttffssen for later repeated use.
  • CONCAT("zo",a&"te"&a combines strings to make the first part. This is only 2 bytes more efficient than hard-coding it.
  • MID(a,ROW(1:8),1) turns the 8 character string into an array of 8 characters.
  • REPT(MID(~),10) repeats each of those characters 10 times. These last two lines are the big byte-saver I missed the first time. Storing the string as a is not efficient by itself but it is if you later re-use it in the REPT() function.
  • CONCAT(~,~,~,"o") add the last letter to the rest of the bits.

Original 77 byte version:

="zottffssentettffssen"&CONCAT(REPT({"t","f","s","e","n"},5*{4,4,4,2,2}))&"o"

This 78 byte alternative looked like it'd be shorter since each character is repeated the same number of times (allowing you to replace an array with a single integer) but it's only a close second:

="zottffssentettffssen"&CONCAT(REPT({"t","f","s"},20))&"eeeeeeeeeennnnnnnnnno"

This 79 byte alternative was an attempt at compressing that array of characters but the savings where offset by the bytes required to convert them to strings:

="zottffssentettffssen"&CONCAT(REPT(CHAR(101+{15,1,14,0,9}),5*{4,4,4,2,2}))&"o"
\$\endgroup\$
2
  • \$\begingroup\$ ++. I gave it a shot and ended up with =LET(a,"ttffssen",CONCAT("zo",a&"te"&a,REPT(MID(a,ROW(1:8),1),10),"o")) which would be 71 bytes. I guess it's the Excel equivalent to the most voted answer so far =) \$\endgroup\$
    – JvdV
    Oct 7, 2022 at 8:25
  • \$\begingroup\$ You can save 1 byte by changing REPT(MID(a,ROW(1:8),1),10) to MID(a,LEFT(ROW(10:89)),1) \$\endgroup\$
    – Axuary
    Apr 11, 2023 at 17:18
3
\$\begingroup\$

Tcl, 301 57 bytes

saved bytes thanks to the comment of @Sisyphus

Golfed version provided by me, try it online!

puts zo[set x ttffssen]te$x[regsub -all . $x &&&&&&&&&&]o

Original ungolfed version

set a "ttffssen"

proc repeat_string {str count} {
    set result ""
    for {set i 0} {$i < $count} {incr i} {
        append result $str
    }
    return $result
}

proc generate_string {a} {
    set result ""
    foreach char [split $a ""] {
        append result [repeat_string $char 10]
    }
    return $result
}

puts "zo${a}te${a}[generate_string $a]o"
puts "zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno"
\$\endgroup\$
1
  • \$\begingroup\$ Nice. I think you can use a regsub to get much shorter - Try it online! \$\endgroup\$
    – Sisyphus
    Apr 12, 2023 at 1:59
2
\$\begingroup\$

05AB1E, 23 bytes

.•p≠²δK•ÐST×JŠ"zoÿteÿÿo

Port of @97.100.97.109's Python answer, so make sure to upvote him/her as well!

Try it online.

Explanation:

.•p≠²δK•           # Push compressed string "ttffssen"
 Ð                 # Triplicate it
  S                # Convert the top copy to a list of characters
   T×              # Repeat each character 10 times as string
     J             # Join these back together to a single string
      Š            # Triple-swap so the other two strings are on top
       "zoÿteÿÿo  "# Push string "zoÿteÿÿo", where the `ÿ` are automatically filled with
                   # the three strings
                   # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•p≠²δK• is "ttffssen".

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

Retina 0.8.2, 44 bytes


zo_te_20$*t20$*f20$*s10$*e10$*no
_
ttffssen

Try it online! Link is to verbose version of code. Explanation: Mostly run-length compression via $*, with a final substitution to save a further 3 bytes.

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

Charcoal, 22 bytes

≔ttffssenθzoθteθFθ×ιχo

Try it online! Link is to verbose version of code. Explanation:

≔ttffssenθ

Save the first letters of two/twelve/twenty, three/thirteen/thirty, four(teen)/forty, five/fifteen/fifty, six(teen/ty), seven(teen/ty), eight(een/y) and nine(teen/ty) in a variable.

zo

Output the first letters of zero and one.

θ

Output the first letters of two to nine.

te

Output the first letters of ten and eleven.

θ

Output the first letters of twelve to nineteen.

Fθ

Loop over the first letters of twenty to ninety.

×ιχ

Output each letter repeated ten times.

o

Output the first letter of one [hundred].

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

simply, 64 bytes

Just uses the same method as plenty of answers.

out"zo"$A="ttffssen""te"$A;each$A as$v;for$_ in0..9out$v;out'o'

Outputs the expected string, without any trailing whitespace.

Ungolfed

Extremely verbose, almost looking like pseudo-code:

Set $initials to the value "ttffssen".
Show the values "zo", $initials, "te", $initials.

Loop through $initials as $letter.
Begin.
    Loop from 0 to 9 as $i.
    Begin.
        Show the contents of $letter.
    End.
End.

Show the value "o".

More code-y looking:

$initials = "ttffssen";
echo "zo", $initials, "te", $initials;

each $initials as $letter {
    for $i in 0..9 {
        echo $letter;
    }
}

echo "o";

All versions do exactly the same.

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

MathGolf, 19 18 bytes

╢├╕◄ε╕f♣+∙╢►@♂m*'o

Try it online.

Explanation:

╢├        # Push compressed "zo"
╕◄ε       # Push compressed "ttff"
   ╕f♣    # Push compressed "ssen"
      +   # Append the top two together: "ttffssen"
       ∙  # Triplicate it
╢►        # Push compressed "te"
  @       # Triple-swap the top three values (a,b,c to c,a,b)
 m        # Map over the characters of the top "ttffssen":
♂ *       #  Repeat the character 10 times
'o       '# Push character "o"
          # (after which the entire stack is joined and output implicitly as result)
\$\endgroup\$
2
\$\begingroup\$

PowerShell, 56 bytes

"zo$(($a='ttffssen'))te$a$(-join($a|% T*y|%{"$_"*10}))o"

Try it online!

"zo                                                    " # start s new string with "zo"
   $(               )                                    # evaluate the subexpression $(...), which ...
     ($a='ttffssen')                                     # ... sets $a to "ttffssen", and outputs it straight back into the string (because of the additional brackets)
                     te                                  # literal "te"
                       $a                                # insert $a ("ttffssen")
                         $(                          )   # insert the results of another subexpression $(...)
                                 $a|% T*y                # pipe $a to % (alias for ForEach-Object) and call the member ToCharArray()
                                         |%{       }     # pipe the single characters to % and process them in the scriptblock {...}; loop variable is $_
                                            "$_"*10      # turn the char back into a string, and "multiply" it with 10
                           -join(                   )    # join those 10-char-long strings together
                                                      o  # Add the final "one hundred"

Output is implicit.

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

Java (JDK), 92 bytes

Interesting challenge!

()->{var s="ottffssente";for(int i=0;i<90;)s+=++i==9?"":s.charAt(i<9?i:i/10%9);return"z"+s;}

Try it online!


I'm really glad that it was possible to beat the trivial solution :') (95 bytes) :

()->"zottffssentettffssen"+"t".repeat(20)+"f".repeat(20)+"s".repeat(20)+"eeeeeeeeeennnnnnnnnno"
\$\endgroup\$
1
\$\begingroup\$

Japt, 22 bytes

`zo{=`ttffÑA`}{+mpA}o

Test it

`zo{=`ttffÑA`}\x92{+mpA}o
`zo                     o     :Compressed string, starting with "zo" and ending with "o"
   {                          :Interpolate
    =                         :  Assign to variable U
     `ttffÑA`                 :  Compressed string "ttffssen"
             }                :End interpolation
              \x92            :Compressed "te"
                  {    }      :Interpolate
                   +          :  Append to U
                    m         :  Map each character in U
                     p        :    Repeat
                      A       :    Ten times
\$\endgroup\$
1
\$\begingroup\$

Oracle SQL, 97 bytes

select 'z'||listagg(substr(to_char(to_date(level,'J'),'jsp'),1,1))from"DUAL"connect by level<=100

Or, a bit more readable:

select
   'z' ||
   listagg(
      substr(
         to_char(to_date(level, 'J'), 'jsp')
         ,1,1)
      )
from
  "DUAL"
connect by
   level<=100;
\$\endgroup\$

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.