- https://www.codewars.com/kata/586dd26a69b6fd46dd0000c0 Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck).
Started at 22:34 09.10.2020 Friday Oct.
Finished at 22:37 09.10.2020 Friday Oct. (0hrs 3minutes)
Started at 22:34 09.10.2020 Friday Oct.
Finished at 22:37 09.10.2020 Friday Oct. (0hrs 3minutes)
<?php | |
# https://www.codewars.com/kata/586dd26a69b6fd46dd0000c0 Esolang Interpreters #1 - Introduction to Esolangs and My First Interpreter (MiniStringFuck). | |
function my_first_interpreter(string $code): string { | |
$memory = 0; $answer = ""; | |
for($i = 0; $i < strlen($code); $i+=1){ | |
if("+" === $code[$i]){ | |
$memory += 1; | |
$memory = $memory % 256; | |
continue; | |
} | |
if("." === $code[$i]){ | |
$answer .= chr($memory); | |
continue; | |
} | |
} | |
return $answer; | |
} |