Questions tagged [code-golf]
9 questions
10
votes
3 answers
Code Golf: Least Common Multiple
"CodeGolf" challenge: write the shortest practical Least Common Multiple function that:
Does not use built in GCD, LCM or any related fuctions
Accepts multiple arguments in any order, e.g. LCM[3, 20, 6]
In the spirit of the original, obfuscated is…
Mr.Wizard
- 271,378
- 34
- 587
- 1,371
9
votes
6 answers
Make the code shorter for solving Fizz buzz
Here is Fizz buzz
Write a program that prints the integers from 1 to 100. But for
multiples of 3 print "Fizz" instead of the number and for the
multiples of 5 print "Buzz". For numbers which are multiples of both 3
and 5 print "FizzBuzz".
I…
chyanog
- 15,542
- 3
- 40
- 78
7
votes
1 answer
Celebration: How to golf a marriage with a prefix free code
We all know a conspicuous member of our community got hitched recently. As most of us are not in Malta, and weren't able to fly there, I thought of a celebration question. Sort of.
The challenge is golfing a function (Mma only) that finds a prefix…
Dr. belisarius
- 115,881
- 13
- 203
- 453
3
votes
1 answer
Rewrite code with fewer characters
How could I rewrite the following code such that the output (evaluation result) is the same, but is obtained from code having less than 30 characters in total?
Table[Table[{b - a, b}, {b,8}],{a,8}],
I tried for more than an hour, but I can't find…
user63131
- 31
- 1