Skip to main content

All 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: ...
Riomare's user avatar
  • 31
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 ...
Quack E. Duck's user avatar
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? ...
Siawash Kasra's user avatar
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 ...
Jenny's user avatar
  • 51
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 ...
kaiya's user avatar
  • 335
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 ...
Cory Harper's user avatar
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 ...
Juan Carlos Oropeza's user avatar
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: ...
Tobi Alafin's user avatar
  • 1,792
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 ...
Bo Work's user avatar
  • 391
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. ...
Marten's user avatar
  • 595
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 ...
Wowsk's user avatar
  • 113
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 ...
Rick's user avatar
  • 586
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 ...
Felix's user avatar
  • 13
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 (...
Sep Roland's user avatar
  • 4,718
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. ...
Roy Yoon's user avatar

15 30 50 per page