Skip to content

Instantly share code, notes, and snippets.

View phroggyy's full-sized avatar
🔥
Building the world's best incident management platform

Leo Sjöberg phroggyy

🔥
Building the world's best incident management platform
View GitHub Profile
<?php
$f = str_split(file('i')[0]);
$map = [
'^' => [1,0],
'>' => [0,1],
'v' => [-1,0],
'<' => [0, -1],
];
<?php
$input = str_split(file('i')[0]);
$map = [
'^' => [1,0],
'>' => [0,1],
'v' => [-1,0],
'<' => [0,-1],
];
<?php $p=$r=0;foreach(file('i')as$g){$g=explode('x',$g);sort($g,1);$z=$g[0]*$g[1];$y=$g[0]+$g[1];$p+=2*$g[2]*$y+3*$z;$r+=$y*2+$z*$g[2];}echo"$p,$r";
<?php
array_walk($x=file('i'),function(&$g) {
$g=explode('x', $g);
sort($g, SORT_NUMERIC);
});
$p = $r = 0;
foreach ($x as $g) {
$p += 2*($g[0]*$g[1] + $g[0]*$g[2] + $g[1]*$g[2]) + $g[0]*$g[1];
$r += 2*($g[0]+$g[1])+array_product($g);
var Vue = require('vue');
var validator = require('vue-validator');
Vue.use(validator);
// Change this when compiling for production
Vue.config.debug = true;
Vue.config.silent = false;
// Register some directives and filters
@phroggyy
phroggyy / directive.php
Created August 5, 2015 22:17
Declare view-specific variables on the fly with a blade directive. Use @var('variable', 'value') to use. Paste the code from this gist into a service provider.
\Blade::directive('var', function($expression) {
$segments = array_map(function($segment) {
return trim($segment);
}, explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression)));
return '<?php $' . $segments[0] . " = '" . $segments[1] . "' ?>";
});