Questions tagged [programming-challenge]

Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.

Filter by
Sorted by
Tagged with
2
votes
1answer
235 views

Project Euler 40: Champernownes's Constant

I just finished Project Euler 40 with a brute force method. As usual, any optimizations would be helpful. (I feel like I'm getting better at this scripting thing) ...
3
votes
1answer
758 views

Project Euler 39: Integer right triangles

I just finished Project Euler 39: If p is the perimeter of a right angle triangle with integral length sides, {a, b, c} … For which value of p ≤ 1000, is the number of solutions maximised? I'm ...
5
votes
3answers
835 views

Project Euler 38: Pandigital Multiples

I just solved Project Euler 38 and was wondering if you guys could provide some suggestions on how to speed it up. I've tried adding extra conditions but they increase the time. Any ideas on how to ...
3
votes
1answer
713 views

Truncatable Primes — Project Euler 37?

I just finished Project Euler 37 after a bit of debugging and can't figure out how to make it faster. Whenever I add extra tests that I want to speed the program up, it ends up just slowing it down. ...
6
votes
2answers
8k views

Stable custom alphabetical order using List<T>.Sort

Background This is a problem from a programming contest. The Sharonians of planet Sharon, at the far end of our galaxy, have discovered various samples of English text from our electronic ...
1
vote
1answer
598 views

Project Euler 11 - Largest Product in a grid

I have to say without sounding arrogant, because I am only a novice coder, yet after looking at other's solutions, my solution is definitely not the shortest and most lightweight one and probably not ...
4
votes
1answer
651 views

Google Code Jam 2014: Full Binary Tree

Here is my entry for the Code Jam problem Full Binary Tree (I didn't compete but tackled the problem afterwards). It does solve the provided inputs, so I suppose it is correct. I am looking for any ...
3
votes
1answer
133 views

Programming Puzzle - N Teams K Wins each

I found a problem here. I am sharing the problem and my attempt at solution. I would like to find out if this is the best approach possible. One day, at the "Russian Code Cup" event it was decided ...
11
votes
3answers
1k views

Optimizing “Herd Sums” problem using dynamic programming

I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Herd Sums Execution Time Limit: 2 seconds ...
1
vote
3answers
569 views

Optimizing Project Euler 36 - double-base palindromes

This one was quick and simple. Any optimizations? ...
2
votes
1answer
141 views

Project Euler 35 in Python

I'm back with a Python solution for Project Euler 35. Any help would be appreciated; I generate the numbers by observing that all circular primes can only have digits 1, 3, 7, and 9. Then I use the ...
4
votes
1answer
337 views

Project Euler Problem 14 in Clojure

I recently began learning Clojure. In order to get better acquainted with it, I've been tackling Project Euler challenges. Problem 14 is not really a difficult one. It asks for the number that ...
1
vote
1answer
169 views

Project Euler #20 solution in Clojure

Problem: \$n!\$ means \$n × (n − 1) × ... × 3 × 2 × 1\$ For example, \$10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800\$, and the sum of the digits in the number \$10!\$ is \$3 + 6 + 2 + 8 + 8 + 0 + ...
3
votes
3answers
165 views

More succinct / ideal solution to Project Euler #22

"Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical ...
2
votes
1answer
405 views

GSS1 SPOJ problem Time Limit Exceeding

The problem is presented here as follows: You are given a sequence A[1], A[2], ..., A[N] . ( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). A query is defined as follows: Query(x,y) = Max { a[i]+a[i+1]+...+...
4
votes
2answers
6k views

“Rotating the string” optimization

Below is the code for the problem at Codechef. I have made use of the String method .equals in my solution which is working fine ...
3
votes
3answers
359 views

Curious fractions in functional Ruby

Problem 33 in Project Euler asks: The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is ...
6
votes
2answers
3k views

Project Euler 34 - digit factorials

145 is a curious number, as \$1! + 4! + 5! = 1 + 24 + 120 = 145\$. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as \$1! = 1\$ and \$2! = 2\...
8
votes
1answer
957 views

Project Euler Problem 33 - digit canceling fractions

Problem: The fraction \$(\dfrac{49}{98})\$ is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that \$(\dfrac{49}{98}) = (\dfrac{4}{8}...
8
votes
3answers
953 views

Project Euler 23: Non Abundant Sums

Here is my solution to Project Euler 23: Non Abundant Sums. I know I'm doing the Divisors function brute force, but I can't seem to get it to work any other way. ...
4
votes
2answers
1k views

How to make Project Euler 32 in Python faster?

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, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is ...
1
vote
2answers
1k 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. ...
5
votes
3answers
2k views

Project Euler 30 — Digit fifth powers

Here's my solution for Project Euler Problem 30. Any optimizations in time, space, or style would be greatly appreciated. ...
1
vote
2answers
342 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? ...
8
votes
2answers
466 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 ...
6
votes
2answers
915 views

String pattern riddle

I've tried this problem on Codeforces. Given a set of string patterns, all of which are the same length, and which consist of literal lowercase ASCII characters and ...
29
votes
3answers
26k views

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

I cannot 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, and ...
5
votes
2answers
2k 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 ...
4
votes
1answer
4k 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 ...
6
votes
3answers
1k 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
3k 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
4answers
3k views

Project Euler 28 - Number Spiral Diagonals

Project Euler problem 28 Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: $$\begin{array}{rrrrr} \color{red}{21} &22 &...
4
votes
2answers
2k 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? ...
7
votes
1answer
258 views

Eight Directions Crossword

I solved a problem which you can read about here, but it gives me "time limit exceeded" even though it runs in 4 seconds. I really don't understand why. I don't think my code can be any simpler, ...
5
votes
2answers
128 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 ...
14
votes
7answers
4k 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 the ...
3
votes
2answers
2k 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 ...
12
votes
3answers
3k views

Project Euler Problem 10 - Sum of primes < 2mil

...
9
votes
3answers
1k views

Rendition of Project Euler 26 - reciprocal cycles

This is my solution for problem 26 from Project Euler: ...
15
votes
3answers
29k 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 ...
6
votes
2answers
343 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
502 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
104 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 =...
6
votes
4answers
625 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 ...
10
votes
3answers
447 views

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

Problem Statement Given \$n\$ digits and \$m\$ indices \$x\$ from \$1. \ldots,n\$, calculate the difference \$b_y = a_x - a_y\$ for all indices \$y \; (y < x)\$. Then, calculate \$B1\$, the ...
5
votes
2answers
2k views

Prime generator program SPOJ time limit exceed

Problem Statement Input The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-...
25
votes
5answers
1k 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 106 ...
5
votes
1answer
3k views

Binary tree level order traversal algoritm

I am trying to solve this Binary tree lever order traversal: ...
5
votes
1answer
483 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 ...
6
votes
2answers
1k 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 ...

1
53 54
55
56 57
59