Questions tagged [time-limit-exceeded]

When the code scales so poorly in the face of large inputs that it cannot complete in a reasonable amount of time, use this instead of the [performance] tag.

855 questions
Filter by
Sorted by
Tagged with
123 views

Migrate files from MySQL BLOBs to PostgreSQL largeobjects

As title says, this piece of code migrates files (binary and metadata) from a database to another one with different structure. Currently my problem is that when I have to deal with a big database (...
455 views

Calculate the sum of all primes less than 2,000,000 in Swift

This is a Swift program I wrote to calculate the sum of primes below 2 million, but it is tediously slow. I am curious about what makes it so slow. My theory is that copying the filtered array is ...
991 views

Finding the similarity between the two movies using Pearson correlation coefficient

I am trying to find the similarity between the two movies using Pearson correlation coefficient. The programs is working well for small inputs but for large inputs (like 100000 lines) it takes forever....
689 views

Knight's tour code

Another one for some late night snack. - Knight's tour! Please provide your suggestions/flaws/optimization to this knight's tour backtracking code.. ...
604 views

Partitions of a number (backtracking) - time efficiency

I had to write an algorithm that prints the partitions of a natural number in lexicographic order. Example of I/O: If the algorithm reads from ...
591 views

Number of divisors of a factorial

I was solving the DIVFACT problem from Sphere Online Judge: Given a number, find the total number of divisors of the factorial of the number. Since the answer can be very large, print the answer ...
2k views

Project Euler #549: Divisibility of factorials

This is the problem: Calculate $$\sum_{i=2}^{10^8} s(i)$$ where $s(n)$ is the smallest $m$ such that $n$ divides $m!$. Quite mathematical, I've found a better way than brute ...
654 views

CUDA brute force 48 bit key

I have a cryptographic function with two 24 bit keys. I have two blocks of input and two blocks of output, and want to brute force the keys using CUDA. Overview: The function is composed to two ...
501 views

Primes & Squares

Codeforces #230B Question Whether a number has exactly three factors. (i.e. 1, itself and its square root, thus squares of primes) [Time limit is 2 sec, Memory 256 MB] Input Number of testcases, n ...
2k views

Finding the maximum distance from the starting node

I've tried everything to make my program faster but with 250 nodes my code takes around 9 seconds to print the result, and with 5000 nodes it took around 260 seconds. Is there a way to make my ...
389 views

...
1k views

Counting pairs of integers which have a predefined difference

I'm doing this HackerRank problem: Given $N$ integers, count the number of pairs of integers whose difference is $K$. So far, I've ended up with this code: ...
2k views

Generating a very long random string of letters

I was trying to fill a file with about ten million random characters (a-z,A-Z,' '). To my surprise the code is extremely slow. I inserted this print ...
208 views

Time Limit Exceeded with shortest path algorithm

The problem: SHPATH You are given a list of cities. Each direct connection between two cities has its transportation cost (an integer bigger than 0). The goal is to find the paths of ...
676 views

SPOJ DIVSUM - DIvisor Summation

DIVSUM - Divisor Summation #number-theory Given a natural number n (1 <= n <= 500000), please output the summation of all its proper divisors. Definition: A proper divisor of a natural ...
158 views

Copying lists into columns of a table

Edit: I found a potential solution. Changing all of the Dim as Long to Dim as Integer allows the scripts to run smoother. ...
415 views

Copying orders and prices into another Excel sheet

I would like to know if the below VBA can be streamlined to process faster, since it takes on average 9hrs to complete a sheet (800 000 lines), and I have quite a few to get through. Running on 3 ...
677 views

Google Code Jam Google String problem: a sequence resulting from bit flips and reversals

I'm currently having a go at some past Google Code Jam problems to help me practice my programming skills. One of these problems is Problem A ("Googol String") from Round A APAC Test 2016. Here is ...
202 views

Effective ways to find partial sha1 collision

I need to find 2 different string and compare their hash value. Both string must contain "abc". I looking for the first eight character that are the same and stop. I have been running for more than 24 ...