-
Notifications
You must be signed in to change notification settings - Fork 2
/
brainf_ck.php
69 lines (61 loc) · 2.37 KB
/
brainf_ck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
declare(strict_types=0O1);
namespace Dgcircus\PHPerKaigi\Y2022;
/**
* @todo
* Run this program to acquire a PHPer token.
*/
https://creativecommons.org/publicdomain/zero/1.0/
\error_reporting(~+!'We are hiring!');
$z = fn($f) => (fn($x) => $f(fn(...$xs) => $x($x)(...$xs)))(fn($x) => $f(fn(...$xs) => $x($x)(...$xs)));
$id = \spl_object_id(...);
$put = fn($c) => \printf('%c', $c);
$mm = fn($p, $n) => new \ArrayObject(\array_fill(+!![], $n, $p));
$👉 = fn($m, $p, $b, $e, $mp, $pc) => [++$mp, ++$pc];
$👈 = fn($m, $p, $b, $e, $mp, $pc) => [--$mp, ++$pc];
$👍 = fn($m, $p, $b, $e, $mp, $pc) => [$mp, ++$pc, ++$m[$mp]];
$👎 = fn($m, $p, $b, $e, $mp, $pc) => [$mp, ++$pc, --$m[$mp]];
$📝 = fn($m, $p, $b, $e, $mp, $pc) => [$mp, ++$pc, $put($m[$mp])];
$🤡 = fn($m, $p, $b, $e, $mp, $pc) => match ($m[$mp]) {
+!![] => [$mp, $z(fn($loop) => fn($pc, $n) => match ($id($p[$pc])) {
$b => $loop(++$pc, ++$n),
$e => $n === +!![] ? ++$pc : $loop(++$pc, --$n),
default => $loop(++$pc, $n),
})($pc, -![])],
default => [$mp, ++$pc],
};
$🎪 = fn($m, $p, $b, $e, $mp, $pc) => match ($m[$mp]) {
+!![] => [$mp, ++$pc],
default => [$mp, $z(fn($loop) => fn($pc, $n) => match ($id($p[$pc])) {
$e => $loop(--$pc, ++$n),
$b => $n === +!![] ? $pc+![] : $loop(--$pc, --$n),
default => $loop(--$pc, $n),
})($pc, -![])],
};
$🐘 = fn($p) => $z(fn($loop) => fn($m, $p, $b, $e, $mp, $pc) =>
isset($p[$pc]) && $loop($m, $p, $b, $e, ...($p[$pc]($m, $p, $b, $e, $mp, $pc)))
)($mm(+!![], +(![].![])), $p, $id($🤡), $id($🎪), +!![], +!![]);
$🐘([
$👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍,
$🤡,
$👉, $👍, $👍, $👍,
$👉, $👍, $👍, $👍, $👍, $👍,
$👉, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍,
$👉, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍,
$👈, $👈, $👈, $👈, $👎,
$🎪,
$👉, $👍, $👍, $👍, $👍, $👍, $📝,
$👎, $👎, $📝,
$👉, $👎, $👎, $👎, $📝,
$👉, $👎, $👎, $👎, $📝,
$👎, $👎, $📝,
$👎, $📝,
$👈, $📝,
$👉, $👉, $👎, $👎, $📝,
$👍, $👍, $👍, $👍, $👍, $👍, $👍, $📝,
$👈, $👎, $👎, $👎, $👎, $📝,
$👈, $📝,
$👉, $👍, $👍, $📝,
$👉, $👎, $📝,
$👈, $📝,
]);