Skip to main content

Questions tagged [recursion]

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

21 votes
12 answers
1k views

Sometimes a string has buried palindromes in it: hallolilah contains lol. And if we took out ...
Steve Bennett's user avatar
7 votes
2 answers
596 views

Recursion is actually quite powerful, sometimes its doesn't look like that child problem of itself exist, but recursion is just helpful. One case per answer.
l4m2's user avatar
  • 32.6k
-3 votes
8 answers
1k views

Assumption A cigarette can be made by combining four cigarette butts. Cigarette butts last infinitely until smoked. Explanation Say you have 31 butts. That means, you can make 7 cigarettes from 28 ...
Siddharth Singh's user avatar
18 votes
7 answers
2k views

The TAK function is defined as follows for integers \$x\$, \$y\$, \$z\$: $$ t(x, y, z) = \begin{cases} y, & \text{if $x \le y$} \\ t(t(x-1,y,z), t(y-1,z,x), t(z-1,x,y)), & \text{otherwise} \...
Bubbler's user avatar
  • 79.3k
1 vote
0 answers
229 views

There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
BlazeRod11's user avatar
13 votes
25 answers
2k views

The task is simple. You're given an arbitrary string message. Return that message prefixed with a number, such that the length of that number plus the message equals the number. In other words, the ...
virchau13's user avatar
  • 499
5 votes
6 answers
394 views

This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule. Related to AoC2020 Day 22, Part 2. Combat is a simple two-player ...
Bubbler's user avatar
  • 79.3k
17 votes
31 answers
2k views

Given the input of n and value. The code is supposed to nest the single element list with ...
U13-Forward's user avatar
  • 2,031
22 votes
9 answers
1k views

Challenge Create a function or program that, when given an integer size, behaves the following way: If size is equal to 1, ...
zdimension's user avatar
-8 votes
3 answers
363 views

Write the shortest possible code cause an error due to recursion too deep Example error in python RecursionError: maximum recursion depth exceeded Example error in ...
Danis's user avatar
  • 773
9 votes
1 answer
305 views

The Monkey has swung home to find his tree all in pieces. He likes order and scoops up all his 'tree-parts' and sets them out in 3 groups. The Monkey's ...
leopardxpreload's user avatar
18 votes
14 answers
3k views

Background Famously, the acronym GNU stands for GNU's Not Unix. 1 It's recursive because, after expanding it once, it still ...
Jonah's user avatar
  • 34.1k
47 votes
76 answers
8k views

Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to ...
AJFaraday's user avatar
  • 11.8k
32 votes
31 answers
9k views

Challenge Write a function/program that outputs either the n'th element, or the first n elements, in the well known number ...
Stewie Griffin's user avatar
5 votes
2 answers
463 views

Here is my ungolfed Ruby code for a function I want to try and golf: ...
Simply Beautiful Art's user avatar

15 30 50 per page