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.
1
vote
Are my eyes open or closed?
MATL, 22 16 bytes
2)2\?'._.'}'O_O'
Try it online
22 byte version, 2)'ntpr'=a?'O_O'}'._.'.
1
vote
Compute overall ranking
MATL, 21 20 bytes
2#2$XSwiY*4#S)tn:tb(
Takes input as a matrix for the table of rankings, then the tie breaking column as a number, then a column vector of weightings for each column. Attempted expla …
5
votes
What is that angle?
Matlab, 86 77 bytes
Here's another way using Matlab:
[I,J]=find(~im2bw(imread(input('','s'))));mode(mod(round(atan2d(J-51,I-51)),360))
This reads the file (stolen from flawr), and finds the indic …
1
vote
How long ago was this?
MATL, 5 bytes
iPYOd
This is the same as StewieGriffin's answer, except I used flip then diff rather than diff then negating the result.
Full explanation, with corresponding Matlab functions:
i …
4
votes
Sequential Multiplication
MATL, 3 bytes
tq*
You can try it online! Basically similar to the Seriously and Jelly answers. First, it duplicates the top of the stack (get's input first time when the stack is empty). Decrements …
2
votes
Reimplement the wc coreutil
MATL, 38 bytes
'\n'32cZtttnGnw-wPZvPYbnqbnvvV!3Z"vX:!
You can try it online!
This shouldn't be so long though...
Explanation, for the calculation,
'\n'32cZt %// Takes implicit input and replaces …
1
vote
Graph an equation!
Matlab, 35 bytes
ezplot(input(''));axis([-5 5 -5 5])
Input is a string like 'y=2*x^2'.
1
vote
Accepted
Identify the Conic Section
Matlab, 154 bytes
p=input();c=null([p.^2 prod(p,2) p 1+p(:,1)*0]),s={'circle' 'ellipse' 'parabola' 'hyperbola'};s{3+sign(c(3)^2-4*c(1)*c(2))-~max(abs(c(3)),abs(c(1)-c(2)))}
Saved some bytes thanks …
3
votes
Derivative at the Edge
MATL, 21 15 bytes
2/d1)6Mh8Mt0)h+
TryItOnline
Halves the input vector, and takes successive differences, to give d=[i(2)-i(1) i(3)-i(2) ... i(end)-i(end-1)]/2 and then makes two modified vectors, …
11
votes
Calculate Euler's totient function
MATL, 7 bytes
t:Zd1=s
You can TryItOnline. Simplest idea, make a vector 1 to N, and taken gcd of each element with N (Zd does gcd). Then, find which elements are equal to 1, and sum the vector to g …
3
votes
Get the most dominant color!
MATL, 30 26 23 bytes
Save some bytes by using mode with explicit output specification 6#XM.
2#YiwX:6#XMgY)tn3>?x'='
Previously (26 byte solution)
2#YiwX:S&Y'tX>=Y)tn3>?x'='
Doesn't work online, …
2
votes
Where should I put my restaurant?
MATLAB, 42
If it is OK to take input as
I=[5.7 3.2
8.9 8.1]
then this statement
fminunc(@(y)sum(hypot(I(:,1),I(:,2)-y)),0)
returns 5.113014445748538.
Shamelessly stealing Thomas Kwa's meth …
11
votes
1/N probability
MATL, 5 bytes
Three different versions of this one, all length 5.
iYr1=
which takes an input (i), generates a random integer between 1 and that number (Yr), and sees if it it is equal to 1 (1=). A …
3
votes
Find the number in the Champernowne constant
MATL, 22 bytes
it10+:Yst' '=~)wYsXf1)
Take the input (i), make the vector 1 to input+10 (10+:), converts the vector to a string (Ys), and remove the spaces, which is painful, (t' '=~)). Then, conve …
1
vote
Card pair probability
MATL, 44 38 bytes
This also uses MATL version 3.1.0, which is earlier than this challenge.
New version, thanks to Luis Mendo for saving 4 bytes!
iiXI*XJxO1e4XH:"JZ@I\TTo3X53$X+1=a+]H/
Old version …