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

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

Other stuff:


Leaderboard

You can view the leaderboard for this post by expanding the widget/snippet below. In order for your post to be included in the rankings, you need a header (# header text) with the following info:

  • The name of the language (end it with a comma , or dash -), followed by...

  • The byte count, as the last number to appear in your header.

For example, JavaScript (ES6), 72 bytes is valid, but Fortran, 143 bytes (8-bit) is invalid because the byte count is not the last number in the header (your answer will be recognized as 8 bytes - don't take advantage of this).

<iframe src="https://ozewski.github.io/ppcg-leaderboard/?id=185872" width="100%" height="100%" style="border: none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe><style>html,body{margin:0;padding:0;height:100%;overflow:hidden}</style>

\$\endgroup\$
  • 39
    \$\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 May 21 at 0:54
  • 7
    \$\begingroup\$ Some example outputs end with exclamation and some do not. What is the significance? \$\endgroup\$ – recursive May 21 at 1:56
  • 9
    \$\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\$ – user2390246 May 21 at 10:58
  • 7
    \$\begingroup\$ And the tie-breaker isn't votes, it's who reached the lowest score first. \$\endgroup\$ – Shaggy May 21 at 12:08
  • 4
    \$\begingroup\$ Now waiting for the next golfing language that's name is an empty string. \$\endgroup\$ – 640KB May 21 at 18:24

74 Answers 74

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\$
  • \$\begingroup\$ javascript is shorter than "+process.argv[0].slice(5,15)+" \$\endgroup\$ – Nahuel Fouilleul May 21 at 9:28
  • 2
    \$\begingroup\$ @NahuelFouilleul yes, but +process.argv[0].slice(5,15)+ is more fun ;-) \$\endgroup\$ – Johan du Toit May 21 at 9:37
  • 1
    \$\begingroup\$ The consensus on language names is that we must use proper casing - JavaScript, not javascript. \$\endgroup\$ – Shaggy May 21 at 12:10
  • \$\begingroup\$ @Shaggy, point taken. \$\endgroup\$ – Johan du Toit May 22 at 5:03
2
\$\begingroup\$

JavaScript, 38 37 bytes

x=>`Hi${x.slice(3)}, I'm JavaScript!`

Try it online!

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

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

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\$
  • \$\begingroup\$ Oh, thanks! @JohanduToit Don't know how I missed that. \$\endgroup\$ – peterzuger May 22 at 6:34
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\$
2
\$\begingroup\$

AWK, 28 25 bytes

$1="Hi",$0=$0", I'm AWK!"

Try it online!

This program modifies the contents of field "$1" and "$0" in a range pattern. Because no actions are specified after the pattern, the default action {print $0} is executed.

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

GFortran, 80 76 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

This is how I compile and run it (on Mac with homebrew + gcc + source file dad.f):

$ gfortran -std=gnu -Wextra -Wall -pedantic -ffree-form -fcheck=all -fbacktrace dad.f -o dad.app

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

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

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

Try it online!

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

K (ngn/k), 21 bytes

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

Try it online!

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

Red, 39 bytes

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

Try it online!

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

Nim, 32 bytes

s=>"Hi"&s[3..s.len]&", I'm Nim!"

Try it online!

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

Icon, 52 bytes

procedure d(s);return"Hi"||s[4:0]||", I'm Icon!";end

Try it online!

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

Haxe, 57 54 bytes

function(x:String)return'Hi${x.substr(3)}, I\'m Haxe!'

Try it online!

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

Charcoal, 21 bytes

Hi✂S³P, I'm Charcoal!

Try it online! Link is to verbose version of code. Explanation: is the Slice operator which normally takes four arguments, however the use of the P command to output the suffix allows Charcoal to deduce that the last two arguments were omitted.

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

APL+WIN, 31 21 bytes

10 bytes saved by taking on board Adam's comments. Thanks.

"Hi",3↓⎕,", I'm APL!"

Prompts for input string.

Try it online! Courtesy of dzaima/APL

\$\endgroup\$
1
\$\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\$
  • 1
    \$\begingroup\$ You could save a byte by only skipping 3 characters and outputting "Hi$_`, I'm PowerShell!" \$\endgroup\$ – Spitemaster May 21 at 14:15
  • \$\begingroup\$ @Spitemaster Oh yeah, I guess I could. Thanks \$\endgroup\$ – Veskah May 21 at 14:28
  • \$\begingroup\$ @Veskah You can output the working directory with $pshome but that prints something like /opt/microsoft/powershell/6 \$\endgroup\$ – Jeff Freeman May 23 at 15:39
1
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 55 bytes

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

Try it online!

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

Clojure, 36 bytes

#(str"Hi"(subs % 3)", I'm Clojure!")
\$\endgroup\$
1
\$\begingroup\$

Forth (gforth), 40 bytes

: f 3 -3 d+ ." Hi"type ." , I'm Forth!";

Try it online!

Code Explanation

: f                 \ start a new word definition
  3 -3 d+           \ add 3 to the starting address and subtract 3 from the string length
  ." Hi"type        \ output "Hi" followed by all but the first 3 characters of the input string      
  ." , I'm Forth!"; \ output ", I'm Forth!" and end the word definition
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 34 bytes

"Hi${i.substring(3)}, I'm Kotlin!"

Try it online!

Kotlin, 26 bytes

Is this a loop hole ?

"Hi${i.s(3)}, I'm Kotlin!"

Try it online!

The 26 is definitely a loophole else I can golf it to 5 bytes with:

i.k()

which is meaningless.

Try it online!

\$\endgroup\$
1
\$\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\$
  • \$\begingroup\$ Are you doing much with Teascript these days? It was a cool project,.. \$\endgroup\$ – roblogic May 24 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 May 24 at 4:38
1
\$\begingroup\$

Lua, 68 59 bytes

function d(s)return(s:gsub("(I\'m)(.*)","Hi%2, %1 Lua"))end

Uses a pattern to swap in the I'm in the original and then returns the joke. Having chucks on a single line like this is valid, but ugly.

Edit: More efficient use of gsub

\$\endgroup\$
  • \$\begingroup\$ Consider adding a short explanation to your answer. Code-only answers tend to get automatically flagged as low quality. \$\endgroup\$ – mbomb007 May 22 at 13:40
  • \$\begingroup\$ @mbomb007 Thanks; I updated my answer. \$\endgroup\$ – Scribblemacher May 22 at 14:26
1
\$\begingroup\$

ReRegex, 31 bytes

^I'm/Hi/[^!]$/$0, I'm ReRegex!/

This assumes input doesn't end on !.

TIO

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

Julia 1.0, 30 bytes

s->"Hi$(s[4:end]), I'm Julia!"

Try it online!

\$\endgroup\$
1
\$\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\$
  • 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 May 23 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\$ – Jeff Schaller May 23 at 15:48
1
\$\begingroup\$

JavaScript (V8), 37 bytes

s=>`Hi${s.slice(3)}, I'm JavaScript!`

Try it online!

\$\endgroup\$

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.