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.
4
votes
Accepted
Fixing a logic system
Ruby, 299 298 283 279 bytes
class Object;def * o;!self|o;end;def s;w=join.gsub(/\W/,"").chars.uniq;n=w.size;(0..2**n).any?{|i|n.times{|j|eval(w[j]+"=#{i[j]>0}")};all?{|e|eval([%w[<-> ==],%w[-> *],% …
4
votes
Accepted
Convert a decimal to a fraction
Ruby, 43
y=gets.to_r;puts"#{y.to_i} + (#{y-y.to_i})"
Pretty straightforward.
1
vote
Comparing two numbers
Ruby 1.9+, 73 71 70 68 bytes
->a,b{[a,b]*" is #{%w{equal\ to greater\ than less\ than}[a<=>b]} "}