All Questions
20 questions
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-...
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 ...
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 ...
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 ...
1
vote
2
answers
143
views
2
votes
1
answer
91
views
Count the different positions reached in a cycle of permutations
I have come across a problem on cyclic permutations. It is about swapping numbers around.
It starts out with input N < 100,000 which makes the first N natural numbers as orders: 1 2 3 ... N-1 N
...
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 ...
1
vote
2
answers
924
views
Lattice path from Project Euler with Python solution
I was trying to solve this problem called lattice path from Project Euler:
Count the number of unique paths to travel from the top left to the bottom right of a lattice of squares.
How many such ...
10
votes
3
answers
726
views
Master Locksmith
Description
Master Locksmith has just finished the work of his life: a combination
lock so big and complex that no one will ever open it without knowing
the right combination. He's done testing ...
8
votes
2
answers
1k
views
Python solution to Code Jam's 'Rounding Error'
The "Rounding Error" problem of Round 1B of Google Code Jam 2018 is as follows:
Problem
To finally settle the age-old question of which programming language is the best, you are asking a total ...
4
votes
2
answers
1k
views
Finding combination of coins that can produce a given sum
This function is checking whether it has enough money in a list called self.deviceMoney to make change.
It works exactly the way I want, but only in case where not ...
3
votes
2
answers
4k
views
Finding integer lengths for a right triangle with a given perimeter
I'm using Python 3 and have written this code to find the right triangle sides when given the perimeter:
...
13
votes
3
answers
20k
views
Counting permutations without repetitions for a number or a string
Can I make the following code faster with minor modifications? It times out on CodeWars website.
...
10
votes
2
answers
959
views
Finding all contiguous sublists such that each member appears an even number of times
The program needs to find all contiguous sublists of numbers where the number of occurrences of every member in the contiguous sublist is divisible by 2.
The first line of input is N (the number of ...
6
votes
3
answers
672
views
Korean word segmentation using frequency heuristic
This a continuation of a previous question. I want to thank Joe Wallis for his help with increasing the readability of my code. Although the changes made by Joe Wallis did increase the speed of the ...