All Questions
7 questions
7
votes
2
answers
812
views
Best Algorithm for solving USACO: Photoshoot - Python
I was trying to solve this problem with Python 3.8. I couldn't find a way other than to brute-force calculate all the possible permutations then check which permutation was valid. The program works ...
1
vote
1
answer
99
views
Algorithmic complexity of this algorithm to find all ordered permutations of length X
I have written a recursive function to generate the list of all ordered permutations of length X for a list of chars.
For instance: ['a', 'b', 'c', 'd'] with X=2 will give [['a', 'a'], ['a', 'b'], ['...
3
votes
1
answer
806
views
"Tara's Beautiful Permutations" challenge
I'm practising my coding skills using Python to answer medium to difficult problems on sites like HackerRank.
Here is the challenge. Given an array of integers, where each number can appear at most ...
3
votes
3
answers
320
views
Finding the number of ways to partition {1,2, ..., N} into p1 and p2 such that sum(p1) == sum(p2)
I am trying to write a space and time efficient algorithm to calculate the number of ways to partition a set of integers {1, 2, ..., N} into two partitions such that the sums of integers in the two ...
-2
votes
1
answer
3k
views
Counting the number of ways to break an amount into coins
I have an algorithm here that counts the number of ways that n cents can be represented using the following denominations:
quarter: 25 cents
dime: 10 cents
nickel: 5 cents
pennies: 1 cent
There are an ...
7
votes
3
answers
2k
views
Find the total number of ways W, in which a sum S can be reached in N throws of a dice
I was solving this question:
Given there is a 6 sided dice. Find the total number of ways W, in which a sum S can be reached in N throws.
Example:
S = 1, N = 6 => W = 0
S = 6, N = 6 => W =...
14
votes
1
answer
3k
views
Nonogram puzzle solution space
I've written some code to brute-force enumerate the solution space of nonogram puzzles up to a certain size. It does a good job up to the first ~4 billion puzzles, but I run out of disk space to store ...