Tagged Questions
3
votes
1answer
72 views
Project Euler 407: Is there any more optimal way to solve this idempotent equation (modulo n ring)?
Project Euler problem 407:
If we calculate a2 mod 6 for 0 ≤ a ≤ 5 we get: 0, 1, 4, 3, 4, 1.
The largest value of a such that a2 mod 6 = a is 4.
Let's call M(n) the largest value of a < n ...
6
votes
2answers
265 views
Speed up solution to Project Euler problem 75
I've been programming for a few months now, and have used Stack Overflow a great deal, but this is my first post. Anyway, I wrote this code for Project Euler problem 75, and was curious if anyone knew ...
7
votes
1answer
216 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 :
...
2
votes
3answers
110 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:
fib = [0, 1]
final = 1
...
3
votes
1answer
99 views
Project Euler Problem 1
This is my python solution to the first problem on Project Euler:
n = 1
rn = 0
while n < 1000:
if n%3 == 0 or n%5 == 0:
rn += n
n = n + 1
print(rn)
I would like to find a way to ...
0
votes
4answers
115 views
How can this python code be improved?
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 ...
2
votes
1answer
56 views
Can this small snippet of code be better written? It organizes 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. ...
2
votes
1answer
72 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 ?
...
4
votes
2answers
206 views
Any better way to solve Project Euler problem # 5
So, here's my attempt on Problem # 5 of Project Euler, which is looking quite clumpsy when seen first time. Is there any better way to solve this? Or any built-in library that already does some part ...
0
votes
2answers
146 views
optimizing project euler #83 solution
I have solved the project euler problem 83 using uniform cost search. This solution takes about 0.6s to solve. I want to know if anyone can get the code to run relatively faster without changing the ...
2
votes
2answers
276 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 ...
8
votes
1answer
270 views
Help me make my Python code clearer
Here's my solution to Project Euler problem 40.
import operator
import math
def levels(n):
return 9 * n * 10 ** (n - 1)
def face_value(i):
def level_filler(i):
n = 1
yield 1
...
5
votes
4answers
346 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 ...
4
votes
2answers
395 views
Project Euler problem 11 in python
My solution for project euler #11 in python. Possibly it can be improved. But other than improvements, I have 2 extra questions, more likely confessions, mostly because of my laziness:
1- Would it be ...
3
votes
2answers
192 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 ...