I've seen versions of this question for other languages, but not for JS. Is it possible to do this recursively in one function? I understand that I need to take the first element in the string, and then append it to each solution to the recur...

It must be noted here that I performed the mathematics by hand on paper to derive the foregoing proofs. I am not sure if the proofs would have become apparent by solely using the medium of the modern computer. The definition of "efficiency"...

I have an 'item' object in JavaScript, and the item can have settings like color, size, etc. I need to get all possible combinations in an array. So lets say we have an item that looks like this: var newItem = { name: 'new item'...

So given input = [1, 2, 3] and k=2 this would return: 1 2 1 3 2 1 2 3 3 1 3 2 This is the closest to what I am looking for, but not quite: http://algorithms.tutorialhorizon.com/print-all-combinations-of-subset-of-size-k-from-given-array/ functi...

var a = [1,3,6,10,-1]; function combinations(array, n) { } combinations(a, 9) // should return... [[1], [3], [6], [-1], [1,3], [1,6], [1,-1], [3,6], [3,-1], [6, -1], [10, -1], [1,3,-1], [3,6,-1], [1,6,-1], [1,3,6,-1]] maybe i'm missing some co...

I have the array [1, 2, 4] and I want to make 4; I want it to return [4], not [[1,1,1,1], [1,1,2], [2,2], [4]], I was previously doing this but I started to run out of memory when running this on a small server. I had to let the whole function run th...

Let's says I've an array['Alex', 'Sam', 'Robert'] I'd like to combine them something like: Take first array[0] and append with array[2] which will be AlexRobert first letter of array[0] which is A and append wit...

Little challenge. Goal (nodeJS, loop is an * interator function using "yield" strategy) var str; var minChars = 1; var maxChars = 10; for (str of loop('abcdefghijklmnopqrstuvwxyz',minChars,maxChars)) { console.log(str); }...

I've seen a few generators out there but they all make a squared matrix. For example, you give it a list of three items and it'll assume the output of the length is also three. However, I'd like to specify the items and the length. Soun...

Having a small array with some symbols like ['^','^','>','>','+','<','<'], how can I get all the different permutations? I know that similar questions have been asked (and already ha...

©2020 All rights reserved.