Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
109 views

Finding the number of distinct decompositions a number has using only repdigits

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
Lesserrafim's user avatar
3 votes
2 answers
211 views

Find the join of two set partitions

Two partitions of a set have a greatest lower bound (meet) and a least upper bound (join). See here: Meets and joins in the lattice of partitions (Math SE) The meet is easy to calculate. I am trying ...
Watchduck's user avatar
  • 230
3 votes
1 answer
90 views

Number of partitions of (a,b) into k distinct parts which sum up to (a,b)

Problem set This is somewhat a generalization of the famous partition of integer n into k parts. Given two integers ...
linuxbeginner's user avatar
4 votes
1 answer
134 views

Repetition-Limited Multiset Coefficient function

This is a simple multiset coefficient calculator in python, that will calculate both standard multiset coefficients, as well as multiset coefficients with repetition limits, used initially as part of ...
Lee Davis-Thalbourne's user avatar
6 votes
2 answers
112 views

Schedule a series of 1:1 contests so that each entrant plays against every other

My sister is organizing a Majong tournament. She wants to set up a set of round-robin rounds. There will be 16 players at 4 tables; 4 players per table. Players will play 5 rounds. She wants every ...
JDT's user avatar
  • 81
2 votes
1 answer
159 views

Find the list of combination (with repetition) given rank and number of items. (Lexicographic ordering)

The problem involves the fastest possible method to generate a list of combinations which repeats from all the possible combinations with repetition allowed. I know there needs to be a way to ...
Reptorian's user avatar
1 vote
1 answer
126 views

Effective encoding-decoding chain determination (time optimization)

Could you please help with speeding-up this code? Input: UTF-8 text (encoded 1-3 times from known pool of encodings). Every time was encoded and decoded by random encoding from pool. Original was koi8-...
Kir S's user avatar
  • 11
7 votes
2 answers
1k views

Find all combinations of length 3 whose sum is divisible by a given number

I came up with a suitable solution to a HackerRank problem that failed because the execution took longer than 10 seconds on lists that were of very large size. The problem: Given a list ...
NFeruch - FreePalestine's user avatar
8 votes
2 answers
961 views

Print all "balanced" sequences of 'A' and 'B'

the aim of the code below is to print all balanced sequences with equal number of 'A' and 'B'. A sequence is balanced if every prefix of length \$\geqslant 4\$ is balanced. A prefix is balanced if the ...
kodkod's user avatar
  • 441
3 votes
0 answers
58 views

Check if two semistandard Young tableaux are compatible

I have a question about how to check if two tableaux are compatible (will define below). Here we only consider tableaux of rectangular shape. A tableau is called semistandard if its rows are weakly ...
Jianrong Li's user avatar
1 vote
1 answer
90 views

An algorithm that minimizes the number of ingredients necessary

I am working on a code that will minimize the number of ingredients necessary to make some dishes. Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. ...
adrienlucca.net's user avatar
1 vote
3 answers
134 views

A more elegant way to uniformly sample from non-negative integers with a fixed sum

Given a positive integer n, I would like to randomly output n non negative integers that sum to ...
Simd's user avatar
  • 231
3 votes
2 answers
453 views

Pascal's triangle solution in Python code

I have solved the pascal's triangle problem. I am not good at writing efficient programs, hence any suggestions/ comments shall be welcomed. ...
Zainab Saad's user avatar
1 vote
1 answer
133 views

Subset Product Algorithm

Subset Product is an NP-complete problem and is my favorite problem. So, I've written a slightly smarter way of solving the problem. Will performance impact matter if I use multi-cpus and my GPU? Do ...
The T's user avatar
  • 491
5 votes
2 answers
2k views

Find non-overlapping pairs of elements in a list whose difference is less than some given threshold

I have the following task: Let us have a list (denoted by L, and for simplicity, the elements come from the interval [0,1]). We are given a parameter (denoted by C), and we want to find as many pairs ...
Atvin's user avatar
  • 153

15 30 50 per page
1
2 3 4 5
11