Skip to content

Commit c972cf5

Browse files
committed
Add a PHP solution to problem 236
1 parent 524ec58 commit c972cf5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$inputFile = new SplFileObject($argv[1]);
5+
6+
$inputFile->setFlags(SplFileObject::READ_CSV |
7+
SplFileObject::READ_AHEAD |
8+
SplFileObject::SKIP_EMPTY |
9+
SplFileObject::DROP_NEW_LINE);
10+
11+
$inputFile->setCsvControl('|');
12+
13+
foreach($inputFile as $values)
14+
{
15+
array_walk($values, function(&$n)
16+
{
17+
$n = intval($n, 2);
18+
19+
$n ^= ($n >> 1);
20+
$n ^= ($n >> 2);
21+
$n ^= ($n >> 4);
22+
});
23+
24+
echo join(' | ', $values), PHP_EOL;
25+
}

0 commit comments

Comments
 (0)