Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 9, 2020 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/e01a288ee97cfe8587b79fe0d2549192 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/e01a288ee97cfe8587b79fe0d2549192 to your computer and use it in GitHub Desktop.
Just PHP FUN 124.
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment