Linked Questions

131
votes
281answers
34k 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 ...
214
votes
62answers
18k 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 ...
42
votes
36answers
5k 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 ...
43
votes
42answers
8k 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 ...
28
votes
41answers
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: ...
34
votes
22answers
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 ...
27
votes
25answers
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
23answers
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
26answers
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 ...
20
votes
21answers
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
23answers
1k views

Reversencode the given string

Given a string, if it is even, break the string into 2 even parts, then reverse the parts to get the "reversencoded" string. Example: onomatopoeia -> tamonoaieopo If the string is not of ...
25
votes
12answers
2k views

Collatz's ice cream cone factory

The Collatz sequence Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as \begin{equation} a_{n+1} = \begin{cases} a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\...
12
votes
24answers
3k views

How many weekdays?

This a simple question. The start day is a Saturday and let the input be a non-negative number x. The output should be the number of weekdays (Mon-Fri) in the next <...
19
votes
16answers
3k views

It was just an input-bug

Continuing my It was just a bug challenge: Input: A string consisting of printable ASCII characters without white-spaces nor new-lines. Output: First turn the input into a palindrome by reverting the ...
11
votes
17answers
9k views

Euclidean Distance Between Two Matrices

Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following: Given two matrices it must return the euclidean distance matrix. The euclidean distance ...

15 30 50 per page