67
\$\begingroup\$

We all know the classic dad joke that goes something like this:

  1. Somebody says a sentence to describe their self (e.g. I'm tired or I'm confused).

  2. A dad-joke enthusiast comes along and replies Hi <adjective>, I'm Dad!, because introductions follow the same format (I'm Peter follows the same format as I'm hungry).

Your job is to take in an input in the form of a self-descriptor, and output the appropriate dad-joke form, but instead of using the word "Dad", you'll use the name of the programming language you're programming in.

Test cases (assume that they are being parsed by Python):

I'm amazing                  Hi amazing, I'm Python!
I'm tired                    Hi tired, I'm Python!
I'm hungry                   Hi hungry, I'm Python!
I'm fat                      Hi fat, I'm Python!

Now assume that these test cases are being parsed by Golfscript:

I'm a programmer             Hi a programmer, I'm Golfscript!
I'm a question-writer        Hi a question-writer, I'm Golfscript!
I'm a Stack-Overflow-er      Hi a Stack-Overflow-er, I'm Golfscript!

The exact challenge:

  1. Take in a string in the self-descriptor format (I'm <adjective> or I'm a(n) <noun>) using standard input or through a function.
  • Assume there is no ending punctuation.

  • Assume the word I'm is used and not I am.

  1. Convert it to a dad-joke format - see the above examples for exactly how that should look.

Other stuff:

\$\endgroup\$
15
  • 51
    \$\begingroup\$ One of the ways I considered telling my family that my wife was expecting was by telling as many dad jokes as possible and seeing who caught on! \$\endgroup\$
    – Giuseppe
    Commented May 21, 2019 at 0:54
  • 9
    \$\begingroup\$ Some example outputs end with exclamation and some do not. What is the significance? \$\endgroup\$
    – recursive
    Commented May 21, 2019 at 1:56
  • 11
    \$\begingroup\$ Usual practice is to give it much longer before accepting an answer, if you do so at all: codegolf.meta.stackexchange.com/q/2035/66252 \$\endgroup\$ Commented May 21, 2019 at 10:58
  • 9
    \$\begingroup\$ And the tie-breaker isn't votes, it's who reached the lowest score first. \$\endgroup\$
    – Shaggy
    Commented May 21, 2019 at 12:08
  • 9
    \$\begingroup\$ Now waiting for the next golfing language that's name is an empty string. \$\endgroup\$
    – 640KB
    Commented May 21, 2019 at 18:24

103 Answers 103

3
\$\begingroup\$

QuadR, 22 bytes

^...
$
Hi
, I'm QuadR!

Try it online!

This replaces:

^... three initial characters
and
$ the end-of-line

with

Hi
and
,I'm QuadR
respectively

\$\endgroup\$
3
  • \$\begingroup\$ So you could exchange the middle two lines and change the language to Retina and still beat @KevinCruijssen's answer? \$\endgroup\$
    – Neil
    Commented May 21, 2019 at 12:28
  • \$\begingroup\$ @Neil I guess so, but your's is still shorter. Tbf, QuadR is but a thin cover for the not-intended-for-golf ⎕R APL operator. \$\endgroup\$
    – Adám
    Commented May 21, 2019 at 15:22
  • \$\begingroup\$ Ah, but my answer only works for Retina 1, not Retina 0.8.2 though. \$\endgroup\$
    – Neil
    Commented May 21, 2019 at 15:35
3
\$\begingroup\$

Retina, 22 21 bytes

3L$`
Hi$', $` Retina!

Try it online! Link includes test cases. Does not work in Retina 0.8.2, so adapt @Adám's QuadR answer instead. Explanation: The pattern is empty, so it matches at every position in the input string. We only need the third (or fourth would work) match however. The substitution is then applied to that match. Within that substitution, $' refers to the rest of the string and $` refers the the beginning of the string.

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

Retina 0.8.2, 26 25 23 bytes

^...
Hi
$
, I'm Retina!

-1 byte thanks to @attinat.
-2 bytes by porting @Adám's QuadR answer, so make sure to upvote him!!

PS: @Neil posted a shorter Retina answer in the new version, so I've changed this answer to Retina 0.8.2 explicitly.

Try it online.

Explanation:

Replace the first three characters with "Hi":

^...
Hi

And then append a trailing ", I'm Retina!" (by replacing the end of the string):

$
, I'm Retina!
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Shouldn't it be like this instead? \$\endgroup\$
    – att
    Commented May 21, 2019 at 8:06
  • 2
    \$\begingroup\$ or better, 25 bytes \$\endgroup\$
    – att
    Commented May 21, 2019 at 8:09
  • \$\begingroup\$ @attinat Ah, of course, hadn't even noticed the incorrect output.. >.> And thanks for the -1! \$\endgroup\$ Commented May 21, 2019 at 8:43
3
\$\begingroup\$

bash, 24 bytes

echo Hi ${@:2}, $1 bash!

TIO

\$\endgroup\$
2
  • \$\begingroup\$ replace bash with $0 to save a couple of bytes \$\endgroup\$
    – roblogic
    Commented May 23, 2019 at 1:04
  • 1
    \$\begingroup\$ @roblogic, $0 would print script name or running bash -c 'echo Hi ${@:2}, $1 $0!' bash $@ but should count in size \$\endgroup\$ Commented May 23, 2019 at 18:16
3
\$\begingroup\$

Javascript (Node.js in TIO), 60 bytes

s=>"Hi"+s.slice(3)+", I'm J"+process.argv[0].slice(6,15)+"!"

Try it online

\$\endgroup\$
4
  • \$\begingroup\$ javascript is shorter than "+process.argv[0].slice(5,15)+" \$\endgroup\$ Commented May 21, 2019 at 9:28
  • 3
    \$\begingroup\$ @NahuelFouilleul yes, but +process.argv[0].slice(5,15)+ is more fun ;-) \$\endgroup\$
    – jdt
    Commented May 21, 2019 at 9:37
  • 2
    \$\begingroup\$ The consensus on language names is that we must use proper casing - JavaScript, not javascript. \$\endgroup\$
    – Shaggy
    Commented May 21, 2019 at 12:10
  • \$\begingroup\$ @Shaggy, point taken. \$\endgroup\$
    – jdt
    Commented May 22, 2019 at 5:03
3
\$\begingroup\$

VSL, 51 bytes

fn f(s:String){print("Hi "+s[from:4]+", I'm VSL!")}

Glad VSL can now participate in some golfs :)

Try it online! (doesn't have latest VSL so might not work just yet)

\$\endgroup\$
2
  • \$\begingroup\$ Are you doing much with Teascript these days? It was a cool project,.. \$\endgroup\$
    – roblogic
    Commented May 24, 2019 at 4:31
  • 1
    \$\begingroup\$ @roblogic unfortunately not anymore. I ended up adding most of its better features (unicode shortcuts, compression) to Japt so now that's generally always the better choice \$\endgroup\$
    – Downgoat
    Commented May 24, 2019 at 4:38
3
\$\begingroup\$

Ed, 30 bytes

I couldn't leave a sed answer without an ed answer!

%s/I'm\(.*\)/Hi\1, I'm ed!
wq

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I prepended a “#” to your post's first line to turn it into heading, so the Leaderboard script be able to parse it and list it. Funny choice for the link, though I'm sure some readers would be happier with something more informative. \$\endgroup\$
    – manatwork
    Commented May 23, 2019 at 15:41
  • 1
    \$\begingroup\$ Thank you, manatwork. gnu.org/software/ed would be a reasonable place to go to learn more about ed. \$\endgroup\$ Commented May 23, 2019 at 15:48
3
+100
\$\begingroup\$

Knight, 24 bytes

O++'Hi 'P", I'm Knight!"

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ The input is supposed to be in the form I'm <something>, not just the word. You have to do something like O++'Hi 'G=pP4Lp", I'm Knight!" instead. \$\endgroup\$
    – Aiden Chow
    Commented Oct 19, 2022 at 2:41
  • \$\begingroup\$ @AidenChow You can use 3 instead of 4 and omit the space after Hi. \$\endgroup\$
    – naffetS
    Commented Oct 19, 2022 at 2:42
  • \$\begingroup\$ @Sʨɠɠan True! (filler) \$\endgroup\$
    – Aiden Chow
    Commented Oct 19, 2022 at 2:42
3
\$\begingroup\$

Bash, 32 Bytes

read i;echo Hi${i:3}, I\'m Bash!

Try it online

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

Haskell, 34 bytes

f x="Hi"++drop 3x++", I'm Haskell"

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ The comma is required \$\endgroup\$
    – emanresu A
    Commented Aug 28, 2022 at 6:45
2
\$\begingroup\$

Red, 39 bytes

func[s][rejoin["Hi"at s 4", I'm Red!"]]

Try it online!

\$\endgroup\$
6
  • 1
    \$\begingroup\$ I think Red[]rejoin["Hi"at read 4", I'm Red!"] is a valid 38-byte full program. \$\endgroup\$
    – Wezl
    Commented Feb 19, 2021 at 14:52
  • \$\begingroup\$ @Wezl I think read expects exactly one argument - Reads from a file, URL, or other port, in your case it would be 4. \$\endgroup\$ Commented Feb 19, 2021 at 17:13
  • \$\begingroup\$ oh, but is there a shorter function that would work? \$\endgroup\$
    – Wezl
    Commented Feb 19, 2021 at 17:14
  • \$\begingroup\$ @Wezl Maybe ìnput, but it works only within the GUI console. \$\endgroup\$ Commented Feb 19, 2021 at 17:36
  • \$\begingroup\$ ok never mind, sorry. \$\endgroup\$
    – Wezl
    Commented Feb 19, 2021 at 17:37
2
\$\begingroup\$

Wolfram Language (Mathematica), 43 bytes

"Hi"<>#~StringDrop~3<>", I'm Mathematica!"&

Try it online!

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

T-SQL, 44 bytes

SELECT STUFF(v,1,3,'Hi')+', I''m SQL!'FROM t

Input is taken via pre-existing table t with text field v, per our IO standards.

STUFF is shorter than variations using SUBSTRING or RIGHT.

Can handle multiple inputs (as separate rows in t), although that's not required.

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

PowerShell, 42 41 40 37 bytes

-1 byte thanks to Spitemaster

"Hi$($args|% s*g 3), I'm PowerShell!"

Try it online!

There might be a cheaper automatic variable holding the PowerShell version hiding somewhere but I'm not sure. Answer takes the substring after I'm to the end and builds a string with it.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ You could save a byte by only skipping 3 characters and outputting "Hi$_`, I'm PowerShell!" \$\endgroup\$ Commented May 21, 2019 at 14:15
  • \$\begingroup\$ @Spitemaster Oh yeah, I guess I could. Thanks \$\endgroup\$
    – Veskah
    Commented May 21, 2019 at 14:28
  • \$\begingroup\$ @Veskah You can output the working directory with $pshome but that prints something like /opt/microsoft/powershell/6 \$\endgroup\$ Commented May 23, 2019 at 15:39
  • \$\begingroup\$ You could use the -f formatting operator for 33 bytes: Try it online! \$\endgroup\$
    – GMills
    Commented Jan 2, 2020 at 20:27
  • \$\begingroup\$ @GabrielMills Breaks for multiple words \$\endgroup\$
    – Veskah
    Commented Jan 3, 2020 at 13:02
2
\$\begingroup\$

Befunge-93, 45 bytes

"iH",,~~~>~# :1+#,_0"!39-egnufeB m'I ,">:#,_@

Try it online!

Dissected:

"iH",,                                           Push then output constant "Hi"
      ~~~                                        Read "I'm" from output, which gets unused
         >~# :1+#,_                              Non-wrapping cat program
                   0"!39-egnufeB m'I ,"          Push null-terminated constant string to stack
                                       >:#,_@    Output string and exit
\$\endgroup\$
2
\$\begingroup\$

Canvas, 19 bytes

jjjHiŗ, I'm Canvas!

Try it here!

18 bytes only handling single letter names

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

SNOBOL4 (CSNOBOL4), 55 bytes

	INPUT "I'M" REM . X
	OUTPUT ="HI" X ", I'M SNOBOL"
END

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ 53 bytes. \$\endgroup\$
    – user100411
    Commented Sep 17, 2021 at 2:26
2
\$\begingroup\$

C (gcc), 49 bytes

+3 Bytes: was not working
-3 Bytes: K&R style function. thanks JohanduToit

This is similar to the answer from Neil A. but takes the input as commandline arguments instead of a function parameter.

main(b,a)char**a;{printf("Hi%s, I'm C!",a[1]+3);}

Try it online!

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

PowerShell Core, 53 bytes

Filter f{$_-replace"(...)(.*)",'Hi$2, $1 PowerShell'}

Try it online!

Probably could do more improvement on the regex. Oh well.

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

Sinclair ZX80 BASIC, 92 tokenized BASIC bytes

As the Sinclair ZX80 character set only allows for upper-case and 'inversed' characters, and doesn't include a single-quote, shifted-E is substituted here. There is no exclamation mark in the ZX80 character set either - Source.

 1 INPUT A$
 2 FOR I=0 TO 2
 3 LET A$=TL$(A$)
 4 NEXT I
 5 PRINT "HI";A$;","
 6 PRINT "I'M SINCLAIR ZX80 BASIC"

How it works:

Line 1 takes the input as a string value to A$; Line 2 - 4 creates a loop to remove the first three characters of the entered value; Line 5 - 6 then outputs the ultimate Dad joke.

ZX80 Dad Joke answer

\$\endgroup\$
1
  • \$\begingroup\$ Can you replace print with a question mark? \$\endgroup\$ Commented Oct 25, 2022 at 8:55
2
\$\begingroup\$

naz, 122 bytes

2a2x1v7a8m1o3d4m9a1o3d3s1o1x1f5r3x1v2e1o1f0x1x2f0a0x1f0m9a2a4m1o9s3s1o2m9a1o2d3a1o3m8s1o3d4s1o3m9a5a1o9s4s1o9a9a7a1o3d7s1o

Uses a lot of arithmetic instructions to set the register to each of the character values in the dad-joke format.

Works for any input file terminated with the control character STX (U+0002).

Explanation (with 0x instructions removed)

2a2x1v           # Set variable 1 equal to 2
7a8m1o           # Output "H"
3d4m9a1o         # Output "i"
3d3s1o           # Output a space
1x1f5r3x1v2e1o1f # Function 1
                 # Read the 5th byte of input, then remove it from the input
                 # This has the effect of skipping over the self-descriptor's "I'm "
                 # Jump to function 2 if the value of the byte is equal to variable 1
                 # Otherwise, output the byte and jump back to the start of function 1
1x2f0a           # Function 2
                 # Add 0 to the register
1f               # Call function 1
0m9a2a4m1o       # Output ","
9s3s1o           # Output a space
2m9a1o           # Output "I"
2d3a1o           # Output an apostrophe (')
3m8s1o           # Output "m"
3d4s1o           # Output a space
3m9a5a1o         # Output "n"
9s4s1o           # Output "a"
9a9a7a1o         # Output "z"
3d7s1o           # Output "!"
\$\endgroup\$
2
\$\begingroup\$

Pip, 21 bytes

["Hi"a@>3k"I'm Pip!"]

Try it online!

Explanation

Constructs a list containing:

  • Literal string "Hi"
  • The input, minus its first three characters (a@>3)
  • A string containing a comma and a space (which happens to be the initial value of the variable k)
  • Literal string "I'm Pip!"

By default, lists are concatenated together when they are output.

Alternately, we can reuse the I'm from the input for a different 21-byte solution:

["Hi"a@>3ka@<4"Pip!"]
\$\endgroup\$
2
\$\begingroup\$

Zsh -c, 21 bytes

<<<"Hi${1:3}, I'm $0"

Try it online! (includes wrapper script to run with -c)

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

Scala, 36 bytes

{case s"$a $b"=>s"Hi $b, $a Scala!"}

Try it online

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

APOL, 32 bytes

+("Hi " +(V(i 4) ", I'm APOL!"))

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

JavaScript/Python (polyglot), 149 141 bytes

a=1//2;import sys
eval(["print('Hi'+sys.argv[1][3:]+', I\\'m Python!')","console.log('Hi'+process.argv[2].slice(3)+`, I'm JavaScript!`)"][a])

Example input (First arg)

I'm bored

JavaScript output (Try it Online!)

Hi bored, I'm JavaScript!

Python output (Try it Online!)

Hi bored, I'm Python!

Explanation

  • a=1//2;import sys:
    • What Python see: a=1//2= 0 (integer division/no-reminder), ;import sys
    • What JavaScript see: a=1 (the rest commented)
  • ["print('Hi'+s[...]","console.log([...]"]: Array with the code in Python, and the code in JavaScript respectively.
  • [a]: Select the index of it (Python:0', JavaScript:1)
\$\endgroup\$
2
\$\begingroup\$

Lexurgy, 44 bytes

a:
I'm=>Hi
*=>\,\ I'm\ Lexurgy\!/_ $//_ $$

Ungolfed explanation:

a:
I'm => Hi               # Swap "I'm" to "Hi"
* => \,\ I'm\ Lexurgy\! # the tack on the joke...
         / _ $          # when at the end of a word...
              // _ $$   # but not in between words.
\$\endgroup\$
1
2
\$\begingroup\$

GFortran, 73 bytes

As usual, Fortran string handling is clunky and annoying!

try it online

character(99)S;read'(A)',S
print*,'Hi',trim(S(4:)),', I''m GFortran!'
end
\$\endgroup\$
1
\$\begingroup\$

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

n=>$"Hi{n.Substring(3)}, I'm C#!"

Try it online!

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

K (ngn/k), 21 bytes

{"Hi",3_x,", I'm K!"}

Try it online!

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