All Questions
32 questions
3
votes
1
answer
168
views
Pentomino solver in Python
When I was a child, I used to play Ubongo board game, recently I discovered Pentomino puzzle and I wanted to create a custom solver in python for it. Here is what I got:
...
2
votes
1
answer
89
views
Locate Primitive Value in Nested Sequence Type - Iterative version is slower than equivalent recursive function
I'm looking for advice on how to improve the performance and/or style of these two search functions. This is just for fun and for practice: they are already fast enough for any application I would ...
1
vote
2
answers
110
views
Binary Search using recursive approach
Is the following implementation of recursive function correct? How about the time complexity of the code; is it good in terms of performance?
...
5
votes
2
answers
493
views
How to optimize Karatsuba algorithm (using arraylist and java)
I was using Karatsuba algorithm to multiply two polynomials and return the coefficients and I am using java, we are asked to use arraylists here, however, my code is too complicated and it takes much ...
12
votes
5
answers
27k
views
Brute-Force algorithm in C++
I wrote a brute-force algorithm which shall find all possible combinations of ASCII-values that can sum up to a specific value (int hashval).
The algorithm is ...
3
votes
1
answer
567
views
Find A Series of Numbers Who when Squared and Summed are equal to a given Square
I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript
I have a working solution, the ...
6
votes
1
answer
634
views
Best way to performance permutations
This has been my white whale for a while, the idea is convert all the symbols to the goal symbol using all the pieces.
I did an algorithm like 5 years ago (now is lost) and reach lvl 48 but got stuck ...
2
votes
2
answers
173
views
Recursive Transversal (Python)
For a programming challenge I was doing, I needed to traverse a list of lists, and while writing the standard 2D traversal function, I thought why not generalise it, so I did. Here's my best effort:
...
2
votes
2
answers
284
views
A recursive algorithm to find the number of distinct quantities of money from a pile of coins
Problem: find the number of distinct quantities of money that a pile of coins can make.
The vector coins contains the values of the coins, and the corresponding ...
3
votes
1
answer
661
views
Speed up Magic square program
I have written a Java program to calculate magic squares with recursion and backtracking. A 3*3 Magic square is calculated in about 1 sec, but a 4*4 needs about 50 minutes on my laptop with Intel i5. ...
1
vote
2
answers
245
views
When given 7 letters, find all possible words with length 3 to 7
I am writing a program in JavaScript to find all possible words given 7 letters. The words have to be 3 or more characters, and for right now I am limiting it to 7 characters long. The code below ...
5
votes
1
answer
1k
views
Recursively generating the look-and-say sequence
I have a pattern where every number is counted by the number of repetitions. A new resulting number is formed by adding that repetition to the front of that value. The resulting pattern would look ...
1
vote
1
answer
578
views
Recursive merge-sort inversion count algorithm very slow
I am trying to implement a recursive count of inversions in a list of integers by using merge sort and counting the number of split inversions on each recursion. My code works but runs painfully ...
23
votes
0
answers
665
views
Multiplying big numbers using Karatsuba's method
The Karatsuba algorithm, first published in 1962, aims to speed up the multiplication of big numbers by reducing the number of 'single-digit-multiplications' involved.
Because of its complexity (...
2
votes
2
answers
775
views
Find subsets of size K in N set
The question is: There is a set An, and it consists of integers from 1 to n.
...