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
Calculate a check digit using the Damm algorithm
Ruby, 149 characters
i="0";t="0#{'2uleblnnz0nbpv3kqkaufbjqebm57jdj6ubaba1mc2fyucqff69tbllrcvw393li'.to_i 36}";puts(gets.chomp.each_char{|c|i=(c=~/\d/?t[(i+c).to_i]:i)}+i)
Tested on repl.it
1
vote
Write a Program that Writes a function BUT in a different language!
Ruby to Thue, 139 bytes
Not as short as i thought it should be, but I will post anyway. Thue may not be the best language for golfing in.
10.times{|n|puts "#{n}+::=#{n==9?'+':''}#{(n+1)%10}\n#{n}|::=| …
3
votes
Memory Allocator
Ruby, 135
Has a global array keep track of whether each cell is allocated or not.
i=->n{$a=[!0]*n;$a[0]=0}
a=->n{s=$a.each_cons(n).to_a.index{|a|a.none?};n.times{|i|$a[s+i]=0}if s;s||0}
d=->s,n{n.time …
4
votes
The "Do While False" idiom
C, 76 bytes
I renamed c1 to c, c2 to C and result to r. C programmers go to extremes to avoid goto. If you ever have a problum with absurd syntax in C, it is most likely to be because you did not use …
2
votes
When does Santa enter the basement? (AOC Day 1)
Befunge 25 bytes
Outputs in unary. This starts you on floor one, and will go until 0.
1<\1_v#:+-*2%2~
:#._@>$1>
1
vote
Unscramble the Source Code
Ruby, 23 (Cracked)
code scramble:
[[d++]8%-0]the...11 mops
output :
"lice"
tested on: http://repl.it/languages/Ruby/
1
vote
Unscramble the Source Code
JavaScript, 36
scrambled code:
trx=["bs","alie"];trx((x+x)guns(96))
output:
ion
0
votes
Unscramble the Source Code
JavaScript, 72 [SAFE]
Output:
35616001553385
Code scramble:
Math.exp(unoat(exp){ecit((("x")ps.in(1.19+21)).sit())+flr()})loop[ferln]
Unscrambled:
1
vote
Capitalize first letter of each word of input
Ruby(55)
gets.chars.inject(' '){|c,d|print c<?!?d.upcase():d;d}
I know that a better ruby solution exits in an old answer, but I like this better.
note:c<?! checks for chars that come before !, which …
0
votes
Person of Interest
Befunge-98, 170
I think this can still be golfed down a bit. But at least I beat C#. Tested at befungius.aurlien.net.
a3*> 82*v>":detciderp emirC">:#,_$...'-,..'-,....av
>1 -:!#;_v^;v,,,"-555-"...,,, …
1
vote
Don't google "google"
C++, 81
int l(char *s){int b=0,i=0;do{b=s[i]^"google"[i]?1:b;}while(s[i++]);return--i/b;}
Divides by 0 on "google". This is my first C++ golf, so any tips would be welcome.
^ is used like !=. b is eq …
2
votes
Print out all IPv6 addresses
Ruby 75
x=->s,n{n>0?65536.times{|m|x.(s+?:*(8<=>n)+m.to_s(16),n-1)}: p(s)};x.('',8)
This is a recursive solution that takes a each prefix and finds every possible suffix. Recursively.
-2
votes
How many decimals are there before I'd need to add 1 when rounding?
Ruby, 46 Bytes
This may not be valid, as it only fits 16 digits.
p (gets.to_i**0.5).to_s.split('.')[1]=~/[5-9]/
2
votes
Stack Exchange Vote Simulator
Shape Script, 26 bytes
"^"$"0>1@-"~"v"$"0<1-"~0@!
How it woks:
"^"$ split input on '^'
"
0> Check if the number is more than 0 (1 if true, 0 if false).
1@- subtract the answer …
1
vote
Make a Unicorn interpreter
Ruby, 75 characters
A nifty ruby interpreter that replaces all 🦄 with ' ' (a space) and all 🐐 with ' ' (two spaces), and gets the length of each segment.
I call this version of Unicorn RubyUnicorn …