g | x | w | all
Bytes Lang Time Link
043Lua231215T212540Zbluswimm
028Vim231215T190428ZAaroneou
006Thunno 2230721T062842ZThe Thon
035JavaScript221206T113450ZShaggy
019><>221206T105919ZEmigna
009Japt221030T202634ZShaggy
097x86‑64 machine code on Linux221101T195054ZKai Burg
037Julia 1.0221101T202127Zamelies
017Gaia221030T111412ZCliff
019Pushy221030T104939ZFlipTack
030jq R221030T100659Zpmf
039Python220731T184703Zsolid.py
047C clang220817T124431Zjdt
137Swift220817T101826ZLeena
076Regex Boost220811T001922ZDeadcode
044sed220801T213951ZJiří
026Zsh220810T064046Zpxeger
038C# function220804T094332ZAcer
055C gcc220805T154411Zc--
179PHP function220802T203515ZRam Chan
180brainfuck220804T172807Zengineer
041*><>220804T153139ZGeoffrey
015J220803T152005ZConor O&
035Ruby220803T142713Zgame0ver
054Alice220803T022228ZJulian
041R function220803T014012Zqdread
nansimply220731T173713ZIsmael M
145Rust full program220802T090604Zmousetai
037PowerShell220802T053736Zmazzy
023Knight220801T232715Z97.100.9
035PowerShell Core220801T220547Zuser3141
046vim220801T212931ZRay
038Excel220801T212654ZEngineer
00905AB1E220801T071221ZKevin Cr
005Vyxal s220731T120234Zlyxal
023Perl 5 + pl220731T090135ZDom Hast
039Kustom220801T105225ZLeaf
015BQN220801T085715ZDominic
005Vyxal220731T192728ZnaffetS
008Jelly220731T175918ZJonathan
025Pyth220731T172011Zprincesa
025lin220731T140454ZMama Fun
4535JavaScript220731T080333Zm90
033Factor + sequences.repeating220731T070540Zchunes
030Haskell220731T063940Zxnor
033Haskell220731T062014ZChristia
027Retina220731T061906ZNeil
013Charcoal220731T061740ZNeil

Lua, 43 bytes

print(("HelloWorld"):rep(#...):sub(1,#...))

Try it online!

Vim, 28 bytes

D@=le<Tab>@")
iHelloWorld<Esc>@=
|lD

Try it online!

Explanation

D                   # Delete the input into the @" register
 @=                 # Set @= register to:
   le<Tab>  )       #   The length of:
          @"        #     The @" register
iHelloWorld<Esc>    # Type "HelloWorld" @= times
                @=  #
|                   # Move cursor to position @=
 lD                 # Delete everything after the cursor

Thunno 2, 6 bytes

khỊsØE

Try it online!

Explanation

khỊsØE  # Implicit input
khỊ     # Push "HelloWorld"
   sØE  # Extend/truncate it
        # to the input's length
        # Implicit output

JavaScript, 35 bytes

I/O as an array of characters.

s=>s.map((_,x)=>"HelloWorld"[x%10])

Try it online!

><>, 19 bytes

"HelloWorld"i0(?;{o

Try it online!

Explanation

"HelloWorld"         # push the string "HelloWorld"
            i0(?;    # take input, if there isn't more input, exit program
                 {o  # else print the bottom of the stack

Japt, 9 bytes

î`HÁMWld

Try it

î`HÁMWld     :Implicit input of string
î             :Repeat & slice the following to length of input
 `HÁMWld     :  Compressed string "HelloWorld"

x86‑64 machine code on Linux, 97 B

input

source code

Uses NASM – the Netwide Assembler. Overview of algorithm:

  1. Infinitely wait until data become available. (select)
  2. Query total number of Bytes immediately available for reading. (FIONREAD)
  3. Discard input. (TCIFLUSH)
  4. Integer division: Bytes that were available for reading count divided by 10.
  5. Loop: Whole 10 Byte writes of 'HelloWorld'.
  6. Write remainder of integer division Bytes.
global _start

bits 64
default rel

; These two constants rather serve as documentation:
STDIN_FILENO         equ   0
STDOUT_FILENO        equ   1
; Linux (`syscall`) system call numbers used in this program:
sys_exit             equ   60
sys_ioctl            equ   16
sys_select           equ   23
sys_write            equ   1
; `ioctl(2)` requests used:
FIONREAD             equ   0x0000541B
TCFLSH               equ   0x0000540B
; Argument to `TCFLSH` request:
TCIFLUSH             equ   0


; ==============================================================
section .text
hello_world:
    db 'Hello'
    db 'World'
; 'HelloWorld'’s length is `10`, but this is cleaner style:
hello_world_length   equ   $ - hello_world

_start:
    ; rax    rdi  rsi    rdx   r10   r8
    ; select(  1, [rsp], NULL, NULL, NULL)
    push 1                      ; bitfield with LSB set
    mov rsi, rsp                ; *readfds
    pop rdi                     ; nfds
    push rdi                    ; rsp for get_iteration_count
    mov al, sys_select
    syscall
    
get_input_length:
    ; rax   rdi           rsi       rdx
    ; ioctl(STDIN_FILENO, FIONREAD, [rsp])
    
    xor edi, edi                ; fd := 0 (STDIN_FILENO)
    xchg rsi, rdx               ; bytes available buffer
    mov si, FIONREAD            ; ioctl(2) request number
    mov al, sys_ioctl
    syscall
    
discard_input:
    ; rax   rdi           rsi     rdx
    ; ioctl(STDIN_FILENO, TCFLSH, TCIFLUSH)
    
    mov edx, edi                ; TCIFLUSH = 0 → copy zero
    mov sil, TCFLSH & 0xFF      ; TCFLSH − 0x10 = FIONREAD
    mov al, sys_ioctl
    syscall
    ; `rax` may be non-zero now, in particular −ENOTTY.
    test eax, eax               ; for dumb last char = "\n" test
    setns dil                   ; subtrahend = 0 for ENOTTY
    
get_iteration_count:
    ; Retrieve number of Bytes that were available for reading.
    pop rax
    sub eax, edi                ; subtract 1 if this is terminal
    jc exit                     ; user typed ^D (detach input)
    
    ; Load divisor.
    push hello_world_length
    pop rcx
    ; eax := number of whole writes; edx := Bytes in partial write
    div ecx
    
    ; Save Bytes in partial write for `finish_write` below.
    ; The `push rdx`/`pop rdx` pattern is just two 2 Bytes.
    push rdx
    
    ; Use `ebx` as loop counter, because `syscall` clobbers `rcx`
    ; and this does not require a REX prefix like r8 – r15 do.
    xchg eax, ebx
write:  
    ; rax   rdi            rsi          rdx
    ; write(STDOUT_FILENO, hello_world, 10)
    xchg edx, ecx
    lea rsi, [hello_world]
    mov dil, STDOUT_FILENO
    
    test ebx, ebx               ; zero _whole_ writes test
    jz finish_write             ; zero entire 10B writes
keep_writing:
    mov al, sys_write
    syscall
    dec ebx
    jnz keep_writing
    
    ; Write the remainining ≤ 9 Bytes.
finish_write:
    pop rdx
    mov al, sys_write
    syscall

exit:
    xchg ebx, edi               ; rdi := 0 (= “successful”)
    push sys_exit               ; need to wipe entire register
    pop rax                     ; because we may have jumped
    syscall                     ; here from get_iteration_count

; vim: ft=nasm:

disassembly

helloWorld.o:     file format ELF64-x86-64


Disassembly of section .text:

0000000000000000 <hello_world>:
   0:   48                      rex.W
   1:   65 6C                   gs ins byte ptr es:[rdi], dx
   3:   6C                      ins    byte ptr es:[rdi], dx
   4:   6F                      outs   dx, dword ptr ds:[rsi]
   5:   57                      push   rdi
   6:   6F                      outs   dx, dword ptr ds:[rsi]
   7:   72 6C                   jb     75 <exit + 0x1B>
   9:   64                      fs

000000000000000A <_start>:
   A:   6A 01                   push   0x1
   C:   48 89 E6                mov    rsi, rsp
   F:   5F                      pop    rdi
  10:   57                      push   rdi
  11:   B0 17                   mov    al, 0x17
  13:   0F 05                   syscall 

0000000000000015 <get_input_length>:
  15:   31 FF                   xor    edi, edi
  17:   48 87 F2                xchg   rdx, rsi
  1A:   66 BE 1B 54             mov    si, 0x541B
  1E:   B0 10                   mov    al, 0x10
  20:   0F 05                   syscall 

0000000000000022 <discard_input>:
  22:   89 FA                   mov    edx, edi
  24:   40 B6 0B                mov    sil, 0xB
  27:   B0 10                   mov    al, 0x10
  29:   0F 05                   syscall 
  2B:   85 C0                   test   eax, eax
  2D:   40 0F 99 C7             setns  dil

0000000000000031 <get_iteration_count>:
  31:   58                      pop    rax
  32:   29 F8                   sub    eax, edi
  34:   72 24                   jb     5A <exit>
  36:   6A 0A                   push   0xA
  38:   59                      pop    rcx
  39:   F7 F1                   div    ecx
  3B:   52                      push   rdx
  3C:   93                      xchg   ebx, eax

000000000000003D <write>:
  3D:   87 D1                   xchg   ecx, edx
  3F:   48 8D 35 BA FF FF FF    lea    rsi, [rip + 0XFFFFFFFFFFFFFFBA]
  46:   40 B7 01                mov    dil, 0x1
  49:   85 DB                   test   ebx, ebx
  4B:   74 08                   je     55 <finish_write>

000000000000004D <keep_writing>:
  4D:   B0 01                   mov    al, 0x1
  4F:   0F 05                   syscall 
  51:   FF CB                   dec    ebx
  53:   75 F8                   jne    4D <keep_writing>

0000000000000055 <finish_write>:
  55:   5A                      pop    rdx
  56:   B0 01                   mov    al, 0x1
  58:   0F 05                   syscall 

000000000000005A <exit>:
  5A:   87 DF                   xchg   edi, ebx
  5C:   6A 3C                   push   0x3C
  5E:   58                      pop    rax
  5F:   0F 05                   syscall 

Having the 'HelloWorld' string in the .text section is weird, but putting (read-only) data into an already/definitely existing section, i. e. .text, makes the executable file smaller. The stripped ELF64 executable file has a size of merely 440 B, not that that really mattered for code golfing.

output

limitations

Julia 1.0, 37 bytes

~=length;!a=("HelloWorld"^(~a))[1:~a]

Try it online!

Gaia, 17 bytes

l:“HelloWorld”פ<

Try it online!

Pretty standard approach I think. It's a shame Gaia does not have a reshape to length built-in like BQN/J :(

Explained

l:“HelloWorld”פ<
l                  # Length of the input
 :                 # push a second copy of that
  “HelloWorld”     # push the string "HelloWorld" to the stack
              ×    # repeat that string by the length of the input
               ¤<  # push the second copy of the length to the top of the stack and get the first n characters of the string

Pushy, 19 bytes

LF`dlroWolleH`^:N'}

Try it online!

jq -R, 30 bytes

("HelloWorld"*length)[:length]

Try it online!

Python, 39 bytes

lambda s:('HelloWorld'*len(s))[:len(s)]

Attempt This Online!

Python, 39 bytes

Alternative version proposed by mazunki:

lambda s:('HelloWorld'*(l:=len(s)))[:l]

Attempt This Online!

C (clang), 47 bytes

i;f(*s){for(i=0;*s;*s++="HelloWorld"[i++%10]);}

Try it online!

Swift, 137 bytes

 var a = readLine()!,h = "HelloWorld",c = h.count,j = a.count,i = Int(j/c),s="";for _ in 0..<i {s += h};s += String(Array(h)[0..<j - i*c])

Regex (Boost), 76 bytes

s/(.(.(.(.(.(.(.(.(.(.)?)?)?)?)?)?)?)?)?)?/?1H?2e?3l?4l?5o?6W?7o?8r?9l?10d/g

Try it online!

This is a single regex substitution, to be applied once.

It uses nested conditional replacement. The number of capture groups that get set is the number of characters matched, and they will always be consecutively numbered starting at 1.

It will start by matching the full 10 character length as many times as possible, which will be replaced each time with the full HelloWorld string. Then when it reaches a point where there are fewer than 10 characters remaining, it will do its last replacement.

Regex (PCRE2), 116

s/(.(.(.(.(.(.(.(.(.(.)?)?)?)?)?)?)?)?)?)?/${1:+H${2:+e${3:+l${4:+l${5:+o${6:+W${7:+o${8:+r${9:+l${10:+d}}}}}}}}}}/g

Try it on regex101!
Try it online!

PCRE2's conditional replacement syntax is quite a bit more verbose. But you can run this on regex101 and see it work in real time as you type (make sure to erase the test cases first, so it's as fast as possible).

sed, 111 55 51 44 bytes

s/./a/
:a
s/^/HelloWorld/
s/.\{10\}$//
/a/ba

Attempt This Online!

Zsh, 26 bytes

<<<${(r:$#1::HelloWorld:)}

Attempt This Online!

C# (function), 38 bytes

x=>x.Select((_,i)=>"HelloWorld"[i%10])

Try it online!

---

C# (full program), 102 96 bytes

-6 bytes thanks to TKirishima

using System.Linq;System.Console.WriteLine(args[0].Select((_,i)=>"HelloWorld"[i%10]).ToArray());

This is a complete program in C#10 thanks to implicit top-level statements. TIO doesn't support this, but .NET Fiddle does.

C (gcc), 55 bytes

main(c){for(;~getchar();)printf(L"dHelloWorl"+c++%10);}

Try it online!

PHP (function), 179 bytes

Used own logic and avoid system define function

function fnc($rs,$as){$dr="";$fv=explode(".",strval(strlen($as)/strlen($rs)));while((int)$fv[0]>0){$dr.=$rs;(int)$fv[0]--;}return $dr.=substr($rs,0,(int)strlen($as)%strlen($rs));}

Try it online!

PHP, 90 bytes

Sugested by @Steffan

function fnc($a){for($f=strlen($a);$f--;)$d.="HelloWorld";return substr($d,0,strlen($a));}

Try it online!

brainfuck, 180 bytes

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

Try it online!

Can likely be golfed quite a bit more, as the majority of the code is setting up the string "HdlroWolle" on the tape.

Explanation:

>+[++[++>]<<+]>+                          108 = 'l'
[->>+>+>+>+>+>+>+>+>+<<<<<<<<<<]          ptr before '\0lllllllll'

-[>+<-------]>-                           ptr on 'H'

>--------                                 'd'
>                                         'l'
>++++++                                   'r'
>+++                                      'o'
>---------------------                    'W'
>+++                                      'o'
>                                         'l'
>                                         'l'
>-------                                  'e'    ("HdlroWolle")

> ,[>+<,]         [Read all input, counting the length of it 2 cells after the string.]

>[-<                                      Do len(input) times: 

<[                                        Shift the string right by 1
    [->+<]
    <
]
[see https://www.codingame.com/playgrounds/50443/brainfuck-part-2---working-with-arrays]

[Print the first character of the string and move the far 
 right cell back to the beginning, rotating the string.]
>>.>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]

>]                                        End loop

*><>, 41 bytes

Uses the -i flag to initialize the stack with our input value.

l1["dlroWolleH"    v
or1-:?!;rl2(?!u20.O>

Try it online!

Explanation

l                    Push the length of the stack onto the stack
 1[                  Pop that length value into a new stack
    "dlrowolleh"     Push "HelloWorld" reversed onto the stack
                   v Change IP Direction downward

                   > Change IP direction rightward
o                    Pop a value off the stack, print it as a char
 r                   Reverse the stack, putting the length value on the top of the stack
  1-:                Subtract one from that value
     ?!;             If that value is 0, halt execution
        r            Reverse the stack
         l           Check the length of the stack
          2(         Is it less than two (Do we have more to print, but have run out of our HelloWorld string)
            ?!u      If NOT, ignore instructions until the next O
               20.   If so, jump to [0,2] in the code box, just before pushing HelloWorld onto the stack
                  O  Else, continue onto the >

J, 15 bytes

'HelloWorld'$~#

Try it online!

Very straightforward.

Explanation

'HelloWorld'$~#
            $~     reshape
'HelloWorld'       this string
              #    by the length of the input

Ruby, 37, 35 bytes

->x{('HelloWorld'*l=x.size)[0...l]}

Try it online!

-2 bytes thanks to @Steffan

Alice, 54 bytes

/ H l o o l " \w>?hn$vihn$@?]oK
 " e l W r d !  ^(H' <

Try it online!

Flattened

/"HelloWorld"!\w>?hn$vihn$@?]oK
                ^(H' <
/"HelloWorld"!\                  Pushes the hello world string on the tape
               w      ihn$@   K  While where are characters to read on the input
                >?hn$v           If the tape is outside of "HelloWorld"
                ^(H' <           Rewind the tape
                           ?]o   Print one character from the tape and move to the next one

R (function), 41 bytes

`substr<-`(a,1,90,strrep("HelloWorld",9))

I assume this can be improved...

This takes advantage of a feature of substr() I learned when I was today years old: substr() has a replacement function, and if the string replacing the substring is longer than the substring, it is cut off at the appropriate place, which works perfectly for this challenge. We can replace the entire input string a with a string of concatenated "HelloWorld"s with the last one truncated. This will not work for any string longer than 90 characters but no test cases in the input are that long. To make it work for longer strings, you can replace both of the 90 and 9 with nchar(a).

Try it online!

simply, 111 106 bytes

This is (yet another) language I'm just working on, for fun.

It is a very verbose language, and still in progress, which is why the algorithm is ... less conventional and very convoluted...

def&f($v){$C=&str_chunk("HelloWorld"&len($v));send$C[0];}echo&join(&array_map(&str_chunk($argv[0]10)&f)'')

Due to oversights in the parser, the values don't have to have to be separated by commas.


Ungolfed:

Create a function called &handle_chunk with arguments ($value).
Begin
    Assign $len the value of executing the function &len with argument $value.
    
    Set the variable $chunks with the value of calling the function &str_chunk with the arguments "HelloWorld", $len.
    
    Return the value $chunks[0].
End.

Display the result of calling &join(
    Call the function &array_map with the arguments (
        Run &str_chunk($argv[0], 10),
        &handle_chunk
    ),
    ""
).

Should be self-explanatory.


How to run:

Download the repository and open índex.html.



Unintended method:

This is simply a re-implementation of m90's answer:

%c="";def&f($s)call%c->padEnd(&len($s)"HelloWorld");

Works the same way as the intended way.

Rust (full program), 145 bytes

The full program rule doubles the length.

fn main(){for l in std::io::stdin().lines(){print!("{}",(0..).zip(l.unwrap().chars()).map(|i|b"HelloWorld"[i.0%10]as char).collect::<String>())}}

Attempt This Online!

Rust (function), 85 bytes

|l:&str|(0..).zip(l.chars()).map(|i|b"HelloWorld"[i.0%10]as char).collect::<String>()

Attempt This Online!

PowerShell, 37 bytes

-join($args|%{'HelloWorld'[$i++%10]})

Try it online!

Knight, 23 bytes

O G*"HelloWorld"=cL P0c

Try it online!

PowerShell Core, 35 bytes

% L*h|%{'HelloWorld'*$_|% S*g 0,$_}

Try it online!

Windows PowerShell, 38 bytes

% L*h|%{'HelloWorld'*$_|% S*g -a 0,$_}

Same as above, but PS 5.1 requires actually naming the parameter "-ArgumentList" (shortened to "-a") for the Substring() method call.

Input comes from the pipeline.

Nothing fancy; this is basically
ForEach-Object {$l = $_.Length; ('HelloWorld' * $l).Substring(0, $l)}
The expensive method calls can be golfed by using the cmdlet ForEach-Object (that is, its alias "%"), and its possibility to call a method of the input object by name, accepting wildcards.

% L*h|%{'HelloWorld'*$_|% S*g 0,$_}
% L*h                                  # "ForEach-Object -MemberName Length": invoke the method "Length" for the string passed in the pipeline
     |                                 # Pipe the length of the input string to the next cmdlet
      %{                               # "ForEach-Object -ScriptBlock {"
        'HelloWorld'*$_                #     repeat the string 'HelloWorld' <Length> times
                       |               #     and pipe the 'HelloWorldHelloWorld...' to the next cmdlet
                        % S*g 0,$_     #     "ForEach-Object -MemberName Substring -ArgumentList 0, <Length>": invoke the method "Substring" for the string passed in the pipeline, get <Length> chars starting at 0
       }                               # }: end of the scriptblock; Output is implicit

vim, 46 bytes

$mma<C-R>=col('$')
aHelloWorld<C-V><ESC><ESC>`mlDo<ESC>@"khjllDkdd

Annotated

$mm                      # Go to the end of input and mark our position
a                        # Append...
  <C-R>=col('$')         #   The column offset/line length
  aHelloWorld<C-V><ESC>  #   This exact string
<ESC>                    # ...which yields a command that prints "HelloWorld"
                         # once per char in the original input. (All that matters
                         # is that this string is at least as long as the output 
                         # needs to be.)

`mlD                     # Delete the string we just appended, copying into register "
o<ESC>@"                 # Run the command, putting a bunch of "HelloWorld"s on next line
khjllD                   # Make the new line the same length as the input
kdd                      # delete the input

<C-R> is 0x12, <ESC> is 0x1b, <C-V> is 0x16.

Try it online!

Excel, 38 bytes

=LEFT(REPT("HelloWorld",3276),LEN(A1))

Input is in the cell A1. Output is wherever the formula is.

Repeats the string as many times as allowed based on the limitations of inputs to LEFT() and the truncates all but the left-most characters based on the length of the input.

enter image description here

05AB1E, 9 bytes

”Ÿ™‚ï”áI∍

Input as a list of characters.

Try it online or verify all test cases.

Explanation:

”Ÿ™‚ï”     # Push dictionary string "Hello World"
      á    # Only keep letters to remove the space: "HelloWorld"
       I   # Push the input-list
        ∍  # Shorten/extend the "HelloWorld" string to its length
           # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”Ÿ™‚ï” is "Hello World".

Vyxal s, 5 bytes

ẏkhȧİ

Try it Online!

Can't believe I had to find a new 5 byter because someone got my answer by 2 bytes shorter :p.

Explained

ẏkhȧİ
ẏ     # The range [0, len(input)]
 khȧ  # The string "HelloWorld"
    İ # The range indexed into the characters of the string.

Vyxal sr, 5 bytes

khȧf•

Try it Online!

More flags and more ways that I won't be outgolfed again. Takes input as a list of characters

Explained

khȧf•
khȧf  # The string "HelloWorld" as a list of chars
    • # Molded to the shape of the input

Perl 5 + -pl, 23 bytes

Inspiration taken from @Neil's Retina answer. 3 bytes saved thanks to @Sisyphus!

$_&=HelloWorld x y//./c

Try it online!

Explanation

Sets $_ (which will be implicitly output via -p) to the result of stringwise ANDing a string of HelloWorlds repeated once for the count of each char in the input (implicitly stored in $_ via the implicit -n from -p) when tr///ansliterated (y///) from any char to \xFFs. This operation results in a string the length of the original input with the content HelloWorld truncated accordingly.

Kustom, 39 bytes

Basically just this Javascript answer.

The extra byte is for the global variable name.

$tc(rpad,"",tc(len,gv(i)),HelloWorld)$

BQN, 15 bytes

"HelloWorld"⥊˜≢

Try it at BQN REPL

"HelloWorld"⥊˜≢
               ≢    # get the shape (length) of the input
            ⥊˜      # and use this to reshape
"HelloWorld"        # the string "HelloWorld"
                    # (recycling elements if required)

Vyxal, 5 bytes

LkhȧẎ

Try it Online!

Jelly, 8 bytes

“ ⁷ỴNt»ṁ

A monadic Link that accepts a list of characters and yields a list of characters.

Try it online!

How?

Pretty simple...

“ ⁷ỴNt»ṁ - Link: list of characters, S
“ ⁷ỴNt»  - dictionary lookup -> "HelloWorld"
       ṁ - mould like S

Pyth, 25 bytes

FNrZlwp@"HelloWorld"%N 10

Try it online!

PS: first time using Pyth & this platform is awesome!

lin, 25 bytes

"HelloWorld"`cyc.~ len `t

Try it here! Returns an iterator.

For testing purposes:

"how are you" ; `_` outln
"HelloWorld"`cyc.~ len `t

Explanation

Cycle and take (input length) items.

JavaScript, 45 35 bytes

s=>"".padEnd(s.length,"HelloWorld")

Try it online!

−10 thanks to Arnauld.

Factor + sequences.repeating, 33 bytes

[ "HelloWorld"swap length cycle ]

Try it online!

Haskell, 30 bytes

map fst.zip(cycle"HelloWorld")

Try it online!

A cute way to truncate one string to the length of another is to zip them together, which truncates the longer string, then extract the desired string with map fst.

Longer alternatives:

fst.unzip.zip(cycle"HelloWorld")
zipWith const$cycle"HelloWorld"

Haskell, 33 bytes

($cycle "HelloWorld").take.length

Try it online!

Retina, 27 bytes

T`p`~
Y`~`\He\l\l\oW\or\l\d

Try it online! Explanation:

T`p`~

Translate all the characters to ~s.

Y`~`\He\l\l\oW\or\l\d

Cyclically translate all the ~s to the characters HelloWorld. Note that unfortunately most of them have special meanings to translate so that they have to be quoted.

Charcoal, 13 bytes

…HelloWorldLS

Try it online! Link is to verbose version of code. Explanation:

 HelloWorld     Literal string `HelloWorld`
…               Reshaped to length
           L    Length of
            S   Input string