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.
3
votes
Crack the code to the combination lock
JavaScript ES6 – 53 43 bytes
f=n=>n.replace(/.. ?/g,a=>(1+a[1]-a[0])%10)
Fairly straightforward function, uses regex to get the numbers. Try it out at http://jsfiddle.net/efc93986/1/. If function …
8
votes
Integer mark into grade
Retina, 43 + 15 = 58 bytes
...+
A
.[012]
$&-
.[789]
$&+
^9.
B
^8.
C
^7.
D
6.
E
\d.*
F
Retina is a regex language created by Martin Büttner, where the odd-numbered files are the regex to match with, …
3
votes
A Spintax {Task|Problem|Question}
JavaScript ES6, 86 84 bytes
f=s=>s.repeat(5).replace(/{(.+?)}/g,(_,e)=>(p=e.split`|`)[Math.random()*p.length|0])
This expects the input to have a trailing newline. It starts by repeating the input …
3
votes
Implement a FuzzyFinder
JavaScript ES6, 68 bytes
(s,l,f=j=>j.indexOf(s))=>l.filter(w=>~f(w)).sort((a,b)=>f(a)>f(b))
This is an anonymous function that takes parameters s (file path string) and l (array of strings). The St …
0
votes
Complementary colors
CJam, 16 bytes
qA,'G,65>+s_W%er
This is fairly long because CJam handles base changes differently, so it was shorter to just do transliteration. See my Retina answer for more on transliteration.
T …
7
votes
Complementary colors
Retina, 13 10 bytes
T`w`G-A9-0
There are three parts to the code, separated by backticks (`): T specifies transliterate mode, which replaces each character in the second part with its corresponding …
1
vote
Stack a random number of cups into a perfect two dimensional pyramid (triangle)
JavaScript (ES6) – 47
p=n=>{for(t=i=0;i+t<n;)t+=i++;return i-1+','+t}
For now only works on Firefox. The following works on any recent browser at 55 bytes:
p=function(n){for(t=i=0;i+t<n;)t+=i++;retur …
1
vote
Output Graham's Number
JavaScript 179
n='';a=Array;for(b=64;b>1;)n+=(c=a(65-b).join(' '))+'3^^'+a(2*b).join('.')+'^3\n'+c+' \\'+(u=a(b--).join('_'))+' '+u+'/\n'+(d=a(64).join(' '))+' \\/\n'
console.log(n+d+'3^^^^3')
Te …
3
votes
Print all Country Codes
JavaScript ES6, 336 322
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alert(r='tr20d,yxurj,soeyn,1migz,rbh14,5hqc,13w82y,z1c,iqx33,l8dmo,1swln,zokqa,tukfz,r8voh,jzd34,mflqi,jzjen,10gn1k,13ycc7,sn0bd,kbb0j,qm2h …
2
votes
Unscramble the Source Code
JavaScript, 26 (cracked)
later(103>(8-9)&80>4|10>9)
Output
999
4
votes
Unscramble the Source Code
JavaScript, length 32 (cracked)
alert('HaVobp'.match(/[HaVt]+/))
Output
puGiXm
7
votes
Fifty Shades of Grey
JavaScript, 87 90 bytes
for(i=90;i>40;)document.write('<p style=background:#'+i+i+i--+';height:9ex;width:9ex>')
This outputs squares to the HTML, because it is really JavaScript's only met …
2
votes
Solve a Diagonal Burrows-Wheeler transform
JavaScript ES6, 41 + 49 = 90 bytes
Encoder
(t=>t.replace(/./g,(_,o)=>t[o*2%t.length]))('Hello World')
Decoder
(t=>t.replace(/./g,(_,o)=>t[-~(l=t.length)/2*o%l]))('HloWrdel ol')
These are anon …
0
votes
Decode a Rövarspråket string
JavaScript ES6, 108 bytes
F=s=>{
for(n='',i=0;i<s.length;n+=c)c=s[i],i+=~'bcdfghjklmnpqrstvwxyz'.indexOf(c.toLowerCase())?3:1
return n
}
To make this interesting, I tried to do this entirely wi …
23
votes
Ninjas and Monkeys and Bears, Oh My!
JavaScript ES6, 86 bytes
f=s=>'NBM BM NB M B N'.replace(/\S+/g,e=>(i=0,s=s.replace(RegExp(e,'g'),_=>++i))&&i+e)
(I just had to answer this.) It goes through each substring of NBM, starting with the …