All Questions
Tagged with programming-challenge python
1,025 questions
11
votes
1
answer
416
views
Help me make my Python code clearer
Here's my solution to Project Euler problem 40.
...
5
votes
1
answer
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 ...
5
votes
2
answers
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 ...
4
votes
2
answers
893
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 ...
3
votes
1
answer
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 ...
2
votes
1
answer
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/...
2
votes
1
answer
188
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 ...
4
votes
2
answers
340
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 ...
4
votes
2
answers
229
views
Python vs. Java Runtime on Euler 22 - Name Scores
I want to know why Java is accepted over Python when it comes to runtime. On performing the following Euler problem, Python takes up less lines and runs faster (Python ~0.05s, Java ~0.3s on my machine)...
2
votes
4
answers
1k
views
"Recycled numbers" challenge
I wrote this program for the Google Code Jam problem, "Recycled numbers."
It took around 2 and half minutes to solve the small input set on my dual core, 1GB RAM system. But for the large input set ...
7
votes
2
answers
2k
views
Canonical Python symmetric cryptography example
Python Cryptography Example
Last weekend I wrote some code to help people use PyCrypto in a canonical fashion to symmetrically encrypt and decrypt strings and files. By canonical I mean I've followed ...
13
votes
4
answers
29k
views
Python Solution for Project Euler #2 (Fibonacci Sums)
I'm a fairly new programmer (just started yesterday!). I decided to tackle Project Euler #2 today, as I did #1 yesterday without many problems. I came up with what seems to me to be a working solution,...
1
vote
6
answers
2k
views
The Next Palindrome - reducing total execution time
I tried to solve one SPOJ problem. I wrote one program in Python, however, it got accepted by the SPOJ judges, but its total execution time is 2.88s. The same algorithm used in C language having ...
6
votes
2
answers
617
views
Euler 35 - python solution taking too long
Here is my solution for Project Euler 35. (Find the number of circular primes below 1,000,000. Circular meaning all rotations of the digits are prime, i.e. 197, <...
3
votes
2
answers
516
views
Project Euler, #4: Incorrect Results on 7-digit numbers
I've got my answer working (up until a 7-digit answer is requested, anyway), and would like some help
returning the correct answer
speeding up the results
I was thinking of storing the values of ...
7
votes
4
answers
1k
views
Project Euler #14 - Longest Collatz sequence
I'm attempting some Project Euler problems in an attempt to learn Python. While I can get the correct answer quite easily, my programs are quite slow. Project Euler, if doing it correctly, specifies ...
6
votes
3
answers
763
views
Optimizing word counter
I took the Python class at Google code today, and this is what I made for the problem about building a word counter.
Please take a look and suggest any improvements that can be done. Please do point ...
3
votes
4
answers
3k
views
Sieve of Eratosthenes: making it quicker
I was thinking about doing problem 23 of Project Euler. It includes the difficulty where you have to factorize primes. I had already done that in problems I solved earlier, but it was only necessary ...
10
votes
2
answers
2k
views
Pangrams CodeEval challenge
I took a challenge on CodeEval. Although the code seems to work for the examples taken from the site, I feel it is not really pretty and must be more complicated than it should be.
Description:
...
2
votes
6
answers
4k
views
Quadrant Queries challenge
Running the same test 10,000 times with cProfile tells me that most of the damage happens in the count() function. This is my attempt at a solution to the Quadrant Queries challenge from ...
8
votes
1
answer
6k
views
Yahtzee Code Kata in Python
I tried a Yahtzee kata in Python the other day. I'm not particularly experienced in Python (C# is my main language) so I'd be interested in any feedback as to how I could have done things better. In ...
6
votes
2
answers
654
views
"File Fix-it" challenge
I'm learning Python and have found this problem from Google Code Jam:
How many mkdir commands does it take to construct a given directory tree:
Input
The first ...
61
votes
10
answers
4k
views
Using separate functions for Project Euler 1
I started programming with Java and C++, so I'm used to having a 'main' function that calls other functions that do the actual work. At university I was always told that doing actual computation in ...
59
votes
9
answers
14k
views
Project Euler problem 1 in Python - Multiples of 3 and 5
I'd like suggestions for optimizing this brute force solution to problem 1. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to ...