Project Euler has a paging file problem (though it's disguised in other words).
I tested my code(pastebinned so as not to spoil it for anyone) against the sample data and got the same memory contents+score as the problem. However, there is nowhere near a consistent grouping of scores. It asks for the expected difference in scores after ...
So, I'm attempting to solve Project Euler Problem 10 in Java, and I'm getting not the right answer. Here's my code:
public class Problem10 {
public static void main(String[] args)
{
long sum =0;
for(int i =3;i<2000000;i+=2)
{
if(isPrime(i))
{
sum+=i;
}
}
System.out.println(sum);
}
...
I have been trying to solve this question for a while, and I am having trouble because some of it seems somewhat more ambiguous than previous problems. As background, the problem says that the given text file is encrypted text with the ASCII saved as numbers. The encryption method is to XOR 3 lowercase letters cyclically with the plainte...
Hi,
I've been learning Ruby, so I thought I'd try my hand at some of the project Euler puzzles. Embarrassingly, I only made it to problem 4...
Problem 4 goes as follows:
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 p...
I am trying to sum all the numbers up to a range, with all the numbers up to the same range.
I am using python:
limit = 10
sums = []
for x in range(1,limit+1):
for y in range(1,limit+1):
sums.append(x+y)
This works just fine, however, because of the nested loops, if the limit is too big it will take a lot of time to compu...
Hello, I am just trying to learn some Lisp, so I am going through project euler problems. I found problem no. 14 interesting (so if you are planning to solve this problems stop reading now, because I pasted my solution at the bottom). With my algorithm it was so slow, but after using memoization (I copied the function from Paul Graham's...
When I was solving Euler project problem #15 I realized that it can be solved with the # of combinations of ways of the route from start to end. The route generated always has the same size of right or down choices (or 0s and 1s) and the right routes always have the same qty of 0s and 1s.
So qty of numbers with the same qty of 0s and 1s ...
I have the following Python code, which I wrote for the sister problem 18.
It works perfectly for problem 18, but is slightly out for problem 67. I can't for the life of me figure out why.
triangle = [
[59],
[73, 41],
[52, 40, 9],
[26, 53, 6, 34],
[10, 51, 87, 86, 81],
[61, 95, 66, 57, 25, 68],
...
]
def max_adjacent(row,col):
ret...
Hi, I am working on a Project Euler question. But it take quite a long time (30 Minutes last time) for my PC to get the answer.
When doing time command on my Linux PC. I get result as this:
real 1m42.417s
user 0m18.204s
sys 1m24.026s
This is a time based on much smaller dataset than the question asked.
So my question is, is...
I work on a windows XP PC with a Python 2.6 install and I was trying to solve a Project Euler problem, but whenever I execute the code the interpreter hangs. I've debugged it through PyScripter, IDLE and MonkeyStudio, but it still doesn't work even for trivial values like 15.
I simply don't understand why. Can you please help me out?
H...
Here's my solution to Project Euler problem #5:
#include <stdio.h>
#include <stdint.h>
#define N 20
int main( int argc, char* argv[] )
{
uint64_t r = 1;
uint64_t i, j;
for( i = 2; i <= N; ++i )
if( (j = r%i) )
r *= ( (i%j) ? i : (i/j) );
printf( "\n%llu\n", r );
return 0;
}
It is of O(n) efficiency. ...
I'm working on a Project Euler problem which requires factorization of an integer. I can come up with a list of all of the primes that are the factor of a given number. The Fundamental Theorem of Arithmetic implies that I can use this list to derive every factor of the number.
My current plan is to take each number in the list of base p...
I'm working through the problems in Project Euler as a way of learning Haskell, and I find that my programs are a lot slower than a comparable C version, even when compiled. What can I do to speed up my Haskell programs?
For example, my brute-force solution to Problem 14 is:
import Data.Int
import Data.Ord
import Data.List
searchTo = ...
I am building a program which will multiply by 2, and reach long accurate numbers.
Here I build a program in which each digit is stored in a different variable.
When I compile the program, and I type 2^63, It gives me the correct answer.
But when I type 2^64, I get a “Segmentation fault”.
What is it? What can I do?
#include <stdio.h>...
I am new to Java and even OOP, but I tried to write program for this task:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^(2) + b^(2) = c^(2)
For example, 3^(2) + 4^(2) = 9 + 16 = 25 = 5^(2).
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
I want that y...
The number 3797 has an interesting property...Being prime itself , it is possible to continuously remove digits from left to right,but remain prime at each stage....:3797,797,97,7....similarly we can work from right to left:3797,379,37,3.
Find the of only 11 primes that are both truncatable from left to right....and right to left.
Pls tr...
Hi,
I have created solution for PE P12 in Scala but is very very slow. Can somebody can tell me why? How to optimize this? calculateDevisors() - naive approach and calculateNumberOfDivisors() - divisor function has the same speed :/
import annotation.tailrec
def isPrime(number: Int): Boolean = {
if (number < 2 || (number != 2 && num...
I'm working on Project Euler problem #2:
Each new term in the Fibonacci sequence is generated
by adding the previous two terms. By
starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Find the sum of all the even-valued terms in the sequence which do not exceed four million.
My ...
What's wrong with this recursion in Java?
public class findPyt
{
public static int sum = 0;
public static void main(String[] args)
{
findP(3, 4, 5);
}
public static void findP(int a, int b, int c)
{
sum = a+b+c;
if (sum == 1000)
{
System.out.println("The Triplets are:...
I'm playing through project Euler in my spare time, and it's come to the point where I need to do some refactoring. I've implemented Miller-Rabin, as well as a few sieves. I've heard before that sieves are actually faster for small-ish numbers, as in under a few million. Does anybody have any information on this? Google wasn't very helpf...