Browse all latest questions tagged Algorithm

Votes

Published 19 Sep, 2022

I'm implementing a stack algorithm for study purpose in Kotlin class Stack<T:Comparable<T>>(list:MutableList<T>) { var items: MutableList<T> = list fun isEmpty():B...

Votes

Published 07 Sep, 2022

Supposing that I have some foreach loop like this: Set<String> names = new HashSet<>(); //some code for (String name: names) { //some code } Is there a way to check inside foreach...

Votes

Published 25 Aug, 2022

As part of a program I'm writing, I need to solve a cubic equation exactly (rather than using a numerical root finder): a*x**3 + b*x**2 + c*x + d = 0. I'm trying to use the equations from here. How...

Votes

Published 23 Apr, 2022

I am trying to implement simple validation of credit card numbers. I read about the Luhn algorithm on Wikipedia: Counting from the check digit, which is the rightmost, and moving left, double the va...

Votes

Published 24 Aug, 2022

Is there an extension of the Hungarian algorithm that caters for the assignment of multiple jobs per worker? In its simplest form, the algorithm assigns a single job to a single worker. My applicati...

Votes

Published 01 May, 2022

How can I get the number of "1"s in the binary representation of a number without actually converting and counting ? e.g. def number_of_ones(n): # do something # I want to MAKE this FA...

Votes

Published 01 Sep, 2022

I am writing a program which will add a growing number or unique strings to a data structure. Once this is done, I later need to constantly check for existence of the string in it. If I were to use...

Votes

Published 23 Apr, 2022

I got into that question by thinking about sorting algorithms. Does changing an element position inside an array would be the same, at the interpretation, compilation or run-time phases, to recreate...

Votes

Published 19 Aug, 2022

I'm totally stuck and have no idea how to go about solving this. Let's say I've an array arr = [1, 4, 5, 10] and a number n = 8 I need shortest sequence from within arr which equals n. So for...

Votes

Published 24 Aug, 2022

I just finished my rock paper scissors game in python. Right now, the user has to chose between three buttons, and a string user1 is set to either "Rock", "Paper", or "Scissors". And when I evaluate t...

Votes

Published 26 Apr, 2022

I'm working on a Project Euler problem: the one about the sum of the even Fibonacci numbers. My code: def Fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else:...

Votes

Published 19 Aug, 2022

I recently discovered Codility and I'm going on with the demo training. I wrote this solution to the Genomic Range Query problem, it works fine, solution is provided with dynamic programming, but it s...

Votes

Published 29 Jun, 2022

Input known_array : numpy array; consisting of scalar values only; shape: (m, 1) test_array : numpy array; consisting of scalar values only; shape: (n, 1) Output indices : numpy array; shape: (n,...

Votes

Published 25 Aug, 2022

I'm attempting to implement BFS in Python, I understand how the algorithm works but I don't have much programming experience. I've spent hours thinking about the best way to represent everything and h...

Votes

Published 06 Sep, 2022

I am trying to write a DP solution for the problem: count total number of sub-sequences possible of an array whose elements' sum is divisible by k. I have written the following solution. But it is no...

Popular Questions