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

78 Answers 78

3
\$\begingroup\$

bash, 24 bytes

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

TIO

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ replace bash with $0 to save a couple of bytes \$\endgroup\$ – roblogic May 23 '19 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\$ – Nahuel Fouilleul May 23 '19 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

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

Wolfram Language (Mathematica), 43 bytes

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

Try it online!

| improve this answer | |
\$\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.

| improve this answer | |
\$\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
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Canvas, 19 bytes

jjjHiŗ, I'm Canvas!

Try it here!

18 bytes only handling single letter names

| improve this answer | |
\$\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!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Oh, thanks! @JohanduToit Don't know how I missed that. \$\endgroup\$ – peterzuger May 22 '19 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.

| improve this answer | |
\$\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

| improve this 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.

| improve this answer | |
\$\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

| improve this answer | |
\$\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!"]
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

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

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

K (ngn/k), 21 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Red, 39 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Nim, 32 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Icon, 52 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Haxe, 57 54 bytes

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

Try it online!

| improve this answer | |
\$\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.

| improve this answer | |
\$\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

| improve this answer | |
\$\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.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ You could save a byte by only skipping 3 characters and outputting "Hi$_`, I'm PowerShell!" \$\endgroup\$ – Spitemaster May 21 '19 at 14:15
  • \$\begingroup\$ @Spitemaster Oh yeah, I guess I could. Thanks \$\endgroup\$ – Veskah May 21 '19 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 '19 at 15:39
  • \$\begingroup\$ You could use the -f formatting operator for 33 bytes: Try it online! \$\endgroup\$ – Gabriel Mills Jan 2 at 20:27
  • \$\begingroup\$ @GabrielMills Breaks for multiple words \$\endgroup\$ – Veskah Jan 3 at 13:02
1
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 55 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Clojure, 36 bytes

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

TeX, 48 43 bytes

Yes I could save a byte by writing TeX instead of \TeX, but it seems a shame.

\def\s[#1]#2#3#4{}\def~[#1]{Hi\s[]#1, I'm \TeX!}

Update: saved 3 5 bytes thanks to fixed pattern matching.

\def\s[]I'm{}\def~[#1]{Hi\s[]#1, I'm \TeX!}

Test file

\def\s[]I'm{}\def~[#1]{Hi\s[]#1, I'm \TeX!}
~[I'm amazing]
~[I'm hungry]
~[I'm tired]
~[I'm fat]
~[I'm a programmer]
~[I'm a question-writer]
~[I'm a Stack-Overflow-er]
\bye

Output: Hi amazing, I'm TeX! Hi hungry, I'm TeX! Hi tired, I'm TeX! Hi fat, I'm TeX! Hi a programmer, I'm TeX! Hi a question-writer, I'm TeX! Hi a Stack-Overflow-er, I'm TeX!

Try it online!

| improve this answer | |
\$\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
| improve this answer | |
\$\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!

| improve this answer | |
\$\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)

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Are you doing much with Teascript these days? It was a cool project,.. \$\endgroup\$ – roblogic May 24 '19 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 '19 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

| improve this answer | |
\$\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 '19 at 13:40
  • \$\begingroup\$ @mbomb007 Thanks; I updated my answer. \$\endgroup\$ – Scribblemacher May 22 '19 at 14:26
1
\$\begingroup\$

ReRegex, 31 bytes

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

This assumes input doesn't end on !.

TIO

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Julia 1.0, 30 bytes

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

Try it online!

| improve this answer | |
\$\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.