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
The shifting dot
PHP, 118 113 112 111 (, -10 bonus points = 101)
(second try, with horribly predictable rand() behavior, and a little more efficiency)
for($n=30,$i=rand(1,29),$t=$s=pack("A$n",'');$n--;$i+=$i<2|rand( …
0
votes
Run the Monty Hall Problem
PHP >= 5.4, 195 192
$r=[0,1,2];unset($r[$p=rand(0,2)]);$d='012';echo"$d\n";fscanf(STDIN,"%d",$c);unset($r[$c]);$d[array_rand($r)]='_';echo"$d\n",!fscanf(STDIN,"%s",$s),'You '.($s=='switch'^$c==$p?'wo …
5
votes
10
answers
5k
views
Print E=mc² or E=mc^2, by using the right side of this equation
Your task – if you choose to accept it – is to have your program print, literally, either one of the following:
E=mc² (if your language supports Unicode (so no HTML trickery, for instance))
E=mc^2 ( …
0
votes
Count characters, turn them into a cipher
PHP, 151
(with setting short_open_tag = On)
<?$c=array_slice(count_chars(strtolower($s=$argv[1])),97,26,1);arsort($c);echo strtr($s,array_combine(range('a','z'),array_map('chr',array_keys($c))));
…
6
votes
3
answers
575
views
Align a horizontally-aligned, right-angled ASCII shape along a diagonal
Your program will receive an ascii shape consisting of only underscores _, pipes |, spaces and newlines \n, which, together, represent a horizontally-aligned, right-angled shape. Together with this s …
15
votes
12
answers
2k
views
Brainf*ckish directions
Your task – should you choose to accept it – is to build a program that parses and evaluates a string (from left to right and of arbitrary length) of tokens that give directions – either left or right …
2
votes
Sort numbers by binary 1's count
PHP 5.4+ 131
I don't even know why I bother with PHP, in this case:
<?unset($argv[0]);usort($argv,function($a,$b){return strcmp(strtr(decbin($b),[0=>'']),strtr(decbin($a),[0=>'']));});print_r($argv) …