All Questions
37 questions
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 ...
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.
...
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 ...
5
votes
2
answers
269
views
Count five-digit octal numbers with alternating even and odd digits, without repeated digits
I need to find the number of five-digit octal numbers in which all digits are different and no two odd or even digits are adjacent.
My code below gives the correct answer, but I'm not satisfied. Can ...
1
vote
1
answer
755
views
Calculating all combinations from arrays AND (arrays OR floats)
Context: My question comes from needing to iterate different np.arange arrays. The main motivation is to calculate all the possible combinations between the arrays, ...
2
votes
0
answers
44
views
Loop through the nearest switch and deletion neighbours of a Boolean assignment
My goal is to look for nearest neighbours in a Boolean-assigned mapping (a Python dictionary). For this purpose I'm looping through the candidates, starting from those with the closest distance. The ...
3
votes
2
answers
350
views
Creating some Loaded Dice to make our board game fairer
Some friends and I were playing a board game and decided that the random dice rolls just weren't fair! So we came up with a scheme for making the rolls slightly more evenly distributed, and I ...
2
votes
1
answer
263
views
How to find the next sequence of integers?
I was thinking of the following problem: List all sequences \$ a_1, a_2, a_3, a_4, a_5, a_6, a_7 \$ of positive integers where \$ 1 \le a_1 < a_2 < \ldots < a_7 \le 39 \$. For any sequence ...
5
votes
4
answers
470
views
Check whether a permutation with one fixed point can be rotated into one with two fixed points
A friend gave me the following riddle:
Given n people with n distinct names, you place n names tags on a round table with n seats. If the n people now sit at those seats randomly such that exactly ...
3
votes
3
answers
139
views
BFF Word Finder
Inspired by this question on Puzzling.StackExchange, I've decided to write a small python script that determines if a word is a BFF Word. Below are the parameters, solved by Puzzling user Stiv, also ...
4
votes
2
answers
130
views
Find only one subset sum with a specified value for large sets
How can I optimize my code for a large set (10,000 elements)?
...
7
votes
2
answers
6k
views
Permutations with replacement in Python
Many a times, I've had the need to use a permutations with replacement function.
So, I've written a function to do just that:
...
2
votes
3
answers
3k
views
Counting numbers that are divisible by 3 and can be produced from the digits of a given number
I'm trying to solve this problem from codewars.
Problem
Given a certain number, how many multiples of three could you obtain with its digits? Suppose that you have the number ...
2
votes
2
answers
986
views
Project Euler # 24 Lexicographic permutations in Python
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of
the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we ...
2
votes
2
answers
2k
views
Staircase challenge - Python
Your task is to print all unique ways to climb a staircase of length n where, from each step, you can take steps of size x where ...