-12
\$\begingroup\$

Following this question: Tut-tut-tut-tut-tut

Write a program that writes "tut-tut-tut" without using the characters "t", "u" or "-" in the code itself.

This is code golf, shortest code in bytes wins.

\$\endgroup\$
5
  • 10
    \$\begingroup\$ In general, "Do X without Y" questions are not very well received due to being overused. I highly suggest you use the Sandbox next time. \$\endgroup\$
    – Seggan
    Commented Sep 19, 2022 at 22:07
  • \$\begingroup\$ What makes this challenge, fundamentally, different rom the original? The vast majority of answers there will be able to use trivial workarounds to replace t/u/-, such as using code points. \$\endgroup\$ Commented Sep 19, 2022 at 22:22
  • 2
    \$\begingroup\$ see this meta for more information \$\endgroup\$ Commented Sep 19, 2022 at 22:24
  • \$\begingroup\$ Borderline dupe of around a dozen challenges listed here. \$\endgroup\$
    – Bubbler
    Commented Sep 19, 2022 at 23:43
  • \$\begingroup\$ Can I use non-ascii t's like superscript ? \$\endgroup\$
    – Bubbler
    Commented Sep 21, 2022 at 3:55

8 Answers 8

3
\$\begingroup\$

Japt, 9 bytes

Bî`¡s,`cÄ

Test it

Bî`¡s,`cÄ
B             :11
 î            :Repeat to length B
  `¡s,`       :  Compressed string "sts,"
       c      :  Map charcodes
        Ä     :    Add 1
\$\endgroup\$
3
\$\begingroup\$

Windows Batch, 169 115 bytes

No code points, but assuming capital letters are OK for the output, as this will produce TuT-TuT-TuT

@for /f %%a in ('sc^|find "CO"') do @se%OS:~9% q=%%a
@se%OS:~9% a=%q:~8,1%%OS:~9%%q:~6,1%%OS:~9%
@echo %a:~1%%a%%a%

Length calculated by using Unix/LF as EOL, without an EOL at the end of the last line.

Shaved of 54 bytes thanks to @jdt, who posted a solution using code points (which I wanted to avoid), but contained three ts. Thinking about ways to fix this made me have another go at mine as well.

The first issue with Batch is that you can't even set a variable without using a t.
But Batch will expand variables in a command first and then take the resulting line verbatim, so the forbidden characters can be picked from a variable. As luck would have it, there is a default environment variable with only two letters, and it even has the T at the last position (allowing to drop the substring length when extracting the T): OS=Windows_NT.
So a T in a command line can be replaced by %OS:~9%, which solves most of the problems; but no such luck for U or -.

@for /f %%a in ('sc^|find "CO"') do @se%OS:~9% q=%%a
This will use the help for sc.exe, find the line continue--------Sends a CONTINUE control request to a service., break it into tokens at spaces (discarding empty fields), and set the variable q to continue--------Sends, where u and - are at single-digit positions.

@se%OS:~9% a=%q:~8,1%%OS:~9%%q:~6,1%%OS:~9%
This sets a to -TuT by picking characters from OS and q.

@echo %a:~1%%a%%a%
This prints a three times, with the first instance %a:~1% starting with the second character to remove the leading -.


Alternative answer by @jdt, 118 bytes

@for %%a in (84,85,84,45,84,85,84,45,84,85,84) do @(cmd /C exi%OS:~9% %%a&echo|se%OS:~9% /p=%%^=Exi%OS:~9%CodeAscii%%)

@jdt posted this in a comment for initially 110 bytes, but it used exit, set, and ExitCodeAscii in the original. Replacing the ts with %OS:~9% brought it to 128, some more golfing brought it down to a one-liner with 118 bytes.



Previous version

@for /f %%a in ('help^|find "SE%OS:~9,1% "') do @%%a s=%%a 
@for /f "delims=" %%a in ('wmic/?^|find "/E"') do @%s%q=%%a
@%s%a=%q:~10,1%%q:~3,1%%q:~1,1%%q:~3,1%
@echo %a:~1%%a%%a%

Used the line SET Displays, sets, or removes Windows environment variables. of the help output to set a variable to SET . Above is the "safe" version (178 bytes) that should work with localized versions as well. In the optimized version for English versions of cmd.exe only (otherwise the first line might run some unexpected commands, and/or not work at all), the first line changes to this, for a total of 169 bytes:
@for /f %%a in ('help^|find "s e"') do @%%a s=%%a (this line ends with a trailing space!)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 110 byte I'm sure this can be golfed futher :-) \$\endgroup\$
    – jdt
    Commented Sep 27, 2022 at 17:12
  • \$\begingroup\$ @jdt I spy with my little eye something that looks like a t in exit, set, and ExitCodeAscii ;-). Fixed it for 128, then golfed it down to a one-liner with 118 bytes; see above. \$\endgroup\$
    – user314159
    Commented Sep 28, 2022 at 22:54
  • \$\begingroup\$ Cool! It reminds me of this answer from years ago. \$\endgroup\$
    – jdt
    Commented Sep 29, 2022 at 1:47
2
\$\begingroup\$

BQN, 11 bytesSBCS

11⥊"rsr+"+2

"rsr+"+2 add 2 to the code points of "rsr+" giving "tut-"

11⥊ cyclically reshape to length 11

Run online!

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

PowerShell (Core or Windows), 46 bytes

No code points; taking advantage of the long cmdlet names for a change ...

$ofs='';"$((gal oh|% R*e)[3,2,1,2])"*3|% S*g 1

Try it online!

$ofs='';                                       # set the output field separator to an empty string     
            gal oh                             # gal is an alias for Get-Alias; oh is an alias for Out-Host; returns an AliasInfo object
                  |% R*e                       # pipe the AliasInfo object for "oh" to % (an alias for ForEach-Object), and call its member ResolvedCommandName, which will return the string "Out-Host"
           (            )[3,2,1,2]             # take the characters at positions 3, 2, 1, 2 from "Out-Host" (-, t, u, t)
        "$(                       )"           # evaluate that in a subexpression $() and stuff it all into a single string "-tut"
                                    *3         # "multiply" with 3 to get "-tut-tut-tut"
                                      |% S*g 1 # pipe that to ForEach-Object again, and call its member "SubString" to get everything starting at position 1
\$\endgroup\$
3
  • \$\begingroup\$ Your code begins with -, which is one of the banned characters. \$\endgroup\$
    – Dingus
    Commented Sep 20, 2022 at 23:16
  • \$\begingroup\$ OK, that was way too exposed to be noticed. Let's see ... \$\endgroup\$
    – user314159
    Commented Sep 20, 2022 at 23:28
  • \$\begingroup\$ Fixed; thanks for noticing, @Dingus \$\endgroup\$
    – user314159
    Commented Sep 20, 2022 at 23:54
2
\$\begingroup\$

Python 2.7 and 3.xx, 45 44 bytes

This was harder and easier than I though...

exec('prin\x74(("\x2d\x74\x75\x74"*3)[1:])')

I've tested it on Python 2.7.11+, 3.9.6 and 3.10.5.

Good 'ol evil eval exec to the rescue!


Thanks to @Dingus for pointing out a mistake, and @Bubbler for saving 1 byte.



Alternative answers

Personally, I feel these are against the spirit of the challenge, and that's why they aren't replacing the "main" answer.

Python 2.7 and 3.xx, 40 bytes

This is an alternative provided by @Bubbler.
It uses "TUT" instead of "tut", for the string, saving 1 byte.
I modified a little, to save 3 more bytes.

exec('prinT(("\x2dTUT"*3)[1:])'.lower())

This was edited to use exec to run in Python 2.7.

Python 2.7 and 3.xx, 40 bytes

This alternative was written by @py3programmer.
It produces the correct output, and avoids the [1:] string indexing.

exec("prinT('TUT\x2d'*2+'TUT')".lower())
\$\endgroup\$
5
  • \$\begingroup\$ -1 isn't allowed (~0 is an easy fix). \$\endgroup\$
    – Dingus
    Commented Sep 20, 2022 at 23:12
  • \$\begingroup\$ Or bring \x2d to the front and do [1:] for -1 byte, and it also seems that 'TUT'.lower() is 1 byte shorter than \x74\x75\x74. \$\endgroup\$
    – Bubbler
    Commented Sep 21, 2022 at 3:59
  • \$\begingroup\$ @Dingus Fixed it, thank you. @Bubbler I found a solution that saves 4 bytes, using 'prinT(("\x2dTUT"*3)[1:])'.lower() instead of 'TUT'.lower(). However, I feel this goes against the spirit of the challenge. While (strictly speaking) it doesn't break the rules at all, and must be a valid solution, I just feel like it is a little ... iffy... dirty... skirting in a gray area... \$\endgroup\$ Commented Sep 21, 2022 at 6:51
  • 1
    \$\begingroup\$ We could also use exec("prinT('TUT\x2d'*2+'TUT')".lower()), as it also has 40 bytes. \$\endgroup\$ Commented Sep 21, 2022 at 15:31
  • \$\begingroup\$ @py3programmer Thank you! Didn't knew that exec existed. I replaced all instances of eval with exec and the code now runs in Python 2.7. I've added it as an alternative answer as well, with credits to you. \$\endgroup\$ Commented Sep 21, 2022 at 20:13
2
\$\begingroup\$

C (clang), 51 bytes

i;f(*b){for(i=0;i<4;b[i++]=i^3?762606932:7632244);}

Try it online!

C (clang), 69 63 bytes

f(){syscall(1,1,L"\x2d747554\x2d747574\x2d747574\x747574",15);}

Try it online!

-6 bytes thanks to ceilingcat!!

\$\endgroup\$
1
1
\$\begingroup\$

Ruby, 70 bytes

p"#{[116,117,116,45,116,117,116,45,116,117,116].map{|c|c.chr}.join()}"

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ 60 bytes \$\endgroup\$
    – jdt
    Commented Sep 26, 2022 at 18:51
1
\$\begingroup\$

05AB1E, 12 bytes

Four different alternatives:

…TUTl45ç«11∍
.•x`•45ç«11∍
'±È3£45ç«6∍û
"vwv/"ÇÍç6∍û

Try it online.

Without the it would have been just 3 bytes shorter:

"tut-"11∍

Try it online.

Explanation:

Part 1 alternatives:

…TUT       # Push string "TUT"
    l      # Convert it to lowercase
     45    # Push 45
       ç   # Convert it to a character with this codepoint: "-"
        «  # Append the two together: "tut-"

.•x`•      # Push compressed string "tut"
     45ç«  # Same as above

'±È       '# Push dictionary string "tutorial"
   3£      # Only keep its first 3 characters: "tut"
     45ç«  # Same as above

"vwv/"     # Push string "vwv/"
      Ç    # Convert it to a list of its codepoint-integers: [118,119,118,47]
       Í   # Decrease each by 2
        ç  # Convert it from codepoint-integers to a list of characters

Part 2 alternatives:

11∍        # Extend it to size 11: "tut-tut-tut"
           # (after which the result is output implicitly)

6∍         # Extend it to size 6: "tut-tu"
  û        # Palindromize it: "tut-tut-tut"
           # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress strings not part of the dictionary?) to understand why .•x`• is "tut" and '±È is "tutorial".

\$\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.