Category "recursion"

PHP: set a (deep) array key from an array [closed]

is there a PHP function that would create a (deep) array key from an array ? It's quite difficult to explain, see that example: function myst

How to remove object properties with negative values, regardless of depth?

I'm looking for a way to remove object properties with negative values. Although an existing solution is provided here, it works only with no-depth objects. I'm

javascript merge sort and recursion

I am trying to understand how JavaScript merge sort function work. And I struggle understanding how the recursive function work. This is the code: const mergeSo

How to retrieve all posts of a user via Facebook Graph API using promises and recursion?

I am currently developing a web app which uses the Facebook Graph API. What I would like to achieve is to get all posts of a user. However, this is not that e

How do i make a recursive function in python which does the following? magic list

I've got an assignment in which I need to code a recursive function (with no loops) in python that returns: [[]] if n is 1 [[],[[]]] if n is 2 [[],[[]],[[],[[]]

Write a recursive method called which takes in an array of integers and returns said array in reversed sorted order

I have a programming exam in a few days so I'm doing some exercises just to practice. However, I've been stuck with this problem and I started to doubt if it's

print fibo big numbers in c++ or c language

I write this code for show fibonacci series using recursion.But It not show correctly for n>43 (ex: for n=100 show:-980107325). #include<stdio.h> #in

Multiply 2x2 Matrix in Python Recursively? No nested loops or numpy

I'm having a difficult time finding a very simple program that multiplies two 2x2 matrices recursively. Can anyone help me out? Just need to multiply X and Y wi

How to convert scala.some to scala.mutable.Map?

i am trying to write code to mask nested json fields.. def maskRecursively(map :mutable.Map[String,Object]):mutable.Map[String,Object] ={ val maskColumns = PII

'int' object is not subscriptable?

I'm doing an algorithm challenge on www.edabit.com, where you have a list of dice rolls, and: if the number is 6, the next number on the list is amplified by a

how to solve the recursion problem when specifying type hints for classes from different files

how to solve the recursion problem when specifying type hints for classes from different files models1.py from models2 import Second @dataclass class First:

given a list with integers separated by math symbols, find if a certain value can be calculated by placing braces

I'm trying to write a function which get: An integer. (s) A list with integers separated by math symbols.(L) By using recursion to determinate if the value of s

Duplicate things a specific number of times in racket

I'm trying to write a program that takes in a phrase and a number (n) and returns a list that contains the phrase repeated n times. What I have so far looks lik

Recursive iteration of a Map Java

I am writing a recursive function whose purpose is to iterate over the pList File. My code is public static void HashMapper(Map lhm1) throws ParseException {

Writing a recursive case

How do I complete this recursive function at output_string += ? Output should be: 5! = 5 * 4 * 3 * 2 * 1 = 120 def print_factorial(fact_counter, fact_value):

Python: Recursive Function. How to return all subsets of targetsum

My code is not showing the shortest subset eg [7] or it is not reading all the subsets, [7], [3,4] to return the shortest subset. Can explain why only 1 set of

recursively split a dataframe with partykit::lmtree as a stump tree

I am trying to recursively split my data using a stump tree based on the lmtree function from the partykitlibrary. The idea is the following: [1] for each varia

How do I recursively use Array.prototype.find() while returning a single object?

The bigger problem I am trying to solve is, given this data: var data = [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4, children: [ { id: 6

count number of digit using recursive method

Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left

Division using recursion

I am pretty sure that this must be some glaringly stupid mistake by me. But can anyone explain what is wrong in this division code using recursion. I know there