| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | No HP | 250922T110101Z | Eka Juar |
| nan | This got bumped and piqued my curiosity. I decided to take on the harder version of the challenge | 240413T031940Z | GammaFun |
| 004 | Uiua | 240412T231821Z | noodle p |
| 003 | Vyxal | 240412T223541Z | emanresu |
| 039 | Ruby | 160501T011137Z | Value In |
| 063 | Python 3.5 | 160430T025319Z | R. Kap |
| 010 | Jolf | 160430T181516Z | Conor O& |
| 025 | Haskell | 160430T153038Z | Michael |
| 040 | JavaScript ES6 | 160430T094029Z | Neil |
| 007 | 05AB1E | 160430T085315Z | Adnan |
| 004 | Jelly | 160430T041348Z | Dennis |
| 009 | Jelly | 160430T034852Z | Leaky Nu |
| 010 | Pyth | 160430T032706Z | Leaky Nu |
| 007 | J | 160430T032136Z | miles |
No HP 83821328446 Hacker Pasword:080312isaw
This got bumped and piqued my curiosity. I decided to take on the harder version of the challenge, reading in a character at a time.
Zsh, 45 bytes
read -k1&&printf %s ${1::3}&&$0 ${1:3}${1::3}
Recursive call with the text rotated by three characters.
No TIO link, it won't work there because no terminal.
To run this,
- either save it as a
#!zshexecutable script, or wrap function declaration such ashacker(){ ... }. - Call it with
stty -echo; hacker 'text to repeat'; stty echoto properly disable echo. - Don't run it for too long, there is no tail call optimization in this version
A proper version with builtin noecho and tail call optimization is 51 bytes:
read -sk1&&printf %s ${1::3}&&exec $0 ${1:3}${1::3}
Ruby, 39 bytes
In Ruby, $< reads from the supplied file in the command line arguments instead of $stdin if one is given. (If you forget to supply a file, you get a blank output because it reads everything out of $stdin in $<.read and thus STDIN.read.size will be 0.)
$><<($<.read*s=3*STDIN.read.size)[0,s]
Python 3.5, 77 65 63 bytes:
lambda g,f:''.join((g*len(f))[i:i+3]for i in range(0,len(f)*3,3))
Simple enough. An anonymous function which takes in two arguments, the first one being the "file" (g), and the second being the characters typed in by the user (f). Then this creates a generator containing every three characters in g, which are found by indexing for every i and then i+3 characters in g, where i is in the range of 0=>(length of f)*3. Finally, it returns each object in the generator joined into one big string. You call this function by assigning a variable to it, and then calling the variable wrapped inside a print() expression. So if the function's name was q, it would be executed like print(q(<byte array here>)).
Jolf, 10 bytes
]*iγl*I30γ
Explanation
]*iγl*I30γ
*i repeat string 1
l*I3 the length of the other string * 3
γ γ = (^)
] 0γ (^).slice(0, γ)
Haskell, 25 bytes
First argument is what's "typed", the second the source to display
(.cycle).take.(3*).length
Or non-pointfree, for (possibly) better readability:
h a=take(3*length a).cycle
JavaScript (ES6), 40 bytes
(s,t)=>s.repeat(l=t.length*3).slice(0,l)
Where s is the data string and t is the user string. Assumes s is nonempty and repeats it l times to ensure that its length is at least l so that it can return the first l characters, where l is three times the length of t.
05AB1E, 7 bytes
Code:
3×g©×®£
Explanation:
3× # Multiply the input string three times.
g # Take the length.
© # Copy that to the register.
× # Multiply by the second input.
® # Retrieve the length from the register.
£ # Only keep [0:length * 3] from the new string.
Jelly, 4 bytes
ẋ3ṁ@
How it works
ẋ3ṁ@ Main link. Arguments: s (input string), t (file string)
ẋ3 Repeat s three times.
ṁ@ Mold; reshape t like the previous result.
This repeats the elements of t over and over until the length matches that
of s repeated thrice.
Jelly, 9 bytes
⁴L×3
ẋ¢ḣ¢
⁴L×3 Define nilad as ¢:
L length of
⁴ second argument
×3 tripled
ẋ¢ḣ¢ Main chain:
the first argument (implicit)
ẋ repeated
¢ ¢ many times
ḣ¢ then get the first ¢ characters of it.
J, 7 bytes
$~(3*#)
Takes two arguments, the text to be repeated and the user's input text.
Usage
The input text is formatted where , means to join and LF is the newline character.
f =: $~(3*#)
('#include <stdio.h>', LF, 'int main() { }') f 'hello world'
#include <stdio.h>
int main() { }
'hello' f 'hello world'
hellohellohellohellohellohellohel