Linked Questions
25 questions linked to/from Tips for golfing in Julia
149
votes
336
answers
44k
views
Fibonacci function or sequence
The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
230
votes
65
answers
19k
views
No A, just CAPS LOCK
What happens when the CapsLock key on your keyboard doesn't have a notch in it?
"This hPPENS."
The goal of this program is to consistently emulate keyboard misses where each A press is replaced with ...
86
votes
138
answers
13k
views
Collatz Conjecture (OEIS A006577)
This is the Collatz Conjecture (OEIS A006577):
Start with an integer n > 1.
Repeat the following steps:
If n is even, divide it by 2.
If n is odd, multiply it by 3 and add 1.
It is proven that ...
54
votes
45
answers
7k
views
Tips for golfing in Mathematica
What general tips do you have for golfing in Mathematica? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Mathematica (e.g. "remove ...
49
votes
46
answers
10k
views
The Ackermann function
The Ackermann function is notable for being the one of the simplest examples of a total, computable function that isn't primitive recursive.
We will use the definition of \$A(m,n)\$ taking in two ...
43
votes
55
answers
4k
views
Output the largest number with the fewest digits
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.
The input list will not be in any particular order and may contain ...
28
votes
61
answers
3k
views
Reversed Iota's
I didn't invent this challenge, but I find it very interesting to solve.
For every input number, e.g.:
4
Generate a range from 1 to that number:
...
31
votes
47
answers
3k
views
Subtract the next numbers
Description
Subtract the next P numbers from a N number. The next number of N is N + 1.
Look at the examples to get what I mean.
Examples:
...
23
votes
36
answers
2k
views
Smallest Bit Rotation
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits.
For example, when the given number is 177, whose binary representation is \$...
34
votes
22
answers
3k
views
Turn an Array into a Math Problem
Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where:
A plus sign (+) is inserted between pairs of numbers that ...
29
votes
26
answers
3k
views
Find the next 1-sparse binary number
A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation.
So, the number 1010101 is 1-sparse whereas 101101 is not.
Your task is to ...
26
votes
25
answers
2k
views
Case Permutation
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...
24
votes
26
answers
3k
views
Jimmy these arrays down
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can ...
21
votes
21
answers
4k
views
Female and Male Sequences
This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison.
Really looking forward to the answers!
In his book "...
17
votes
27
answers
2k
views
Order by Earliest Lower Digit
Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index.
Do note that this differs from alphabetization, as ...