All Questions
Tagged with time-limit-exceeded python-3.x
143
questions
3
votes
1
answer
152
views
Performance Tuning to enable answer for Project Euler #566 "Cake Icing Puzzle"
Related to this question I am still looking for a solution to Project Euler Problem 566 (see link for a nice simulation also):
Adam plays the following game with his birthday cake.
He cuts a piece ...
2
votes
1
answer
101
views
Project Euler #566 "Cake Icing Puzzle" Performance Tuning
I am rather new to python and wanted to use Project Euler to learn more about it. The task can be seen here, so I will skip any description of my own:
Project Euler Problem 566 (see Link for a nice ...
0
votes
1
answer
118
views
HackerRank Project Euler 12 (Python) | Highly Divisible Triangular Numbers
I again share my Python code which didn't pass time limit test cases in the HackerRank contest of ProjectEuler.
...
1
vote
2
answers
160
views
Making my DP algorithm faster - longest palindromic substring
The following code is my solution to a LeetCode question - find the longest palindromic substring. My code is 100% correct, it passed once but it took too long, and in most of the reruns I hit a "...
5
votes
1
answer
458
views
Connecting ropes with minimum cost
Question:
There are given N ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. The task is to connect the ropes ...
3
votes
2
answers
406
views
Euler Project: Sums of Digit Factorials
MY CODE:
...
4
votes
1
answer
276
views
Decibinary for xth number (Python code)
I created the code for the problem description below. It works for \$N\le10^6\$ but after that it gives a time out error. What I don't understand is how to optimize the code using dynamic programming. ...
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 ...
6
votes
3
answers
1k
views
Python analog clock with turtle - runs slow
I made a python analog clock program with turtle. The problem is, it takes about 1.4 seconds to loop, so it only moves the second hand every 1.4 seconds. Its probably cuz my computer is slow...
...
1
vote
1
answer
226
views
Find next biggest palindrome
I have written a program for the SPOJ PALIN problem:
A positive integer is called a palindrome if its[decimal representation is the same]from left to right and from right to left. For a given ...
0
votes
1
answer
260
views
Climbing the leaderboard (Hacker Rank) via binary search
I am trying to solve the Climbing the leaderboard problem on Hacker Rank. My code passes all the test cases except Test Cases 6 to 9, which I assume are using large data sets.
I'm using binary search ...
8
votes
3
answers
2k
views
Find the number of trailing zeros in factorial
I am trying to find the "Number of trailing zeros of N!" (N factorial).
In the python code I am trying to find the factorial first and then the number of trailing zeros. However, I am ...
3
votes
1
answer
204
views
Attempting to solve minimum window substring problem using Python 3.8
Hello programming gurus/reviewers,
I attempted to solve the Minimum Window Substring (Leetcode 76) problem using Python 3. My solution involved using Counters and backtracking. On submission, the ...
2
votes
0
answers
38
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 ...
4
votes
1
answer
821
views
Find next smallest number that's representable as a sum of distinct powers of 3
I'm solving this challenge:
Given a positive integer number, you have to find the smallest good number greater than or equal to the given number.
The positive integer is called good if it can be ...