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.
2
votes
Rock Paper Scissors
Javascript, 117 characters
Here's a data-driven approach to the problem. This can probably be optimized by generating the win/lose/draw data instead of mapping it manually, but it's a start :)
Golfed …
6
votes
Accepted
Musical Score Interpreter
Javascript,284,279,278,225,221,220 Characters (including necessary whitespace)
One-liner (test fiddle):
function a(c){b='',d=c.split('\n');for(e=0;d[0][e++];){f=0;for(i=0;g=d[i++];){h=g[e-1];if(h== …
7
votes
Accepted
Multiples of 67 in a constructed array of arrays?
JavaScript: 91, 88 (thanks trinithis), 84, 77 (thanks again trinithis), 75 (thanks shesek), 74 Characters (thanks Shmiddty)
91-->88 - See Trinithis's comment
88-->84 - moved j-- into conditional chec …
3
votes
Choose Your Own Adventure
Javascript: 189 Characters
This is a recursive solution that finds the shortest path through the adventure.
Code-Golfed:
a=prompt().split('\\n');b=0;while(!(d=c(b++,1)));function c(e,f,i,g){if(e>0 …
0
votes
Jolly Jumper Sequence
JavaScript: 105 (easy mode)
Golfed:
function a(l){for(r=i=1;i<(m=l.length);i++){for(j=t=0;j+1<m;)t+=(d=l[j]-l[++j])*d==i*i;t||(r=0)}return r}
Un-golfed:
function isJolly(list){
//Iterate over …
3
votes
Hexadecimal To Decimal
JavaScript, 127 119 characters (thanks trinithis!)
Code-Golfed:
function f(n){for(o=i=0,c=1;l=n[i++];)o*=16,l=l.charCodeAt(0),o+=l-(l>96?87:l>64?55:48);return /[\W_g-z]/i.test(n)?0:o}
Formatted:
…
1
vote
maximum subarray variant
JavaScript 140 chars
For the first solution, I assume that the fuel pits are provided in order order of location around the track and in the form:
var fuelPitInfo = [
{
location: 2,//The …
1
vote
Write a program which performs brute force letter combination until the word "password" is f...
Javascript: 57 56 characters (thanks C5H8NNaO4)
Here's a solution that includes numbers as possible characters ("0", "1", "2", .., "passwor9", "passwora", "passworb", "passworc", "password")
for(i= …
21
votes
4
answers
2k
views
Optimal short-hand roman numeral generator
Goal:
Write a function that takes a number as input and returns a short-hand roman numeral for that number as output.
Roman Numeral Symbols:
Symbol Value
I 1
V 5
X 10
L 50
…
86
votes
Draw the Olympic Games logo
HTML Fiddle - 48, 35, 33 characters (Thanks @Dom and @cnst!)
OOO<p style="margin:-15px 6px">OO
Output:
3
votes
Wordsearch Solver
JavaScript: 342 characters
Code-Golfed version:
function a(b){c='\n';d=b.split(c+c);e=d[1].split(c);for(f=-1,g=[];h=e[++f];)for(i=-1,g[f]=[];h[++i];)for(j=-2,g[f][i]=' ';2>++j;)for(l=-2;2>++l;)for …