Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#PHP, (削除) 57 55 (削除ここまで) 53 bytes

PHP, (削除) 57 55 (削除ここまで) 53 bytes

while(hello!=$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loop through input, print the current character, append it to $s, cut $s to the last 5 characters. Break loop when $s is hello.

#PHP, (削除) 57 55 (削除ここまで) 53 bytes

while(hello!=$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loop through input, print the current character, append it to $s, cut $s to the last 5 characters. Break loop when $s is hello.

PHP, (削除) 57 55 (削除ここまで) 53 bytes

while(hello!=$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loop through input, print the current character, append it to $s, cut $s to the last 5 characters. Break loop when $s is hello.

-2 bytes by moving the assignment to the loop head
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41

#PHP, (削除) 57 55 (削除ここまで) 5553 bytes

forwhile(;$shello!=hello;$s=substr=$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

LoopsLoop through input, printsprint the current character, appendsappend it to $s, and cutscut $s to the last 5 characters. Loop breaksBreak loop when $s is hello.

#PHP, (削除) 57 (削除ここまで) 55 bytes

for(;$s!=hello;$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loops through input, prints the current character, appends it to $s, and cuts $s to the last 5 characters. Loop breaks when $s is hello.

#PHP, (削除) 57 55 (削除ここまで) 53 bytes

while(hello!=$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loop through input, print the current character, append it to $s, cut $s to the last 5 characters. Break loop when $s is hello.

negative substr offset saves 1 byte; echo saves 1 byte
Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41

#PHP, 57(削除) 57 (削除ここまで) 55 bytes

for(;$s!=olleh;$s=substr=hello;$s=substr($c.$s,0.$c,-5))print$c=fgetc(STDIN);

or

for(;$s!=olleh;$s=$c.$s^olleh^olleh)print$c=fgetcecho$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loops through input, prints the current character, prependsappends it to $s, and cuts everything after$s to the firstlast 5 characters. Loop breaks when $s is ollehhello.

#PHP, 57 bytes

for(;$s!=olleh;$s=substr($c.$s,0,5))print$c=fgetc(STDIN);

or

for(;$s!=olleh;$s=$c.$s^olleh^olleh)print$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loops through input, prints the current character, prepends it to $s, and cuts everything after the first 5 characters. Loop breaks when $s is olleh.

#PHP, (削除) 57 (削除ここまで) 55 bytes

for(;$s!=hello;$s=substr($s.$c,-5))echo$c=fgetc(STDIN);

as there are no infinite files, I take input from STDIN. Run with -nr.

Loops through input, prints the current character, appends it to $s, and cuts $s to the last 5 characters. Loop breaks when $s is hello.

Source Link
Titus
  • 14.9k
  • 1
  • 25
  • 41
Loading

AltStyle によって変換されたページ (->オリジナル) /