Questions tagged [recursion]

Recursion in computer science is a method of problem solving where the solution to a problem depends on solutions to smaller instances of the same problem.

Filter by
Sorted by
Tagged with
2
votes
3answers
84 views

DFS-based exhaustive word grid search

I have implemented an exhaustive depth-first grid search that searches for all possible words in the 8 connected regions. Is there any way I can make this faster or memory efficient than it is now? I ...
11
votes
2answers
396 views

Finding acronyms with >=1 letters at the start of each consecutive word

Problem I'm seeking a clean and efficient way to determine whether one string is an initialism/acronym of another. Example: IBM => International Business Machines However, a key condition for my ...
0
votes
0answers
33 views

A recursive_count Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++, A recursive_count_if Function with Unwrap Level for Various Type Arbitrary ...
0
votes
1answer
32 views

Find a powerset of a set in C

The code below is an implementation of purely recursive solution to find a powerset of any given set. The input set is a string, and the output - array of strings. Both of them are wrapped into a ...
4
votes
2answers
56 views

Primality Test Refactoring

I devised a new primality test isPrimeNumber() below which determines if 1000000007 is prime. It works fine but the code looks unprofessional in my opinion. Is there any way to refactor it to make it ...
1
vote
0answers
52 views

A Function Applier for Applying Various Algorithms on Nested Container Things in C++

This is a follow-up question for A recursive_replace_if Template Function Implementation in C++, A recursive_copy_if Template Function Implementation in C++, A recursive_count_if Function with Unwrap ...
1
vote
0answers
44 views

A recursive_replace_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_copy_if Template Function Implementation in C++. Besides the recursive version std::ranges::copy_if, I am trying to ...
2
votes
1answer
44 views

A recursive_copy_if Template Function Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform Template Function Implementation with std::invocable concept in C++. Besides ...
2
votes
1answer
45 views

A recursive_transform Template Function Implementation with recursive_invoke_result_t and std::ranges::transform in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function Implementation with std::invocable ...
4
votes
2answers
82 views

Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++, A recursive_transform Template Function ...
2
votes
1answer
64 views

A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template ...
2
votes
1answer
91 views

A recursive_transform Template Function Implementation with std::invocable concept in C++

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Template Function with Execution Policy, A recursive_count_if Template Function ...
2
votes
1answer
55 views

A recursive_count_if Template Function with Execution Policy in C++

This is a follow-up question for Avoiding requires clause if possible on a series recursive function in C++ and A recursive_count_if Function with Automatic Type Deducing from Lambda for Various Type ...
1
vote
1answer
68 views

Avoiding requires clause if possible on a series recursive function in C++

This is a follow-up question for A recursive_transform_reduce Function for Various Type Arbitrary Nested Iterable Implementation in C++, A recursive_count Function For Various Type Arbitrary Nested ...
2
votes
1answer
67 views

A recursive_transform_reduce Function for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A population_variance Function For Various Type Arbitrary Nested Iterable Implementation in C++. Thanks to G. Sliepen's answer, I am trying to implement the mentioned <...
2
votes
1answer
67 views

A population_variance Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++, An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
6
votes
1answer
126 views

A Various Container Type Arbitrary Nested Iterable Generator Function Implementation in C++

This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and std::deque and std::list Type Arbitrary Nested Iterable ...
7
votes
1answer
116 views

Non-nested std::deque and std::list Generator Function for arithmetic_mean Function Testing in C++

This is a follow-up question for A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++ and An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
3
votes
2answers
76 views

Pretty print directory structure in a JSON recursively

I am trying to pretty print the directory structure defined in a JSON. I do have a solution using recursion but I'm looking for feedback on how this solution can be ...
1
vote
0answers
45 views

A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++

This is a follow-up question for An arithmetic_mean Function For Various Type Arbitrary Nested Iterable Implementation in C++. As Toby Speight's answer mentioned, some self-checking unit tests are ...
3
votes
1answer
79 views

An arithmetic_mean Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A Summation Function For Boost.MultiArray in C++. I am trying to ...
1
vote
3answers
92 views

Java recursive sort verification function for a linked list

It should return true, if there is no element that follow or the following elements are greater than their predecessors. ...
3
votes
0answers
84 views

LeetCode: Stone Game C#

https://leetcode.com/problems/stone-game/ Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones ...
1
vote
0answers
32 views

std::deque and std::list Type Arbitrary Nested Iterable Generator Functions Implementation in C++

This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and the previous questions about recursive functions, including A ...
3
votes
1answer
141 views

std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++

This is a follow-up question for the previous questions about recursive functions, including A Summation Function For Arbitrary Nested Vector Implementation In C++, A recursive_count_if Function For ...
2
votes
1answer
43 views

A recursive_count_if Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++, A recursive_count_if Function with Specified value_type for Various ...
2
votes
1answer
64 views

A recursive_count_if Function with Automatic Type Deducing from Lambda for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_count_if Function with Specified value_type for Various ...
13
votes
2answers
536 views

Sudoku solver program written in modern c++

This is a simple program that solves a given Sudoku puzzle recursively. The input is provided as a file that contains the cells, 0 if empty, delimited by a , ...
1
vote
0answers
51 views

A recursive_count_if Function with Specified value_type for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++. Thanks to Quuxplusone's answer and G. Sliepen's comments. Based on the ...
6
votes
3answers
900 views

Money change exam

I was asked to create a method that would: Return a Change object or null if there was no possible change The "machine" has unlimited bills of: 2, 5 and 10 The Change object must return the ...
2
votes
1answer
91 views

A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++. Thanks to G. Sliepen's answer. Based on the mentioned suggestion, the ...
4
votes
1answer
70 views

A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A Summation Function For Arbitrary Nested Vector Implementation In C++ and A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++. ...
3
votes
1answer
76 views

A recursive_transform Template Function with Execution Policy

This is a follow-up question for A recursive_transform for std::vector with various return type, A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ ...
5
votes
0answers
46 views

Word finder using pygame

I made a word searching app that allows the user to inout words into a text box, and parts of the word grid will be highlighted to show the location of the words. The letters of the grid can be edited ...
2
votes
1answer
56 views

A ones Function for Boost.MultiArray in C++

This is a follow-up question for An Element-wise Increment and Decrement Operator For Boost.MultiArray in C++ and A recursive_transform Template Function for BoostMultiArray. I am trying to implement ...
1
vote
1answer
57 views

An Element-wise Increment and Decrement Operator For Boost.MultiArray in C++

This is a follow-up question for A recursive_transform Template Function for BoostMultiArray and An Add/Minus Operator For Boost.MultiArray in C++. Besides the add / minus operator for Boost....
8
votes
4answers
103 views

Lazy generator of strings in lexicographical order

I needed to write a Python generator that lazily generates, in lexicographical order, strings composed of a certain alphabet (e.g. lowercase English letters). My first thought was to make an infinite ...
2
votes
1answer
65 views

A recursive_transform Template Function for BoostMultiArray

This is a follow-up question for A Sine Template Function For Boost.MultiArray in C++, A recursive_transform for std::array with various return type, A recursive_transform for std::vector with various ...
1
vote
1answer
75 views

Recursion with char[] in c#

I am trying to learn recursion and have a question involving an array that needs to be reversed. I am focusing on c# but the language probably doesn't matter a whole lot because my function is not ...
0
votes
1answer
72 views

Generate unique string permutations recursively

🧩 Objective Write a recursive method for generating all permutations of an input string. Return them as a set. See: Recursive String Permutations - Interview Cake 🔎 Questions 1: How does the ...
2
votes
1answer
50 views

A Sine Template Function For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++. Besides the basic add operation applying onto each element, I am trying to implement a sine template function ...
1
vote
0answers
52 views

An element_wise_multiplication and an element_wise_division Function For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++ and An Add/Minus Operator For Boost.MultiArray in C++. Besides the basic element-wise add / minus operations, ...
3
votes
1answer
91 views

LeetCode - Weekly Contest 213 - Kth Smallest Instructions

Hi I participated in Leetcode weekly contest 213 and am facing issue with submission for below question Kth Smallest Instructions Bob is standing at cell (0, 0), and he wants to reach destination: (...
4
votes
0answers
68 views

An Add/Minus Operator For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++. The following code is the improved version based on G. Sliepen's answer. On the other hand, the built-in ...
3
votes
1answer
71 views

An element_wise_add Function For Boost.MultiArray in C++

This is a follow-up question for A Summation Function For Boost.MultiArray in C++. Besides the summation operation of all elements, I am trying to focus on the element-wise operation here. The main ...
4
votes
1answer
105 views

A Summation Function For Boost.MultiArray in C++

This is a follow-up question for A Summation Function For Arbitrary Nested Vector Implementation In C++ and A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++. I am ...
1
vote
0answers
64 views

A recursive_print Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform for std::array with various return type. Based on these discussion about the ...
2
votes
0answers
26 views

Pocket cube solver in Prolog

Hello I have writtern this Prolog code to solve a scrambled 2x2 rubiks cube. Also known as a a pocket cube. ...
5
votes
1answer
120 views

A recursive_transform for std::vector with various return type

This is the follow-up question for A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ and A get_from_variant function in C++. Thanks to G. Sliepen ...
3
votes
1answer
34 views

Approximation search source reconstruction localization algorithm

Goal To determine the coordinates of some signal source in a 3D space, given the coordinates of four observers and the time at which each saw the signal, as well as the velocity of the signal. ...

1
2 3 4 5
21