Initial commit
This commit is contained in:
commit
6b0c875bb2
48
phpfrick.php
Normal file
48
phpfrick.php
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/env php
|
||||
<?php
|
||||
|
||||
function frick(string $str) {
|
||||
$n = [];
|
||||
$n[1] = "(['']||[])";
|
||||
$n[2] = "(" . $n[1] . "+" . $n[1] . ")";
|
||||
$n[3] = "(" . $n[1] . "+" . $n[1] . "+" . $n[1] . ")";
|
||||
$n[4] = "(" . $n[2] . "*" . $n[2] . ")";
|
||||
$n[5] = "(" . $n[2] . "*" . $n[2] . "+" . $n[1] . ")";
|
||||
$n[6] = "(" . $n[3] . "*" . $n[2] . ")";
|
||||
$n[7] = "(" . $n[3] . "*" . $n[2] . "+" . $n[1] . ")";
|
||||
$n[9] = "(" . $n[3] . "**" . $n[2] . ")";
|
||||
$n[0] = "(" . $n[1] . "-" . $n[1] . ")";
|
||||
|
||||
$arraystr = "([].[])"; // ArrayArray
|
||||
|
||||
$c = [];
|
||||
foreach ($n as $number => $code) {
|
||||
$c[(string)$number] = $code . ".[]['']";
|
||||
}
|
||||
|
||||
$c['A'] = $arraystr . "[" . $n[0] . "]";
|
||||
$c['a'] = $arraystr . "[" . $n[3] . "]";
|
||||
$c['d'] = $c['1'] . "^" . $c['4'] . "^" . $c['a'];
|
||||
$c['e'] = $c['0'] . "^" . $c['4'] . "^" . $c['a'];
|
||||
$c['p'] = $c['A'] . "^" . $c['1'];
|
||||
$c['q'] = $c['A'] . "|" . $c['1'];
|
||||
$c['r'] = $arraystr . "[" . $n[1] . "]";
|
||||
$c['s'] = $c['A'] . "|" . $c['2'];
|
||||
$c['t'] = $c['A'] . "^" . $c['5'];
|
||||
$c['u'] = $c['A'] . "|" . $c['4'];
|
||||
$c['v'] = $c['A'] . "^" . $c['7'];
|
||||
$c['w'] = $c['A'] . "|" . $c['6'];
|
||||
$c['x'] = $c['A'] . "^" . $c['9'];
|
||||
$c['y'] = $arraystr . "[" . $n[4] . "]";
|
||||
|
||||
$c['f'] = $c['4'] . "^" . $c['A'] . "^" . $c['r'] . "^" . $c['y'];
|
||||
|
||||
$chars = [];
|
||||
foreach (str_split($str) as $char) {
|
||||
$chars[] = $c[$char];
|
||||
}
|
||||
return "(" . implode(").(", $chars) . ")";
|
||||
}
|
||||
|
||||
echo frick("read");
|
||||
|
Loading…
Reference in New Issue
Block a user