As of May 31, 2023, we have updated our Code of Conduct.

# Questions tagged [programming-challenge]

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

3,299 questions
Filter by
Sorted by
Tagged with
1 vote
2k views

### SPOJ "Pesel" challemge

Here is a solution to the SPOJ's JPESEL problem. Basically the problem was to calculate cross product of 2 vectors modulo 10. If there is a positive remainder, it's not a valid PESEL number; (return <...
• 231
939 views

### Another iteration of Alien Language

I'm mostly looking for performance suggestions. Feel free to include more than just that. Since Google Code Jam is coming around, I thought I would look at some of the previous questions. Alien ...
• 3,095
3k views

### Solving systems of linear equations

I am working on the following problem (http://www.enigmagroup.org/missions/programming/9/). You have a 6x6 table where the first 5 columns and rows are comprised of different types of shapes, 5 total....
• 711
2k views

### Project Euler #3 - how inefficient is my code?

So I am essentially a complete newbie to programming, and have been attempting to learn Python by completing the Project Euler problems. I haven't gotten very far, and this is my code for problem #3 : ...
• 81
973 views

### Project Euler - Shortening Problem 2

You might have read my question on shortening my code to a one-liner for Problem 1. So, I was wondering, is there any more tricks of the trade to shorten my Problem 2 solution: ...
• 1,301
2k views

### Project Euler Problem 1

This is my python solution to the first problem on Project Euler: ...
• 1,301
2k views

### Spotify's "Reversed Binary Numbers" Problem [closed]

I wrote some Java code for Spotify's Reversed Binary Numbers puzzle and I tested it on my machine and I am almost positive that it behaves as expected. However, when I send it to puzzle AT spotify.com ...
1 vote
420 views

### Number letter counts

I'm trying to become more proficient in Python and have decided to run through the Project Euler problems. In any case, the problem that I'm on (17) wants me to count all the letters in the English ...
106 views

### Organizing a long string into a list of lists

This code loads the data for Project Euler problem 18, but I feel that there must be a better way of writing it. Maybe with a double list comprehension, but I couldn't figure out how I might do that. ...
• 217
295 views

### Project Euler: primes in Python

This is a Python module I have just finished writing which I plan to use at Project Euler. Please let me know how I have done and what I could do to improve it. ...
• 217
351 views

### Largest Prime Factor

I'm trying to learn Python by working my way through problems on the Project Euler website. I managed to solve problem #3, which is What is the largest prime factor of the number 600851475143 ? ...
• 285
2k views

### Any better way to solve Project Euler Problem #5?

Here's my attempt at Project Euler Problem #5, which is looking quite clumsy when seen the first time. Is there any better way to solve this? Or any built-in library that already does some part of the ...
• 680
1 vote
1k views

### Skiena's Programming Challenge [UVa ID 10137]- Getting WA

Question from Skiena's Programming Challenges. Getting WA (wrong answer) in Online Judge even though it's working for sample test cases. Can somebody find a case where it fails? I tried the tricky ...
• 21
9k views

### Longest common substring

I wrote a program to find the longest common subsequence among several strings. I used a naive algorithm and implementation. The motivation was solving the Rosalind problem at http://rosalind.info/...
• 413
1k views

### "Find the Min" challenge on Facebook Hacker Cup

I was solving the "Find the Min" problem on Facebook Hacker Cup. The code below works fine for the sample inputs given there, but for input size as big as 109, this takes hours to return the solution....
• 3,085
1 vote
6k views

### SPOJ Problem 2 - Prime Generator

I'm trying to solve this problem. After a couple of tries, this is what I pulled off: ...
• 111
1 vote
126 views

### Tips on projecteuler code optimization

I am working on projecteuler # 14, http://projecteuler.net/problem=14 and my code takes too long to run. Any tips, or hints for a beginner? Code: ...
693 views

### Mimicking T9 cell messaging

Today I solved a question from Google Code Jam: mimicking a cell phone keypad messaging. Here is the program, with goto statements. I know it is an unstructured ...
9k views

### Faster way to determine largest prime factor

Project Euler problem 3 asks: What is the largest prime factor of the number 600851475143? The first step I took is to determine the highest value number I should be looking at as a possibility (...
• 131
3k views

### Enormous Input Test - reducing program runtime

This is my solution to SPOJ Problem 442. How can I make this code run faster? What are some techniques that can be used to make this faster? I am getting a Time Limit Exceed Error here. ...
408 views

### Project Euler 10 - Summation of primes

I'm currently attempting to learn OCaml, and I'm working thought the Project Euler problems to do so. Here's some code I knocked together for problem 10. I am looking for idiomatic feedback rather ...
• 745
432 views

### Project Euler #35 in Common Lisp

To start with Common Lisp I am doing Project Euler using this language. Usually I manage to solve problems but I am quite sure that my code is not as efficient as it could be in Common Lisp. That is ...
1k views

### optimizing project euler #83 solution

Project Euler problem 83 asks: In the 5 by 5 matrix below, ...
• 447
1k views

### Golang solution to Project Euler #81 (min path through a matrix)

Project Euler problem 81 asks: In the 5 by 5 matrix below, ...
• 447
429 views

### Keeping Linq's readability (e.g. over goto statements) without sacrificing performance

I'm doing Project Euler problem 5 as a kata, focussing on TDD and code readability. The challenge is: What is the smallest positive number that is evenly divisible by all of the numbers from 1 to ...
• 1,441
4k views

### "The Trip" challenge from Programming Challenges [closed]

Here is a problem from the book Programming Challenges by Skiena and Revilla: The Trip A number of students are members of a club that travels annually to exotic locations. Their ...
• 131
877 views

### Google Code Jam - Alien Language

I've successfully solved the Alien Languages problem for Google Code Jam in Haskell: The algorithm is trivial - turn the patterns into regular expressions and see how many of the known words match ...
• 259
3k views

I more or less asked the same questions on stackoverflow.com, but maybe this is more for this forum. I have a hard time getting to grips with how to implement a top navigation (common for the whole ...
• 217
164 views

### Counting the ways to pick increasing sequences from sorted arrays

Preamble I am trying to learn JavaScript by writing code and looking up documentation, one problem at a time. I am already familiar with several "dynamic" languages, so I'm hoping to be productive ...
• 506
1k views

### Decoding binary string message

I am trying to learn some Java on my own, and I am tackling some "programming challenge" problems to practice the little I have learnt so far. Could anybody constructively critique this beginner's ...
1 vote
4k views

### Array absurdity challenge

This is a CodeEval challenge taken from here: Challenge description: Imagine we have an immutable array of size N which we know to be filled with integers ranging from 0 to N-2, inclusive. ...
3k views

### Efficient implementation of a Dynamic Programming challenge

I wrote the following code for a Dynamic Programming problem but the online judge gives me a 'Time Limit Exceeded' error. How can I optimize this code to make it more efficient, especially the part ...
• 193
305 views

### Solving Project Euler problem #48 in Scala

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems. For problem #48, coming from a Python background, my solution is the following one-liner: ...
• 163
516 views

### Project Euler #9 in haskell

I am trying to teach myself haskell by means of project Euler i sovled problem #9 by means of this code which is on the brute force side I was wondering if there is a more elegant/haskell/efficient ...
• 173
931 views

### Python Code Review - Project Euler #12

I just figured out Project Euler problem #12. This the first one I've done in Python, so I'm putting my code out there to hopefully get some constructive criticism. If anyone is interested, would ...
• 121
406 views

### Help me make my Python code clearer

Here's my solution to Project Euler problem 40. ...
• 506
310 views

### Devise an algorithm of complexity O(N) finding No of 1's from a 2 dimensional matrix[N][N] containing 1's and 0's

Assume a 2D [n][n] matrix of 1's and 0's. All the 1's in any row should come before 0's. The number of 1's in any row I should be at least the number of 1's row (i+1). Find a method and write a C ...
2k views

### Optimizing Code for Project Euler Problem 14

For Project Euler problem 14 I wrote code that runs for longer than a minute to give the answer. After I studied about memoization, I wrote this code which runs for nearly 10 seconds on Cpython and ...
• 163
3k views

### Finding the largest product of four consecutive numbers in a grid

Project Euler #11 asks to find the largest product of four numbers of a grid, where the four numbers occur consecutive to each other vertically, horizontally, or diagonally. Here is my solution in ...
• 151
885 views

### A little scheme programming challenge

I am learning scheme to get something new from a programming language and this code below is the solution to Project Euler question 21 but the code runs 10x slower than the listed Python code when I ...
• 447
295 views

### Isn't this dynamic programming?

I was solving problem 18 and 67 on Project Euler and came up with an algorithm that actually goes through almost all the possibilities to find the answer in O(n) time. However, ProjecEuler claims ...
• 221
1k views

### Median solving from Interview street in Python

Any suggestions to improve the performance of the following code? This code is exceeding the time limit for the last four cases. This is a solution to the problem https://www.interviewstreet.com/...
22k views

### Smallest Multiple

I just recently learned about Project Euler and have started doing the problems on there. I cleared problem 1 and 2, had no idea how to do 3 and 4, and started to do 5. I've seen the post regarding ...
• 233
231 views

### Spotify Best Before puzzle

I thought to spent my free time by solving a puzzle: Best Before Spotify Puzzle. I coded in Java, and yeah I did not clean up my code (just a rough work) and I have yet to optimize... so I did check ...
• 121
187 views

### How do I add memoization to this problem? [closed]

Problem Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 2020 grid? Solution Here is my ...
• 221
1k views

### Path sum - Dijkstra's algorithm in F#

I'm learning F# and I've decided to solve Project Euler's Problem #81 with Dijkstra's algorithm. In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by only ...
• 321
339 views

### Improving runtime of prime generation

I just answered the question on project euler about finding circular primes below 1 million using python. My solution is below. I was able to reduce the running time of the solution from 9 seconds to ...
• 447
301 views

### Euler 2 : Simple Fibonacci

I'm just starting to experiment with F# (from a C# background). I think I'm starting to get into the right way of thinking, but this code still seems pretty awkward. Is there a better (more terse) ...
• 133