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

1 2 3
4
0
\$\begingroup\$

Bean, 30 bytes

00000000: 56d8 8100 d3d0 80a0 5d20 8081 253c 5881  VØ..ÓÐ. ] ..%<X.
00000010: 01c8 69ac a0c9 a7ed a0c2 e5e1 ee21       .Èi¬ É§í Âåáî!

Original JavaScript:

`Hi${a.slice(3)}, I'm Bean!`

The program takes the first line of raw input implicitly in a, removing the first three characters, and outputs the template above using that string.

Demo


Test Suite

00000000: 53d0 80d3 d080 a078 2080 8840 a05d 56d8  SÐ.ÓÐ. x ..@ ]VØ
00000010: 8100 d3d0 80a0 5d20 8081 253c 5881 0120  ..ÓÐ. ] ..%<X.. 
00000020: 807b 2381 02c8 69ac a0c9 a7ed a0c2 e5e1  .{#..Èi¬ É§í Âåá
00000030: ee21 0a                                  î!.

Original JavaScript:

_.map(a=>`Hi${a.slice(3)}, I'm Bean!`).join('\n')

The test suite takes all the lines of raw input implicitly in _, applies the first program to each line using map(), then outputs each result per line.

Demo

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

아희 (Aheui), 319 bytes

밦밚따밬다발빠받밠따따빠따따밟밢밙다다다분
뭏떠벓벑떠떠벐벌벋떠떠벉더너벅번뻐떠뻐떠벊
맣@섹뵗솬밯삭밧타뿌싿삳빠맣박밯빠싸주마붗
반밚따따두쪼@썽선처손@@@오섣멓서차소빠
성멓뻐섣멓@@@@@@희@먛@셔멓섣멓멓멓

Try it online!

Prints 아희(official Korean name of the language) instead of Aheui, so the code is quite long.

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

Assembly (gcc, x64, Linux), 315 bytes

h:.int 26952
s:.int 32
g:.asciz ", I'm GNU Assembler!\n"
.globl main
main:
mov %rdi, %r13
mov %rsi, %r14
lea h, %rdi
mov $0, %rax
call printf
mov $2, %r15
l:
lea s, %rdi
mov $0, %rax
call printf
mov (%r14, %r15, 8), %rdi
mov $0, %rax
call printf
inc %r15
cmp %r15, %r13
jg l
lea g, %rdi
mov $0, %rax
call printf
ret

Try it online!

Ungolfed:

.section .bss

.section .data

hi:
.asciz  "Hi"

space:
.asciz  " "

imgnuasm:
.asciz  ", I'm GNU Assembler!\n"

badArgumentCount:
.asciz  "Requires at least two arguments\n"


.section .text
.globl main
main:

cmpq $3, %rdi # must have at least two arguments
jl .error

movq %rdi, %r13 # save argc
movq %rsi, %r14 # save argv

leaq hi, %rdi
movq $0, %rax   #%rax holds how many xmm regs to be used in x86-64
call printf

movq $2, %r15 # because (%r14, %r15(==0), 8) is the program path and (%r14, %r15(==1), 8) is "I'm"

.loopbegin:

  leaq space, %rdi
  movq $0, %rax
  call printf

  movq (%r14, %r15, 8), %rdi #(%r14, %r15, 8)
  movq $0, %rax
  call printf

  incq %r15
  cmp %r15, %r13
  jg .loopbegin


  leaq imgnuasm, %rdi
  movq $0, %rax
  call printf

  jmp .done

.error:
  leaq badArgumentCount, %rdi
  movq $0, %rax #%rax holds how many xmm regs to be used in x86-64
  call printf

.done:
  movq $0, %rax # return 0 (success)
  ret
\$\endgroup\$
0
\$\begingroup\$

C# .NET, 94 bytes

class P{static void Main(string[]a){System.Console.Write($"Hi {a[0].Substring(4)}, I'm C#");}}

Try Online

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

Clojure - 36 Bytes

#(str"Hi "(subs %4)", I'm Clojure!")

Trivial solution is trivial, probably has room for improvement

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

VBScript, 51 bytes

Msgbox "Hi "&Wscript.Arguments(1)&", I'm VBScript!"

Test like:

ScriptFile.vbs I'm tired
\$\endgroup\$
0
\$\begingroup\$

TI-Basic, 47 bytes

Input Str1
"Hi"+sub(Str1,4,length(Str1)-3)+", I'm TI-Basic!

Output is stored in Ans and displayed at the end.

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

Pxem (don't break loop when items are insufficient), 46 38 bytes, filename only.

It's been a while. As usual, \0001 is not such a string but a character 0x01.

.z.im.a_iH.w.i.c\0001.+.a.s!mexP m'I ,.v.p

Try it online!

With comments

XX.Z
.A.zXX.Z
  # push(getchar())
  .A.iXX.Z
  # constant 'm' charcode
  .AXXm.Z
# break loop if pop==pop
.A.aXX.Z
# "Hi" and dummy
.AXX_iH.Z
# dummy is popped before entering loop
.A.wXX.Z
  # keep pushing until EOF (-1) is met
  .A.i.c\0001.+.aXX.Z
# discard final EOF
.A.sXX.Z
# ", I'm Pxem!"
# reverse stack before printing each item
.A!mexP m'I ,.v.p
\$\endgroup\$
0
\$\begingroup\$

CLC-INTERCAL, 356 352 bytes.

Assumes adjective and noun has <100 characters.

DO;1<-#3DO;2<-#99DOWRITEIN;1+;2DO;3<-#2DO;3SUB#1<-#29DO;3SUB#2<-#1118DO;4<-#1DO;4SUB#1<-#127DO;6<-#1DO;6SUB#1<-#117DO;5<-#13DO;5SUB#1<-#16DO;5SUB#2<-#368DO;5SUB#3<-#368DO;5SUB#4<-#274DO;5SUB#5<-#103DO;5SUB#6<-#376DO;5SUB#7<-#217DO;5SUB#8<-#374DO;5SUB#9<-#356DO;5SUB#10<-#374DO;5SUB#11<-#375DO;5SUB#12<-#1353DO;5SUB#13<-#276DOREADOUT;3+;2+;4+;6+;1+;6+;5

Copy and paste to try it online!

With comments

DONOTE ;1 for "I'm", ;2 for rest of input
DO;1<-#3
DO;2<-#99
DOWRITEIN;1+;2
DONOTE ;3 for "Hi"
DO;3<-#2DO;3SUB#1<-#29DO;3SUB#2<-#1118
DONOTE ;4 for ","
DO;4<-#1DO;4SUB#1<-#127
DONOTE ;6 for " "
DO;6<-#1DO;6SUB#1<-#117
DONOTE ;5 for "CLC-INTERCAL!"
DO;5<-#13DO;5SUB#1<-#16DO;5SUB#2<-#368DO;5SUB#3<-#368DO;5SUB#4<-#274DO;5SUB#5<-#103DO;5SUB#6<-#376DO;5SUB#7<-#217DO;5SUB#8<-#374DO;5SUB#9<-#356DO;5SUB#10<-#374DO;5SUB#11<-#375DO;5SUB#12<-#1353DO;5SUB#13<-#276
DONOTE concatenate those strings
DOREADOUT;3+;2+;4+;6+;1+;6+;5
\$\endgroup\$
1
  • \$\begingroup\$ Shall I ;7<-"C"? Would it shorten the code? \$\endgroup\$
    – user100411
    Commented Sep 17, 2021 at 12:12
0
\$\begingroup\$

Python 3 (34 Bytes)

lambda m:"Hi%s, I'm Python!"%m[3:]

Python 3 (35 Bytes)

lambda m:"Hi"+m[3:]+", I'm Python!"
\$\endgroup\$
0
\$\begingroup\$

Python 3, 46 bytes

s=input()
print("Hi "+s[4:]+", I'm Python 3!")

Try it online!

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

Pascal (ISO standard 10206, “Extended Pascal”), 103 characters

program d(input,output);var s:string(99);begin readLn(s);writeLn('Hi',subStr(s,4),', I''m Pascal!')end.

FreePascal, 83 characters

The FPC (FreePascal Compiler) in its default configuration (specifically {$mode FPC}), discards and doesn’t need a program header (the program d(input,output);). Instead a program always has the text files input and output at its disposal. Furthermore string is shorthand for string[255]. However, the subStr function is not (yet) supported (as of FPC version 3.2.0) and copy will necessarily require a length specification (can only be omitted in {$mode Delphi}). Thus we can condense the above program to:

var s:string;begin readLn(s);writeLn('Hi',s[4..length(s)],', I''m FreePascal!')end.
var s:string;begin readLn(s);delete(s,1,3);writeLn('Hi',s,', I''m FreePascal!')end.
\$\endgroup\$
0
\$\begingroup\$

Thunno KJ, \$ 22 \log_{256}(96) \approx \$ 18.11 bytes

3Zx", I'm Thunno!"s"Hi

Attempt This Online!

Thunno, \$ 23 \log_{256}(96) \approx \$ 18.93 bytes

3Zx"Hi%s, I'm Thunno!"$

Attempt This Online!

Explanation

               # Implicit input
3Zx            # Remove first three characters
   "..."       # Push the string literal
        s"Hi  "# Swap and push "Hi"
               # Implicit output of joined stack

           # Implicit input
3Zx        # Remove first three characters
   "..."   # Push the string literal
        $  # Replace "%s" with ^^
           # Implicit output
\$\endgroup\$
1 2 3
4

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.