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...

I'm writing something that takes a block of text and breaks it down into possible database queries that could be used to find similar blocks of text. (something similar to the "similar questions" list being generated while I type this) Th...

Please note: the linked question, "How can I create every combination possible for the contents of two arrays?" does not solve this particular question. The persons that labeled that did not fully understand this specific permutation and requ...

I solved the following leetCode problem with some code : You have d dice, and each die has f faces numbered 1, 2, ..., f. Return the number of possible ways modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals t. I made two...

I am trying to make a 5x5 table that will have the numbers 1-5 random put in the rows/columns. But they need to have all different numbers for each row and column. ex: 12345 54123 41532 35214 23451 The code I currently have is very long so I will g...

My question is similar to THIS question that hasn't been answered yet. How can I make my code (or any javascript code that might be suggested?) find all possible solutions of a known string length with multiple missing characters in variation wi...

If I have n balls and k containers then this -> ( (n+k-1)! / n!(k-1)! ) will work out how many combinations there are. I am having difficulty changing this to produce a list of all combinations in javascript. In a function taking an array of bal...

Lets say that I have a JSON file as such: { "item1":{"time":"00:18:21"}, "item2":{"time":"00:22:22"}, "item3":{"time":"00:02:11"}, "item4":{"time":"01:34:32...

I'm trying to make a function that lists all the possible variations with repetitions. The one I made returns "too much recursion". function variants(amount, chars, junk){ var junkarray = junk.split(","); var newjunk;...

I have an Array a = [0,1,2,3,4,5,6] and I want to subset with 3 elements so the result becomes this: [0,1,2],[1,2,3],[2,3,4],[3,4,5],[4,5,6] I tried using this script that I found : Array.prototype.combinate = function( iItems, aIn ) { if (!a...

©2020 All rights reserved.