For challenges involving recursive functions, or functions or programs calling itself, directly or indirectly.

learn more… | top users | synonyms

92
votes
7answers
3k views

Exponentially Slimy Programming: Stacking Minecraft Slimes

Slimes are cube shaped enemies in Minecraft that break into multiple smaller versions of themselves when killed. For the purposes of this challenge we'll depict them as an 8×8 pixel image with 3 ...
14
votes
2answers
1k views

Is there a way of shortening fat-arrow functions?

From what I've seen throughout my time here on PPCG, most JavaScript entries involving fat arrow functions tend to be one of two camps: The simple ones that are capable of running as a single ...
13
votes
27answers
2k views

Hofstadter H-sequence

Definition a(0) = 0 a(n) = n-a(a(a(n-1))) for integer n > 0 Task Given non-negative integer n, output a(n). Testcases n a(n) 0 0 1 1 2 1 3 2 4 3 5 4 6 4 7 ...
10
votes
6answers
217 views

Binary Recurrence Sequences

A binary recurrence sequence is a recursively-defined sequence of the following form: This is a generalization of the Fibonacci (x = 1, y = 2, a = [1, 1], alpha = 1, beta = 1) sequence and the ...
10
votes
1answer
283 views

Recursive Steiner Chains

Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images: In ...
46
votes
32answers
4k views

Alex-style Addition

Inspired by Alex's glorious Learn you an R for great good, we are going to humbly recreate Alex's "one true R program" -- but with a twist. Alex-style Addition works like this -- it has a 90% chance ...
26
votes
3answers
738 views

Tiny Lisp, tiny interpreter

Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect ...
13
votes
7answers
290 views

Prefix Tree Traversal

Write a program that takes in (via stdin or command line) a string with the recursive form PREFIX[SUFFIXES] where PREFIX may be any string of lowercase letters (a-z), including the empty string, ...
26
votes
11answers
1k views

Print, Increment, Decrement, Alias - Interpret Prindeal

Prindeal (pronounced prin-dee-al) is a new esoteric programming language that only has four commands: print, increment, decrement, and alias. Despite its minimalism, complex mathematical operations ...
19
votes
12answers
1k views

Evaluating Parentheses and Brackets as Integers

Write a program that takes in a string of the four characters ()[] that satisfies these points: Every left parenthesis ( has a matching right parenthesis ). Every left bracket [ has a matching right ...
7
votes
8answers
1k views

Ways to arrange the integers 1 to 9 with operators so that the result is 100

Prelude: This task is taken from Five Problems Every Software Engineer Should Be Able to Solve in Less Than an Hour, which I really recommend. The task: Write a program that outputs all ...
5
votes
2answers
775 views

Coding a recursive function for highest possible input

Challenge You are given the following function:- which is the same as:- with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L. Your task is to ...
25
votes
28answers
5k 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 ...