algorithm

Find all possible sums of the combinations of integers from a set, efficiently

Find all possible sums of the combinations of integers from a set, efficiently Question: Given an integer n, and an array a of x random positive integers, I would like to find all possible sums of the combinations with replacement (n out of x) that can be drawn from this array. For example: n = …

Total answers: 1

How to check if all sequence keyword matched in string? – Python

How to check if all sequence keyword matched in string? – Python Question: I have a list of keywords(the number of keywords is depended on user input), I want to check if all keywords are in a sentence with sequence in list. example of keywords(order of keywords is needed for comparing): keywords = [‘Hello’, ‘my’, …

Total answers: 1

How to get the path from the Dijkstra algorithm in Python

How to get the path from the Dijkstra algorithm in Python Question: I took the code for the Dijkstra algorithm from this website and rewrote it for my needs (see below). Now I need to implement a feature that would store the shortest path for each node. I tried implementing it using this code from …

Total answers: 1

Reading Sudokus from text file and applying backtracking

Reading Sudokus from text file and applying backtracking Question: I have just begun with python, so excuse me if these are noob questions or if the questions are already answered. I am trying to read multiple sudoku puzzles and apply the algorithm I found online. The code utilizes a grid(list[list[int]]) setup. I have tried looking …

Total answers: 2

Next Bigger Number when given an int

Next Bigger Number when given an int Question: I’m having trouble optimizing my algorithm for finding the next biggest number with the same digits when given an integer, returning -1 if there is no bigger number. Examples of what the function should do: next_bigger(13): —> 31 next_bigger(201): —> 210 next_bigger(2017): —-> 2071 next_bigger(10) —–> -1 …

Total answers: 3

How do I make this function automatic, it clearly has a pattern

How do I make this function automatic, it clearly has a pattern Question: def populate_kids(self, arr, used_Indices): for a in self.children: a.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: b.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: for c in b.children: c.get_all_jumps(arr, used_Indices) for a in self.children: for b in a.children: …

Total answers: 2