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.
0
votes
How many towers can you see?
Matlab, (123)(119)
function r=m(h);p=[h rot90(h) rot90(h,2) rot90(h,3)];for i=2:size(p) p(i,:)=max(p(i,:),p(i-1,:));end;r=sum(diff(p)>0)+1
used like this:
m([
4 3 5 2 1;
5 4 …
1
vote
Print rotation-safe numbers
JavaScript - 168 129 119 113 111 108
F=n=>{for(;~n;n--){r='';for(c of""+n)r=(c-6?c-9?c:6:9)+r;console.log(r-n&&!/[1-57]/.test(r)&&n%10?n+".":n)}}
4 5 6. 8 9. 16 60 66. 68. 69 906 909. 6090 9806 …
3
votes
Magnetic Sculptures
Javascript, 201 193
F=P=>{m=[];for(p of P){s=2;c=m[p]=m[p]||[];for(i=1e4;~i&&s;i--){if((m[p-1]||[])[i]||(m[p+1]||[])[i])s--;if(c[i-1]) s=0}c[++i]=1}g=-1;m.map(c=>{ d=0;for(i in c){g=i-d>g?i-d:g;d=++i …
3
votes
Calculate the points in a "sjoelen"-game
Matlab, 27
Took me a while to understand that it is single player game. With the help of anonymous function
f=@(N)N*[2;3;4;1]+10*min(N)
which is invoked with row vector
f([3 5 4 3]) == 70
f([7 7 …
0
votes
Create an array with repeated numbers
Matlab, 44 * 0.5 = 22
function r=f(n);r=[];for i=1:n;r=[i:n,r];end
f(4) == [4 3 4 2 3 4 1 2 3 4]
Javascript, 63 * 0.5 = 31.5
F=n=>{r=[m=n];while(--n){r=r.s …