Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active October 19, 2020 19:41
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/94f2342be385ae6f9df321cdc72070e8 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/94f2342be385ae6f9df321cdc72070e8 to your computer and use it in GitHub Desktop.
Just PHP FUN 132.
<?php
# https://www.codewars.com/kata/587c0138110b20624e000253 Esolang: MiniBitMove.
function interpreter(string $tape, string $array): string {
$array = str_split($array);
$pointer = 0;
while ($pointer < count($array)){
for($i = 0; $i<strlen($tape) && $pointer < count($array); $i+=1){
$x = $tape[$i];
if('0' == $x) $pointer += 1;
if('1' == $x) $array[$pointer] = '1' == $array[$pointer] ? '0' : '1';
}
}
return implode($array );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment