Programming challenges can be found on www.hackerrank.com, coderbytes.com, projecteuler.net, osix.net, www.reddit.com/r/dailyprogrammer, enigmagroup.org‎, codility.com, codechef.com etc. etc. These challenges request a good insight into combinations, permutations, prime generation, lookup tables, ...

learn more… | top users | synonyms (1)

0
votes
1answer
6 views

Any way to optimize this already fast Python solution to Project Euler 31 (coin sums)?

This is a Python solution for all general cases. Any suggestions at all would be appreciated; in my opinion it's already quite good! Here's a link to the problem. ...
1
vote
2answers
40 views

Project Euler 29

Here's a link to the problem. Is there any way I could optimize/speed up this code, perhaps make it more Pythonic? ...
6
votes
1answer
39 views

Make Project Euler 27 solution idiomatic Ruby

I learned to program in Java and C# and in my free time I am using Ruby because it is fun. Unfortunately I have the feeling that I write Ruby code like I am making Java or C# code. I have learned to ...
2
votes
1answer
32 views

String pattern riddle

I've tried this problem on Codeforces and want to optimize and simplify it further and make it a more elegant solution, if possible. ...
0
votes
0answers
22 views

Number of disc intersections [on hold]

I've been trying to get a working solution in C++ to the number of disc intersections/"beta2010" Codility training test (found here or here). I realize my solution isn't very efficient but I can't ...
0
votes
1answer
43 views

Why is this code giving me a wrong answer? [on hold]

I have solved this problem in C, but I get wrong answer every time, could you maybe tell me what I did wrong? Also, don't laugh at my code, I started learning C 7 days ago :) ...
8
votes
2answers
293 views

Codility - Perm-Missing-Elem: 100% functional score, but only 60% performance

I can not figure out why I didn't get 100% success from the Codility's Perm-Missing-Element test even I solve with \$O(n)\$. I will appreciate any advice/answers. You can see the problem, my code, ...
4
votes
2answers
100 views

Project Euler Problem 11: Largest product in a grid

Here is my implementation to project Euler Problem 11. I did this problem a bit later, when I learned how to input from a txt file. The problem context can be seen here. I did add "\n" to the end of ...
3
votes
1answer
72 views

Hackerrank - Sherlock and the Beast

I am trying to solve the Sherlock and The Beast HackerRank challenge. Most tests timeout, however when I try a custom stretch test case (T = 20 and all N = 100000), it returns successfully, so I'm not ...
4
votes
3answers
295 views

Project Euler 18/67: Maximum Sum from Top to Bottom of the Triangle

This is my attempt at Project 18/67 of Project Euler. You can see the problem information, and obtain the needed txt file from here. I had some help with the split function, and help on how to use an ...
4
votes
2answers
79 views

Project Euler 14: Longest Collatz Sequence

I've brute forced solve Project Euler 14. This is my first attempt at trying to solve it, by caching already solved answers, and skipping them as I run it, I am finding the program take's almost twice ...
6
votes
3answers
339 views

Project Euler 28 - Number Spiral Diagonals

Project Euler problem 28 I realized that the spiral was essentially an arithmetic sequence, so I based my code off of that. ...
2
votes
1answer
28 views

Project Euler 27 - Quadratic Primes

Project Euler problem 27 I decided to try simple brute force, and it worked surprisingly quickly. How can this be optimized? ...
2
votes
0answers
56 views

Eight Directions Crossword

I solved a problem which you can read about it here, but it gives me time limit exceeded even though it's 4 seconds. I really don't understand why, I don't think my code can be any simpler, basically ...
4
votes
2answers
94 views

Counting matrices

I need help optimizing my code to run faster (it works but I get Time Limit Exceeded) for this problem. (Don't pay attention to readInt() function, its only used ...
-1
votes
0answers
20 views

Calculating the average of numbers [closed]

I'm working on loop statements and I have to input an integer which states how many numbers to enter, and then find the average of those numbers. i keep getting stuck in the loop. trying to figure out ...
6
votes
5answers
794 views

Project Euler #3 - largest prime factor

I was going through the Project Euler problem #3 and made a program to solve it. The problem is as follows: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of ...
3
votes
2answers
97 views

Recursive uniform cost search that needs to be optimized

I have this uniform cost search that I created to solve Project Euler Questions 18 and 67. It takes the numbers in the txt file, places them into a two dimensional list, and then traverses them in a ...
9
votes
3answers
718 views
7
votes
3answers
134 views

Can this rendition of Project Euler 26 be better written in any way?

This is my solution for problem 26 from Project Euler : ...
6
votes
3answers
89 views

Codility Frog Jump - Count minimal number of jumps from position X to Y

Here is a question I tried from the Codility train website: A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position ...
5
votes
2answers
127 views

“Chef and Digits” Java solution

I am looking for a review on the following code which is for this question. I am looking for a general review of the code. I am specifically also looking for advice on how to make this code run more ...
7
votes
2answers
296 views

Chef and Digits

I am looking for a review on the following code which is for this question. I am looking for a general review of the code. I am specifically also looking for advice on how to make this code run more ...
5
votes
1answer
77 views

Calculate difference of indices

The challenge is to reconstruct an n-digit number using the following information: On each step, you choose an index x from 1 to n. For all indices y (y < x), you calculate the difference by ...
4
votes
4answers
77 views

Project Euler 1 (sum of multiples of 3 or 5 under 1000)

I solved this a while ago. In the moment I solved it I was learning Scheme and, well, I still am. I'm not looking at the best solution (I searched for it and coded it already, in Python), what I want ...
9
votes
3answers
143 views

How can I make my solution for Chef and Digits run faster?

Problem Statement Given n digits and m indices x from 1 to n, calculate the difference ...
16
votes
5answers
799 views

Count distinct primes, discarding palindromes, in under 2 seconds

Problem Statement Generate as many distinct primes P such that reverse (P) is also prime and is not equal to P. Output: Print per line one integer( ≤ 1015 ). Don't print more than ...
4
votes
1answer
51 views

Binary Tree Level Order Traversal Algoritm

I am trying to solve this Binary tree lever order traversal ...
5
votes
1answer
83 views

Increasing readability of maximum path sum algorithm

I had written a solution for Project Euler problem 18 in Python 3. It is good in its efficiency but the problem is the readability and I think reuse. The algorithm used is that at every iteration ...
5
votes
2answers
65 views

Genomic Range Query

Recently I worked on one of the Codility Training - Genomic Range Query (please refer to one of the evaluation report for the detail of this training). The proper approach for this question is using ...
5
votes
2answers
787 views

Project Euler #22 - Name scores

I have written code in C++ 11 and check output with Project Euler site, and it is correct. I am not showing output, just to keep it secret, at least from my end. Please review my C++ 11 code. ...
6
votes
3answers
845 views

Project Euler #4 - Largest Palindrome Product

Problem Statement: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
9
votes
2answers
457 views

'Team Split' problem

Below is my solution for this 'Team Split' problem. In summary, the problem is to find relative strength of 2 teams by finding the difference between their total strength (individual strengths can be ...
7
votes
5answers
466 views

Ten thousand and first prime checker takes a very long time

I am attempting problem 7 on Project Euler. I have come up with this solution which works fine for finding smaller nth prime numbers, but really lags when it comes to higher nth prime numbers. I am ...
12
votes
5answers
482 views

Tape Equilibrium

I picked the first test (Tape Equilibrium) from Codility here. Question: A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. Any integer ...
4
votes
6answers
291 views

Speeding up my implementation of Project Euler #3

Project Euler problem 3 asks for the largest prime factor of 600851475143. I have gone from 96 lines to 17 lines taking hits at this one. This is what I am left with after all of that effort: ...
6
votes
2answers
97 views

Lychrel calculator (Project Euler 55)

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, ...
3
votes
3answers
93 views

Login script that checks two users and their corresponding passwords

Please let me know what you think. Is the code well written? Am I using best practices (like when I chose === over ==)? Is my ...
5
votes
2answers
380 views

Sherlock and The Beast

I have recently written the program for the Sherlock and The Beast' HackerRank challenge. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I ...
3
votes
5answers
753 views

Traversing binary tree

I was given the following question to answer as a part of the hiring test using Codility. I would appreciate if any of you can give me the right answer for this problem. Here is the problem ...
4
votes
2answers
124 views

Project Euler “Largest product in a grid” (#11) in Java 8

I have come up with a Java 8 solution for the following problem: In the 20×20 grid below, four numbers along a diagonal line have been marked in red (bold here). 08 02 22 97 38 15 00 40 00 75 ...
10
votes
3answers
129 views

Project Euler “Largest prime factor” (#3) in Java

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? I wrote the following code with help of some Java 8, I'll explain the equivalent ...
11
votes
1answer
274 views

Project Euler “Even Fibonacci numbers” in Java 8

I'm looking for general advice on my code on the following problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 ...
5
votes
1answer
106 views

Project Euler #15 in haskell

I've solved Project Euler #15 in Haskell, but I feel like there might be a better way to express my solution that I'm not seeing. I start out defining my types: ...
9
votes
3answers
285 views

Checking brackets nesting in a string

I took a training challenge on Codility that checks for the proper nesting of brackets in a string. The brackets to be checked are {,},(,),[,]. I have written the ...
5
votes
1answer
46 views

Project Euler #41 - pandigital prime

I've written a solution to Euler 41: We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is ...
3
votes
2answers
611 views

What is the 10001st prime number?

Project Euler problem 7 says: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? I believe that my code is ...
2
votes
2answers
60 views

Optimizing Python code for Project Euler #5 (LCM of all numbers from 1 to 20)

This is my solution for the 5th problem of Project Euler, which asks for the least common multiples of the numbers from 1 to 20 (inclusive). Is there any way to improve the while loop conditional ...
5
votes
1answer
214 views

Optimizing my code for Project Euler Problem #23 (Non-abundant sums)

Project Euler Problem 23 asks: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be ...
6
votes
2answers
115 views

Helper function to solve Project Euler question 26

Project Euler problem 26 asks us to: Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part. I wrote this function in Python to find the ...