All Questions
Tagged with time-limit-exceeded ruby
24
questions
2
votes
2
answers
166
views
Finding minimum steps required to traverse from source to terminal
Hello everyone this is my first post here so please do critique my post if there's anything.
I have made a program intended to pass a programming challenge on open.kattis.com, here.
It should do as ...
3
votes
1
answer
80
views
Finding the lowest perfect square that can be added to a number to make another perfect square
The code below returns the smallest perfect square that can be added to a number n to result in a perfect square. It works perfectly fine but I need it to run ...
1
vote
1
answer
181
views
Efficiently determining maximum allowed euclidean distance between lists of colors
I was recently tasked with determining which hex RGB colors in list color_list are nearest to each hex RGB color in list target_colors, using euclidean distance as the measuring stick, and only ...
6
votes
3
answers
2k
views
CodeWars kata 'Sum Of Pairs'
I need help in optimizing my code for this challenge. I think my algorithm is fine and I pass all sample tests but get took longer than 12000ms to complete error for final one.
I guess there are a ...
7
votes
2
answers
2k
views
Counting the elements of one array that are less than or equal to some other numbers
I have a method which compares two array О(n2), maxes with each element in nums against <...
5
votes
2
answers
2k
views
Phone number to words based on the dictionary
This is the problem:
Given a 10 digit phone number, you must return all possible words or combination of words from the provided dictionary, that can be mapped back as a whole to the number.
...
0
votes
1
answer
135
views
Project Euler - #5 smallest multiple (Ruby using a hash table)
Why will this code work for a smaller multiple like 10 but time out for anything over 13? Can this code be revised to work for larger numbers?
(I have an alternate solution but wanted to see if this ...
1
vote
2
answers
840
views
Find numbers with same number of divisors
I tried to resolve this task:
The integers 14 and 15, are contiguous (1 the difference between them,
noticeable) and have the same number of divisors.
...
2
votes
3
answers
974
views
Ruby function to find numbers whose sum of squares of divisors is a perfect square
I am doing a problem my buddy gave to me and I have my solution which works but needs to be optimised. I have tried to optimise it as much as I can with my knowledge but it seems there is still room ...
1
vote
2
answers
71
views
Fetching items from database with "Outstanding" status
I am fetching around more than 300000 items through a query:
...
3
votes
2
answers
598
views
Counting numbers whose digits all go up or down
I have created a program which takes a value x and uses this value to create a power of ten value like so 10 ** x.
This has ...
4
votes
2
answers
760
views
Find all integers between m and n whose sum of squared divisors is itself a square
Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared
are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors
is 2500 which is 50 * 50, a square!
Given two ...
5
votes
3
answers
2k
views
Finding nearest power of 2
I have the following simple program which calculates and returns the nearest power of 2 of a given number. Because I use increments and decrements to find the closest power, this takes a very long ...
4
votes
2
answers
347
views
Ruby Interrupted Bubble Sort
Working through CodeEval's Interrupted Bubble Sort, I have a working algorithm, but there's a speed issue. I'm trying to do this with Ruby and I keep getting an error that it's timing out after 10 ...
4
votes
2
answers
1k
views
Calculating sum of smallest prime factors for 2 < n < 10**12
I am trying to calculate the sum of the smallest prime factors of n, where 2 < n < 10**12, and get the remainder of this ...