Skip to main content
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
Results tagged with
Search options not deleted user 42185

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

8 votes

Given the names of two planets, give the distance

Prolog, 190 174 151 bytes Thanks to Fatalize for guidance. g(A,X):-sub_atom(A,2,2,_,B),member(B:X,[rc:0,nu:5029,rt:9169,rs:17003,pi:72042,tu:136669,an:281564,pt:444309]). s(A,B,R):-g(A,X),g(B,Y),R i …
SteelRaven's user avatar
3 votes

Given the names of two planets, give the distance

Bash, 140 bytes bc<<<"(-`sed -e 's/,/+/;s/[abd-z]//g;s/Mc/0/g;s/V/5029/g;s/E/9169/g;s/M/17003/g;s/J/72042/g;s/S/136669/g;s/U/281564/g;s/N/444309/g'`)*10^4" $ bash script.sh Mercury, Mars 1700300 …
SteelRaven's user avatar
22 votes

Average Color of an Image

Bash, 46 bytes ImageMagick scales image to one pixel which contains average of the colors in the image then outputs it as text. convert $1 -scale 1x1\! txt:-|egrep -o '#\w+'
SteelRaven's user avatar
20 votes

The Colors in Our Stars

Bash, 147 145 bytes ImageMagick is used to manipulate images. Euclidean distance is used. read w h o=o.png convert -size $w\x$h canvas:black $o while read x y i r g b do convert $o -fx "u+$i*rgb($ …
SteelRaven's user avatar
5 votes

Compute the inverse of an integer modulo 100000000003

C++11 (GCC/Clang, Linux), 104 102 bytes using T=__int128_t;T m=1e11+3;T f(T a,T r=1,T n=m-2){return n?f(a*a-a*a/m*m,n&1?r*a-r*a/m*m:r,n/2):r;} https://ideone.com/gp41rW Ungolfed, based on Euler' …
SteelRaven's user avatar