Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
1
vote
How many lights are on?
Perl, 102 98 91 90 (89 + -n) bytes
perl -nE '$i=ord()%5,$x+=(-1..1)[$i],$y+=((0)x3,1,-1)[$i],$p{$x,$y}^=1 for/./g;say~~grep$_,values%p'
Readable:
$_ = <>; # -n
for (/./g) {
$i = ord() % 5;
$x …
4
votes
The Saltine Challenge
Perl 201
(remove newlines except the first one to get the #)
$_=" 46|6
15.5.5|15.5.5|198|";
s/1/| .5.5. ||/g;
s/\d/(5^$&?_:$")x$&/ge;
@o=@l=/.{18}.?/g;
map{
$s=$_*7;
substr$o[$_-5],$s,12,$l[$_]for …
0
votes
Construct a Ladder
Perl 98
sub l{$r=0;@a=grep$a->[$_],0..$#$a;@b=grep$b->[$_],0..$#$b;$r+=sqrt 1+(shift(@a)-shift@b)**2 while@a&&@b;$r}
Readable:
sub l {
$r = 0;
@a = grep $a->[$_], 0 .. $#$a;
@b = grep …