45
\$\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://xmikee1.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\$
  • 37
    \$\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\$ – gwaugh May 21 at 18:24

71 Answers 71

24
\$\begingroup\$

V, 13 bytes

cEHi<esc>A, <C-r>" V!

Try it online!

Inspired by tsh's answer

This takes advantage of the fact that I'm is yanked from the start of the string when deleting the text from the start, and pastes it to the end with <C-r>" while in insert mode.

\$\endgroup\$
  • \$\begingroup\$ I just edited I'm to <C-O>p and then notice your answer... \$\endgroup\$ – tsh May 21 at 10:11
  • 2
    \$\begingroup\$ A golfing language using Vim and escape takes 5 characters??? \$\endgroup\$ – mowwwalker May 21 at 18:13
  • 3
    \$\begingroup\$ @mowwwalker Nope. It's really the byte 0x1B, but it's easier and more obvious what it means if you write it as <esc>. The same for <C-r>, which is really 0x12 \$\endgroup\$ – DJMcMayhem May 21 at 21:19
  • \$\begingroup\$ @DJMcMayhem, ah that makes much more sense \$\endgroup\$ – mowwwalker May 21 at 21:22
16
\$\begingroup\$

C (gcc), 59 42 33 bytes

-17 bytes thanks to @Conor O'Brien noticing that the import wasn't necessary

-9 bytes thanks to @tsh pointing out a shorter, UB way of writing the function

a(x){printf("Hi%s, I'm C!",x+3);}

Try it online!

Chops off the first 3 characters of the input (removes I'm) and surrounds it with the desired text.

\$\endgroup\$
  • \$\begingroup\$ The program compiles without the import, so you can drop it for 42 bytes. \$\endgroup\$ – Conor O'Brien May 21 at 2:39
  • \$\begingroup\$ @ConorO'Brien nice catch! \$\endgroup\$ – Neil A. May 21 at 3:28
  • 3
    \$\begingroup\$ And the int is also optional. \$\endgroup\$ – tsh May 21 at 4:08
  • 2
    \$\begingroup\$ (?) And also the char*, maybe...; so a(x){printf("Hi%s, I'm C!",x+3);} should work \$\endgroup\$ – tsh May 21 at 4:13
  • 2
    \$\begingroup\$ @tsh: yes, in practice that will work on most 32-bit C implementations (where an int can hold a char* without truncating it), despite the undefined behaviour. On x86-64 gcc on Linux, it will always fail in a PIE executable (typically no pointers are in the low 32 bits of virtual address space, and gcc won't happen to copy the high 32 bits while calculating x+3 from the function arg in the RDI register). But in a non-PIE executable, static addresses are in the low 31 bits of virtual address space, so if the caller passed a string literal or a static buffer, it would happen to work. \$\endgroup\$ – Peter Cordes May 21 at 9:54
15
\$\begingroup\$

V, 13 bytes

cEHi<Esc>A, <C-O>p V!

Try it online!

New to V. Just knew it about 30 minutes ago. Anyway, this language is chosen just because its name only cost 1 byte. I'm not sure how to send <End> key in V. Most vim environment would accept <End> as a replacement of <Esc>A in this example. But, you know, V is 2 characters shorter than vim. :)

Thanks to @Candy Gumdrop, saves 1 byte.

\$\endgroup\$
  • 1
    \$\begingroup\$ Could save one byte by changing c3l to cE. \$\endgroup\$ – Candy Gumdrop May 21 at 9:39
  • \$\begingroup\$ @CandyGumdrop Wow, I didn't know the upper case E before. \$\endgroup\$ – tsh May 21 at 9:52
  • \$\begingroup\$ You could also do cW (which seems different, but is actually identical to cE) or 3s. Nice job! I was just about to post almost this exact answer when I saw that there were 2 V answers already, which was a nice surprise. I've tried several different approaches, but I'm not sure if it'll be possible to get <13 bytes. \$\endgroup\$ – DJMcMayhem May 21 at 17:21
11
\$\begingroup\$

Stax, 13 bytes

â∞¿φ‼0▲(─ƒSqÄ

Run and debug it

Unpacked, ungolfed, and commented, it looks like this.

.Hip        print "Hi" with no newline
3tp         trim 3 characters from start of input and print with no newline
            final line is to print the unterminated compressed literal ", I'm stax!"
`dYgAwg_

I moved the final comment up one line since nothing may follow an unterminated string literal.

Run this one

\$\endgroup\$
  • \$\begingroup\$ I'm going to declare you the winner because your post had more votes, but you technically were tied with one other person. Congratulations! \$\endgroup\$ – connectyourcharger May 21 at 10:02
10
\$\begingroup\$

brainfuck, 164

,-.+>,>,----.++++>,.>,[.,]<<<+++++.----->>.[<]>[.>]<[->+++<]>++.[--->+<]>----.+++[->+++<]>++.++++++++.+++++.--------.-[--->+<]>--.+[->+++<]>+.++++++++.+[++>---<]>-.

Try it online!

The "brainfuck!" part of the string is generated with this tool, can probably be golfed further by hand.

\$\endgroup\$
10
\$\begingroup\$

Excel, 36 33 bytes

-3 bytes thanks to Johan du Toit.

Input goes into A1.

="Hi "&MID(A1,4,99)&", I'm Excel"

First attempt:

=REPLACE(A1,1,3,"Hi")&", I'm Excel!"
\$\endgroup\$
  • \$\begingroup\$ ="Hi "&MID(B13,4,99)&", I'm Excel" 34 bytes \$\endgroup\$ – Johan du Toit May 25 at 11:24
  • \$\begingroup\$ Thank you @JohanduToit. A1 instead of B13 so actually 33 bytes. \$\endgroup\$ – Wernisch Jun 13 at 14:03
6
\$\begingroup\$

R 45 44 39 bytes

@Giuseppe Edit

sub("I'm(.*)","Hi\\1, I'm R",scan(,""))

@AaronHayman Edit

function(s)sub("I'm (.*)","Hi \\1, I'm R",s)

Try it online!

\$\endgroup\$
  • \$\begingroup\$ can save one byte replacing "(I'm ) with "(.* ) \$\endgroup\$ – Aaron Hayman May 21 at 9:32
  • 1
    \$\begingroup\$ @AaronHayman, doesn't work for I'm a programmer (many spaces) because of greediness \$\endgroup\$ – Nahuel Fouilleul May 21 at 9:48
  • \$\begingroup\$ @NahuelFouilleul Right, I wasn't sure if the first or last white space would be considere. \$\endgroup\$ – niko May 21 at 9:54
  • 1
    \$\begingroup\$ Okay, I saved a byte, and I think this one works properly Try it online! \$\endgroup\$ – Aaron Hayman May 21 at 10:22
  • 2
    \$\begingroup\$ 2 bytes by changing the sub to "I'm(.*)" and "Hi\\1, I'm R" and 3 bytes by taking input from stdin using scan: Try it online \$\endgroup\$ – Giuseppe May 21 at 14:14
6
\$\begingroup\$

Python 3, 35 34 bytes

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

Try it online!

-1 byte thanks to Embodiment of Ignorance

Also 34 bytes, using the newer formatted strings, thanks to Gábor Fekete:

lambda s:f"Hi{s[3:]}, I'm Python!"

Try it online!

\$\endgroup\$
  • 3
    \$\begingroup\$ 34 bytes \$\endgroup\$ – Embodiment of Ignorance May 21 at 2:00
  • \$\begingroup\$ What about losing lambda s: and replacing %s[3:] with %input()[3:]? (-4 bytes) \$\endgroup\$ – niko May 21 at 21:01
  • \$\begingroup\$ @niko if I understand what you are saying, that will not print anything. Default rules on this site are either a full program that prints output or a function that returns output. Usually what you are suggesting is called a snippet, and would not be a complete solution, it would need to be wrapped with print() for 7 more bytes, which is why Python answers usually use lambdas. \$\endgroup\$ – Stephen May 21 at 21:07
  • \$\begingroup\$ But how is that different from your (and actually most) answer(s) here? I mean both by themselves do not print anything, and both return the same output right? (Fairly new here - still getting used to CG) \$\endgroup\$ – niko May 21 at 21:22
  • 2
    \$\begingroup\$ @niko It's OK! With lambda s, I have defined an (anonymous) function. If you look at the header and the footer in the TIO link, I name that function f, and then called it with f("I'm whatever"). Then the function returns the expected output. With your snippet, you neither print nor return from a function - you just have a bit of code that evaluates to the correct result, but does not do anything with it. You can run programs multiple times, you can call functions multiple times, but a snippet is just a snippet. \$\endgroup\$ – Stephen May 21 at 21:34
6
\$\begingroup\$

x86, 37 36 bytes

$ xxd DAD.COM
00000000: d1ee ac8a d8c6 0024 adc7 0448 698b d6b4  .......$...Hi...
00000010: 09cd 21ba 1901 cd21 c32c 2049 276d 2078  ..!....!., I'm x
00000020: 3836 2124                                86!$

Unassembled:

D1 EE       SHR  SI, 1                  ; point SI to DOS PSP (080H)
AC          LODSB                       ; load string length into AL, advance SI
8A D8       MOV  BL, AL                 ; put string length into BL
C6 40 24    MOV  BYTE PTR[BX][SI], '$'  ; add string terminator to end of string
AD          LODSW                       ; advance SI two chars
C7 04 6948  MOV  WORD PTR[SI], 'iH'     ; replace second and third char with 'Hi'
8B D6       MOV  DX, SI                 ; load string address for INT 21H string function
B4 09       MOV  AH, 9                  ; display a '$' terminated string function
CD 21       INT  21H                    ; call DOS API
BA 0119     MOV  DX, OFFSET S           ; load address for second part of string
CD 21       INT  21H                    ; call DOS API
C3          RET                         ; return to DOS
S  DB ", I'm x86!$"  

A standalone executable DOS program. Input from command line, output to screen.

enter image description here

Download and test DAD.COM.

* The exact "language" name here is a little ambiguous as CPU machine code isn't really a language in a formal sense. Going with "x86" as a generally understood and accepted name for the target platform.

\$\endgroup\$
  • \$\begingroup\$ [moving comment down from main thread] I'd say "x86" is the architecture, while "MA SM" would be one of the available languages on that architecture (note it does have a space in it though). \$\endgroup\$ – Jonathan Allan May 22 at 18:34
  • 5
    \$\begingroup\$ I think "x86" is probably fine really, it is golf after all :) \$\endgroup\$ – Jonathan Allan May 22 at 18:51
5
\$\begingroup\$

Java, 36 bytes

s->"Hi"+s.substring(3)+", I'm Java!"

Try it online.

\$\endgroup\$
5
\$\begingroup\$

Whitespace, 267 bytes

[S S S T    S S T   S S S N
_Push_72_H][T   N
S S _Print_as_character][S S S T    T   S T S S T   N
_Push_105_i][T  N
S S _Print_as_character][S S S N
_Push_0][S N
S _Duplicate_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   N
T   S _Read_STDIN_as_character][T   N
T   S _Read_STDIN_as_character][N
S S N
_Create_Label_INPUT_LOOP][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S N
S _Duplicate_input][S S S T S T S N
_Push_10][T S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_TRAILING][T N
S S _Print_as_character][N
S N
N
_Jump_to_Label_INPUT_LOOP][N
S S S N
_Create_Label_TRAILING][S N
N
_Discard_top][S S T T   S S S T S T N
_Push_-69_!][S S T  T   N
_Push_-1_e][S S T   T   T   N
_Push_-3_c][S S T   T   S T N
_Push_-5_a][S S S T S T S N
_Push_10_p][S S S T T   S T N
_Push_13_s][S S T   T   N
_Push_-1_e][S S S T T   T   S N
_Push_14_t][S S S T T   N
_Push_3_i][S S S T  S N
_Push_2_h][S S T    T   T   T   T   N
_Push_-15_W][S S T  T   S S S T T   S N
_Push_-70_space][S S S T    T   T   N
_Push_7_m][S S T    T   T   T   T   T   T   N
_Push_-63_'][S S T  T   T   T   S T N
_Push_-29_I][S T    S S T   T   N
_Copy_0-based_3rd_-70_space][S S T  T   T   T   S T S N
_Push_-58_,][N
S S T   N
_Create_Label_PRINT_TRAILING_LOOP][S S S T  T   S S T   T   S N
_Push_102][T    S S S _Add][T   N
S S _Print_as_character][N
S N
T   N
_Jump_to_Label_PRINT_TRAILING_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Since Whitespace inputs one character at a time, the input should contain a trailing newline so it knows when to stop reading characters and the input is done.

Try it online (with raw spaces, tabs, and new-lines only).

Explanation in pseudo-code:

Print "Hi"
Read three characters from STDIN, and do nothing with them
Start INPUT_LOOP:
  Character c = STDIN as character
  If(c == '\n'):
    Call function PRINT_TRAILING
  Print c as character
  Go to next iteration of INPUT_LOOP

function PRINT_TRAILING:
  Discard the top of the stack (the c='\n' that was still on the stack)
  Push "!ecapsetihW m'I ," one character at a time
  Start PRINT_TRAILING_LOOP:
    Print as character
    Go to next iteration of PRINT_TRAILING_LOOP

The characters of ", I'm Whitespace!" are pushed in reversed order, and then printed in a loop. All values of these characters are also lowered by 102, which are added in the loop before printing to save bytes. This constant 102 to lower each character with is generated with this Java program. Also, instead of pushing the value -70 for both spaces twice, the second space in "!ecapsetihW m'I ," is copied from the first with the Copy builtin to save a few bytes.

\$\endgroup\$
5
\$\begingroup\$

IBM/Lotus Notes Formula Language, 61 62 bytes

+1 because I hadn't noticed the ! at the end of the output.

"Hi"+@Right(i;"I'm")+", I'm IBM/Lotus Notes Formula Language!"

Computed field formula that takes it's input from an editable field i. It would fail for "I'm an I'm" but since that wouldn't make any sense at all I'm assuming that it won't happen.

Shame that at 32 bytes, the name of the language is more than half the total length of the formula!

Screenshot below showing an example input and output:

enter image description here

\$\endgroup\$
  • 5
    \$\begingroup\$ It looks like your language would be good for the job if the name wasn't so long :) \$\endgroup\$ – connectyourcharger May 21 at 9:59
  • \$\begingroup\$ if I was being serious I would probably just call it Formula which is how it is referred to in the Notes/Domino developer community :-) \$\endgroup\$ – ElPedro May 21 at 10:10
  • 1
    \$\begingroup\$ @PeterCordes - Possible but Lotus Notes/Domino also has LotusScript as an inbuilt language so we probably need to be a little more specific ;-) \$\endgroup\$ – ElPedro May 21 at 10:12
  • 1
    \$\begingroup\$ Could actually go a little better than that since IBM rebranded it to IBM Notes but then they rebranded again to IBM Domino so I guess that to be strictly correct it should be "Hi @PeterCordes, I'm IBM Domino Formula" :) \$\endgroup\$ – ElPedro May 21 at 10:16
  • 1
    \$\begingroup\$ @PeterCordes Only the essential parts of the language name are required - I'm accepting Perl as a substitution for Perl 5 or Perl 5 -p. \$\endgroup\$ – connectyourcharger May 21 at 10:23
5
\$\begingroup\$

PHP, 34 32 bytes

Hi<?=substr($argn,3)?>, I'm PHP!

Try it online!

Input via STDIN, call with -F.

$ echo I'm a Stack-Overflow-er|php -F dad.php
Hi a Stack-Overflow-er, I'm PHP!

$ echo I'm hungry|php -F dad.php
Hi hungry, I'm PHP!
\$\endgroup\$
5
\$\begingroup\$

sed (-r), 31 28 25 bytes

-3 bytes thanks to Shaggy -3 bytes because -r not needed in output

s/I'm(.*)/Hi\1, I'm sed!/

TIO

\$\endgroup\$
  • \$\begingroup\$ 28 bytes? \$\endgroup\$ – Shaggy May 21 at 12:25
  • \$\begingroup\$ Hmm ... Our way around counting flags was to declare them as different languages so I think you may need the -r but it would be worth getting Meta to weigh in on it. \$\endgroup\$ – Shaggy May 21 at 17:40
  • \$\begingroup\$ i removed because of perl 5 answer and comments \$\endgroup\$ – Nahuel Fouilleul May 22 at 5:34
5
\$\begingroup\$

Japt, 18 bytes

`Hi{s3}, I'm Japt!

When Japt's string compression library achieves a 0% compress rate...

Try it

Another 18-byte alternative:

`Hi{Ť}, {¯4}Japt!
\$\endgroup\$
  • 1
    \$\begingroup\$ ... but still beats Jelly and 05AB1E :) \$\endgroup\$ – Shaggy May 21 at 8:25
5
\$\begingroup\$

Octave, 35 bytes

@(s)["Hi" s(4:end) ", I'm Octave!"]

Try it online!

@(s)                                 % Anonymous function taking a string input
    [                             ]  % Concatenate everything inside the brackets
     "Hi"          ", I'm Octave!"]  % The fixed parts of the output string
          s(4:end)                   % The input, except "I'm"

                                     % Returns the concatenated string

42 bytes:

I tried retrieving "Octave" somehow, without writing it out, since 6 chars is quite a lot compared to some of the other language names here. Unfortunately, I could only find ver, which outputs a struct with comma separated fields. Takes way more than 6 bytes. :(

@(s)["Hi" s(4:end) ", I'm " {ver.Name}{1}]

Try it online!

\$\endgroup\$
5
\$\begingroup\$

Ruby -p, 32 27 26 bytes

-5 bytes by leveraging Nick Kennedy's Jelly answer.

-1 byte from splitting on a different point in the string. Also realized my old bytecount was wrong.

~/m/;$_="Hi#$', I'm Ruby!"

Explanation

                            # -p gets line of input and saves to $_
~/m/;                       # Find first 'm' in $_ using regex
     $_="Hi#$', I'm Ruby!"  # Save modified string to $_
                            # ($' is the string AFTER the most recent regex match)
                            # -p outputs $_ to screen

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Cool! Where's your input? \$\endgroup\$ – connectyourcharger May 20 at 23:37
  • \$\begingroup\$ @connectyourcharger added an explanation. Input is STDIN. \$\endgroup\$ – Value Ink May 20 at 23:40
  • \$\begingroup\$ Gotcha. Good answer! \$\endgroup\$ – connectyourcharger May 20 at 23:42
4
\$\begingroup\$

Batch, 22 + 3 = 25 bytes

@echo Hi %*, %0 Batch!

+3 bytes for naming this file I'm (with the required .bat extension for Batch files). Invoke as I'm hungry, when it will echo Hi hungry, I'm Batch!.

\$\endgroup\$
  • \$\begingroup\$ program should receive I'm but here it's the name of the script don't know if it's valid, or unless it's the interpreter with the script in current path \$\endgroup\$ – Nahuel Fouilleul May 21 at 9:43
  • 1
    \$\begingroup\$ @NahuelFouilleul The interpreter is CMD, so would that actually save me 2 bytes? \$\endgroup\$ – Neil May 21 at 10:03
4
\$\begingroup\$

Perl 6, 30 28 27 bytes

{S/.../Hi/~", I'm Perl 6!"}

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Perl 5 -p, 31 24 bytes

Cut down based on clarifications from OP and a suggestion from @NahuelFouilleul.

/ /;$_="Hi $', $` Perl!"

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ 29 bytes \$\endgroup\$ – Nahuel Fouilleul May 21 at 7:14
  • 1
    \$\begingroup\$ also maybe $^X $] special variables could be used, however 5 is shorter than $] \$\endgroup\$ – Nahuel Fouilleul May 21 at 7:18
  • \$\begingroup\$ Do you need to include the 5 as part of the name of the language? i.e. could you argue that Perl 5 "thinks of itself" as "Perl"? That was the case before Perl 6 existed, and codegolf answers only need to work on at least one implementation of the language, so pick an old one? \$\endgroup\$ – Peter Cordes May 21 at 9:58
  • \$\begingroup\$ OP confirms that Perl is sufficient. And that the use of the -p option doesn't have to be considered part of the language name. \$\endgroup\$ – Peter Cordes May 21 at 10:24
4
\$\begingroup\$

Jelly,  16  15 bytes

Ḋa⁾Hi“'ṫṗḶ/÷!Ṗ»

A full program accepting a (Python formatted) string argument which prints the result.

Try it online!

How?

Ḋa⁾Hi“'ṫṗḶ/÷!Ṗ» - Link: list of characters    e.g. "I'm a programmer"
Ḋ               - dequeue                          "'m a programmer"
  ⁾Hi           - pair of characters               "Hi"
 a              - logical AND (vectorises)         "Hi a programmer"
     “'ṫṗḶ/÷!Ṗ» - list of characters               ", I'm Jelly!"
                -  - since this is a new leading constant chain the previous result
                -    is implicitly printed (with no trailing newline)
                - program result is implicitly printed (again with no trailing newline)

Note: Ḋ⁾Hio... works too.

\$\endgroup\$
4
\$\begingroup\$

Jelly, 20 17 bytes

ṫ4;“'ṫṗḶ/÷!Ṗ»⁾Hi;

Try it online!

A monadic link taking the input as its argument and returning a Jelly string.

Explanation

ṫ4                | everything from 4th character on
  ;“'ṫṗḶ/÷!Ṗ»     | concatenate ", I’m Jelly!" to the end
             ⁾Hi; | concatenate "Hi" to the beginning
\$\endgroup\$
  • 1
    \$\begingroup\$ Hang on, Jelly has a built-in just for the word "Jelly"? \$\endgroup\$ – connectyourcharger May 20 at 23:55
  • 3
    \$\begingroup\$ @connectyourcharger it’s a compressed dictionary word \$\endgroup\$ – Nick Kennedy May 20 at 23:56
  • \$\begingroup\$ Ah, that makes sense \$\endgroup\$ – connectyourcharger May 20 at 23:56
4
\$\begingroup\$

VBA (Excel), 27 28 bytes

?"Hi"Mid([A1],4)", I'm VBA!

Input goes in cell A1 of the Active Sheet in Excel, run code in the Immediate Window

Takes advantage of the fact that "SomeString"SomeValue and SomeValue"SomeString" will implicitly concatenate, and that omitting the third argument from the MID function will take all characters from the end of the input - turning it into a "dump initial characters" function

(-1 byte thanks to Shaggy, but +1 when OP confirmed that all answers should end with an exclamation mark)
(-1 byte thanks to Taylor Scott reminding me that the final double-quote was optional)

\$\endgroup\$
  • 1
    \$\begingroup\$ Could you remove the space after Hi and replace 5 with 4? \$\endgroup\$ – Shaggy May 21 at 12:24
  • \$\begingroup\$ @Shaggy ... Yes, yes I could. No idea how I missed that, thank you \$\endgroup\$ – Chronocidal May 21 at 12:27
  • 1
    \$\begingroup\$ You can drop a byte by removing the very last " from this solution, and as you use evaluate notation (the square brackets) you should mark this solution as being Excel VBA, as that notation is only available in Excel \$\endgroup\$ – Taylor Scott Jun 6 at 12:18
3
\$\begingroup\$

J, 22 bytes

', I''m J!',~'Hi',3}.]

Try it online!

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

Rust, 41 bytes

|x:&str|print!("Hi{}, I'm Rust!",&x[3..])

Try it online!

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

05AB1E, 23 21 bytes

Saved 2 bytes thanks to Kevin Cruijssen

',«#À„Hiš"05AB1E!"ªðý

Try it online!

Explanation

',«                    # append ","
   #                   # split on spaces
    À                  # rotate left
     „Hiš              # prepend "Hi"
         "05AB1E!"ª    # append the language name
                   ðý  # join on spaces
\$\endgroup\$
  • \$\begingroup\$ 21 bytes. And too bad the exclamation mark is there.. Since •äƵí•hR is 1 byte shorter than "05AB1E". :) \$\endgroup\$ – Kevin Cruijssen May 21 at 7:44
  • \$\begingroup\$ @KevinCruijssen: Wow! I feel stupid that I didn't start with the ",". Yeah I tried •äƵí•hR as well, but as you say, it unfortunately doesn't save any here. \$\endgroup\$ – Emigna May 21 at 8:08
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\$
  • \$\begingroup\$ So you could exchange the middle two lines and change the language to Retina and still beat @KevinCruijssen's answer? \$\endgroup\$ – Neil May 21 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 May 21 at 15:22
  • \$\begingroup\$ Ah, but my answer only works for Retina 1, not Retina 0.8.2 though. \$\endgroup\$ – Neil May 21 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\$
  • 1
    \$\begingroup\$ Shouldn't it be like this instead? \$\endgroup\$ – attinat May 21 at 8:06
  • 2
    \$\begingroup\$ or better, 25 bytes \$\endgroup\$ – attinat May 21 at 8:09
  • \$\begingroup\$ @attinat Ah, of course, hadn't even noticed the incorrect output.. >.> And thanks for the -1! \$\endgroup\$ – Kevin Cruijssen May 21 at 8:43
3
\$\begingroup\$

bash, 24 bytes

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

TIO

\$\endgroup\$
  • \$\begingroup\$ replace bash with $0 to save a couple of bytes \$\endgroup\$ – roblogic May 23 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 at 18:16

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.