Flash Flash Revolution

Flash Flash Revolution (http://www.flashflashrevolution.com/vbz/index.php)
-   Technology (http://www.flashflashrevolution.com/vbz/forumdisplay.php?f=74)
-   -   The Project Euler thread (http://www.flashflashrevolution.com/vbz/showthread.php?t=120818)

FFR4EVA_00 10-19-2011 09:41 PM

The Project Euler thread
 
for getting stargroup mad at people leaking answers EXCEPT NOT BECAUSE WE HAVE...
...SPOILER TAGS

http://projecteuler.net/

what you do is simple:
1. make an account
2. open a problem
3. solve the shit out of it
4. rinse and repeat

a lot of the problems, ESPECIALLY later on, require you to find a general solution via programming and plug some ridiculously large parameters into them

anyway, i have completed:
1-13, 16, 18, 28, 33, 52, 67, 79, 108, 110, 157, 267, 355

and i am working on something...

Zageron 10-19-2011 10:43 PM

Re: THE project euler thread
 
I've completed 3 of the puzzles so far, mostly because I have very little time to complete them. I will be going in linear order from start to finish! Using C++ as my language because I'm taking a course on it right now.

Excellent idea ffr4eva.
When people run into problems they can post their questions here, just remember to hide your solutions in spoiler tags and try not to ever post the complete solution!

YoshL 10-19-2011 11:54 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Zageron (Post 3553814)
I've completed 3 of the puzzles so far, mostly because I have very little time to complete them. I will be going in linear order from start to finish! Using C++ as my language because I'm taking a course on it right now.

Excellent idea ffr4eva.
When people run into problems they can post their questions here, just remember to hide your solutions in spoiler tags and try not to ever post the complete solution!

your welcome zageron for telling you about this first :3

i have 1-25, 28 and 30
And i work with java

reuben_tate 10-20-2011 05:09 AM

Re: THE project euler thread
 
So far I've done 1,2,3,5 and 6. I just learned about the bigInteger type in Java so now I'll be using that (since the 'long' type isn't ****ing long enough -__-.)

YoshL 10-20-2011 09:30 AM

Re: THE project euler thread
 
Quote:

Originally Posted by reuben_tate (Post 3553983)
So far I've done 1,2,3,5 and 6. I just learned about the bigInteger type in Java so now I'll be using that (since the 'long' type isn't ****ing long enough -__-.)

hehe, i did all them without using the bigInteger type.

I used manual math with arrays of integers

reuben_tate 10-20-2011 07:51 PM

Re: THE project euler thread
 
Quote:

Originally Posted by YOSHl (Post 3554031)
arrays of integers

Sounds like how the bigInteger type would be implemented. I'd rather just use that, I find no point in implementing a new data structure if one is already implemented for me to use already. :razz:

iironiic 10-20-2011 08:03 PM

Re: THE project euler thread
 
This seems really interesting. I could try to do this on my free time to work on my computer skills.

emerald000 10-20-2011 10:45 PM

Re: THE project euler thread
 
I'm currently at 49, using mostly Maple. I have done a couple in C++ too, where speed mattered.

I should get back into it.

Friend key is 62306152188978_1d29510ddc0c52e8c33db3cdbaf399db for interested people.

leonid 10-20-2011 10:47 PM

Re: THE project euler thread
 
* Working on P83 *





I'm mostly using Ruby and C

My friend key: 1858629421787_a864c4e88f44e36b8023644c0f14493e

iironiic 10-20-2011 11:24 PM

Re: THE project euler thread
 
I just started today and got 1, 2, 3, 5, 6, 7, 9, 10, 16, 20, 25, 45, 48, and 52 solved. I'm using Mathematica here.

Friend Key: 76814575274714_b466b39d7ef7730e66d3da5b16df2525

reuben_tate 10-21-2011 01:20 AM

Re: THE project euler thread
 
By the way... Friend Key: 41335338220707_9d1fa87f00c010a47b494214e8b3416e ^_^

EDIT:
I managed to do a few today, and now I have 1-10 done. ^_^


Quote:

remember to hide your solutions in spoiler tags and try not to ever post the complete solution!
I would, but I don't know how much code I could give before giving the answer away. =/

Reincarnate 10-21-2011 08:39 AM

Re: THE project euler thread
 
I was into this for a while but got bored. It's a lot of fun, though. Some of the later problems are very tricky.

iironiic 10-21-2011 12:00 PM

Re: THE project euler thread
 
@leonid: I got an answer to #80 but I don't understand why it's not the correct answer. Can you help me figure out the problem in my code?

Just to see if there is something wrong in my code, I tried using my program to help me determine some values. Let's define the digital sum of the first 100 digits of radical n to be f(n).

Are these values correct? I chose a few test numbers just to see if my program is telling me the right digital sum. It did tell me that f(2) = 475 which was given in the problem.

f(3) = 441
f(7) = 398
f(35) = 440
f(69) = 439
f(95) = 460

Any help would be appreciated. Thanks!

emerald000 10-21-2011 12:35 PM

Re: THE project euler thread
 
From what I can see, you seem to be rounding off your 100th decimal.

iironiic 10-21-2011 01:47 PM

Re: THE project euler thread
 
Quote:

Originally Posted by emerald000 (Post 3554695)
From what I can see, you seem to be rounding off your 100th decimal.

Well... in the case of radical 2, this is the string of digits I got from my program: {141421356237309504880...}. This is including that one digit to the left of that decimal point because the sum from that digit to the 99th decimal digit is the given 475. What confuses me is this phrase: "first one hundred decimal digits". Does this include or exclude that beginning digit? If it excludes it, the sum should've been 481.

I don't think it's a rounding error because the 100th decimal digit of radical 2 is 7, which would round the 99th decimal digit up. When I created that set of digits, 2 was the last element of that set, so that doesn't seem to be the problem in my program.

emerald000 10-21-2011 02:17 PM

Re: THE project euler thread
 
Let's take f(95). Its 100 digits are: (note my program counts backwards)

7, 2, 5, 5, 6, 0, 8, 3, 0, 6, 9, 0, 2, 1, 7, 8, 4, 8, 6, 5, 3, 9, 4, 2, 0, 6, 4, 2, 7, 7, 1, 8, 0, 0, 2, 7, 5, 0, 0, 0, 5, 7, 1, 9, 9, 1, 3, 0, 1, 9, 4, 7, 3, 3, 0, 0, 9, 3, 8, 5, 2, 5, 2, 9, 9, 2, 0, 0, 6, 9, 9, 8, 9, 9, 1, 3, 1, 4, 8, 3, 8, 6, 0, 9, 3, 6, 9, 8, 0, 8, 4, 4, 3, 4, 9, 7, 6, 4, 7, 9


which gives a sum of 459. The 101st decimal is a 6, so if rounded up the 7, you would get to your answer of 460.

And yes the problem isn't clear, but thanks to the example, you can understand they mean to have 100 significant digits.

Reincarnate 10-21-2011 06:20 PM

Re: THE project euler thread
 
hmm maybe I will get back into this

seeing leonid ahead of me is making my competitive core act up (by that I mean he could kick my ass at this shit but idgaf)


heh solved problem 68 in excel

iironiic 10-21-2011 07:37 PM

Re: THE project euler thread
 
Quote:

Originally Posted by emerald000 (Post 3554738)
Let's take f(95). Its 100 digits are: (note my program counts backwards)

7, 2, 5, 5, 6, 0, 8, 3, 0, 6, 9, 0, 2, 1, 7, 8, 4, 8, 6, 5, 3, 9, 4, 2, 0, 6, 4, 2, 7, 7, 1, 8, 0, 0, 2, 7, 5, 0, 0, 0, 5, 7, 1, 9, 9, 1, 3, 0, 1, 9, 4, 7, 3, 3, 0, 0, 9, 3, 8, 5, 2, 5, 2, 9, 9, 2, 0, 0, 6, 9, 9, 8, 9, 9, 1, 3, 1, 4, 8, 3, 8, 6, 0, 9, 3, 6, 9, 8, 0, 8, 4, 4, 3, 4, 9, 7, 6, 4, 7, 9


which gives a sum of 459. The 101st decimal is a 6, so if rounded up the 7, you would get to your answer of 460.

And yes the problem isn't clear, but thanks to the example, you can understand they mean to have 100 significant digits.

Thanks! I just got 80 and 69 now! :)

fido123 10-21-2011 09:58 PM

Re: THE project euler thread
 
I think I'm going to get started with this. Wanted to work on my programming skills. On my reading week and nobody else I know is so why not. Probably going to work in C or Perl.

leonid 10-21-2011 10:25 PM

Re: THE project euler thread
 
Problem 96 is solving 50 sudoku problems. I'm very tempted to cheat

danny53x 10-21-2011 10:48 PM

Re: THE project euler thread
 
How do I learn this stuff and become a cool programmer like you guys ; _;

TC_Halogen 10-22-2011 02:16 AM

Re: THE project euler thread
 
I'm interested in playing this but I have very little coding experience, haha.

Reincarnate 10-22-2011 01:20 PM

Re: THE project euler thread
 
Good way to learn imo

stargroup100 10-23-2011 02:38 AM

Re: THE project euler thread
 
Quote:

Originally Posted by danny53x (Post 3555090)
How do I learn this stuff and become a cool programmer like you guys ; _;

Project Euler is a set of problems that encourages the use of clever math to simplify programming problems. If you're not inherently good at math, this is gonna be really hard for you no matter how someone teaches you. (Except for the first few problems, which are pretty easy.)

If, on the other hand, you just want to learn programming, this is one way of starting out. At least it gives you a goal.

Man, I need to find more time to do this.

foilman8805 10-23-2011 02:53 AM

Re: THE project euler thread
 
Thanks OP for giving me something to do with my brain while I'm in between jobs. This is awesome. I'll be programming in MATLAB/Octave. I just did the first two problems as a bit of a warm up and it was a lot of fun.

Problem 1
Code:

%% Euler Project - Problem 1

% Find the sum of all multiples of 3 or 5 below 1000.

sum = 0;

for i=3:999
    if rem(i,3) == 0 || rem(i,5) == 0
        sum = sum + i;
    end
end

sum



Problem 2
Had to first write a function to calculate the numbers in the Fibonacci sequence given any input:
Code:

function fib = fibonacci(x)

if x == 0
    fib = 0;
elseif x == 1
    fib = 1;
else
    fib = fibonacci(x-1) + fibonacci(x-2);
end


I then implemented that function in the script file below to find the solution:
Code:

%% Euler Project - Problem 2

% By considering the terms in the Fibonacci sequence whose values do not
% exceed four million, find the sum of the even-valued terms.

% First need to find at what term the Fibonacci sequence goes over
% 4 million. I created a supplimentary function file called fibonacci.m
% that calculates the values of the Fibonacci sequence given an input.
% i.e. fibonacci(10) will output 89.

i = 0;
fib = 0;

while fib <= 4000000
    i = i + 1;
    fib(i) = fibonacci(i);
end

% The loop above identifies that there are 33 values in the Fibonacci sequence
% that don't exceed 4,000,000. Now we will add up each even term.

for j = 1:33
    if rem(fib(j),2) == 0
        sumfib(j,1) = fib(j);
    else
        sumfib(j,1) = 0;
    end
end
   
answer = sum(sumfib)


foilman8805 10-23-2011 03:11 AM

Re: THE project euler thread
 
Interesting, I actually had to augment the source code in MATLAB in order to do Problem 3.

For some reason MATLAB arbitrarily sets a limit on prime factoring numbers larger than 2^32. Opened up the factor.m and changed it to 2^50, so this solution pretty much became a one-liner.

Problem 3
Code:

%% Euler Project - Problem 3

% The prime factors of 13195 are 5, 7, 13 and 29.

% What is the largest prime factor of the number 600851475143?

pf = factor(600851475143);

lpf = max(pf)


Reincarnate 10-23-2011 10:23 AM

Re: THE project euler thread
 
hit a wall with this problem :|

Reshiram 10-23-2011 12:33 PM

Re: THE project euler thread
 
I'm not gonna use programs. :3

Problem 1:

Take the smallest multiple of 3, add the largest, and multiply by 166.5.
Take the smallest multiple of 5, add the largest, and multiply by 99.5.
Subtract the sum of the common multiples.

stargroup100 10-23-2011 01:04 PM

Re: THE project euler thread
 
Upon first glance, that problem looks pretty trivial. But since Rubix is having trouble with it, it must be far from that. LOL

I'll take a crack at it.

stargroup100 10-23-2011 01:18 PM

Re: THE project euler thread
 
After taking a look at the problem, here's what I have so far. (I'm sure you already figured out this much, it's all the obvious stuff.)

Problem 355:

For Co(n), let the maximal sum subset be denoted as S.
Each prime factor below n must be found in the factorization of exactly one term in S. As such, we can start off the problem with a base case by creating a subset of all the primes below n (and 1) and then raising each of these primes to the highest power possible to maximize the sum.

However, it is possible that a term has the form (p^a)(q^b), where p and q are primes, if (p^a)(q^b) > p^c + q^d. (where a,b,c,d are the highest possible powers such that each term is less than n)

So the problem becomes reduced to figuring out how to find all of the optimizations for the sum. Chances are, there's some pattern that can use the fact that they give you the values of Co(30) and Co(100).


I'll edit with more content once I figure out more. BRB FOOD LOL

dag12 10-23-2011 02:27 PM

Re: THE project euler thread
 
Sounds like you could just write a script for euler's totient function and then run a for loop or something >.>
Though I'm sure there's a more elegant way of doing it.

Also, any way to check answers without registering?

Reincarnate 10-23-2011 02:28 PM

Re: THE project euler thread
 
Quote:

Originally Posted by dag12 (Post 3555944)
Sounds like you could just write a script for euler's totient function and then run a for loop or something >.>
Though I'm sure there's a more elegant way of doing it.

Also, any way to check answers without registering?

tried this :<

and no you have to register

stargroup100 10-23-2011 03:11 PM

Re: THE project euler thread
 
UGH

okay this problem is seriously impossible tackling it the way I'm doing it unless there's some beautiful optimization trick

this is not working

Reincarnate 10-23-2011 03:24 PM

Re: THE project euler thread
 
getting close but still off

the way I am tackling it is actually very similar to what you posed above (raising primes to powers) but figuring out where to fix things is tricky

For Co(10):
sorted mainlist [1, 5, 7, 8, 9]
sum of mainlist 30
primes [3, 5, 7]

this is fine

For Co(30):
sorted mainlist [1, 11, 13, 17, 19, 23, 25, 27, 28, 29]
sum of mainlist 193
primes [3, 5, 7, 11, 13, 17, 19, 23, 29]

this is correct too

But for Co(100):
sorted mainlist [1, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 81, 83, 89, 97, 98]
sum of mainlist 1248
primes [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

this is incorrect

iironiic 10-23-2011 03:38 PM

Re: THE project euler thread
 
Should 99 be in your sorted mainlist for Co(100)?

I'm thinking about an approach right now, but I haven't come up with anything yet.

Reincarnate 10-23-2011 03:42 PM

Re: THE project euler thread
 
Quote:

Originally Posted by iironiic (Post 3555968)
Should 99 be in your sorted mainlist for Co(100)?

I'm thinking about an approach right now, but I haven't come up with anything yet.


sorted mainlist [1, 7, 11, 13, 16, 17, 19, 23, 25, 27, 29]
sum of mainlist 188
primes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

This is what I get for Co(30) without that optimization and going for power-raising alone. Obviously I need to toss 28 into this beast, but in doing so I must remove 7 and 16.

EDIT: What I do now, in general is create the "naive prime-raised" solution and then add numbers to the solution and remove all coprime elements, then check to see if that sum is better than what I had before. If so, update solution. If not, kept what I had before and try a new number.


Reincarnate 10-23-2011 04:36 PM

Re: THE project euler thread
 
Hm somehow it's one off, wtf


sorted mainlist [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97, 99]
sum of mainlist 1355
primes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

LongGone 10-23-2011 04:51 PM

Re: THE project euler thread
 
Quote:

Originally Posted by stargroup100 (Post 3555927)
Problem 355:

However, it is possible that a term has the form (p^a)(q^b), where p and q are primes, if (p^a)(q^b) > p^c + q^d. (where a,b,c,d are the highest possible powers such that each term is less than n)

Could this be extended to cover cases of (p^a)(q^b)(r^c) > p^d + q^e + r^f etc. ? I can't think of an example though. The huge annoyance here is that the list of numbers are exhaustive, everytime you form a set of p,q there could be another set which may use them more efficiently instead (pointing out the obvious though)

stargroup100 10-23-2011 04:56 PM

Re: THE project euler thread
 
I have a conjecture that a term of the form (p^a)(q^b)(r^c) is never found in a maximal sum subset, but I'm not sure if I can prove it. If this is true it would at least make the problem significantly easier. I forgot to mention this earlier.

Reincarnate 10-23-2011 05:00 PM

Re: THE project euler thread
 
can anyone find the problem in my earlier list? should equal 1356, not 1355 (according to the problem description)

stargroup100 10-23-2011 05:03 PM

Re: THE project euler thread
 
lurker had the same problem

I'm trying to find the error as well

LongGone 10-23-2011 06:00 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556009)
can anyone find the problem in my earlier list? should equal 1356, not 1355 (according to the problem description)


Since you are one off from the actual answer (changing from odd to even), it implies that one set of (p^a)(q^b) should be degrouped, or grouped (e.g. 5*19=95(odd), or 5^a+19^b=even). Swapping pairs of number products will not change the odd/even parity
The main concern are the primes <10 in this case (because obviously you can't multiply two primes >10 that will result in <100 product)
So the usable primes are 2,3,5,7
Since you used up all 4 and ended up with 1355; If 1356 was not a mistake, that means that you have to degroup one of those primes and leave one as a natural power of itself (which is counterintuitive)
...So either the 13 people who solved didnt bother checking Co(100), or I'm missing something rofl
(or a rare case of a possible product of three primes, which idk if its plausible)

For a possible general approach, to try to maximise sum, we can start by getting rid of all the small primes
So e.g. for Co(100), start with 11,13,17,19. With your current solution we got: 99 (3,11), 95 (5,19), and 92 (2,23), 91 (7,13). Could there be a possible solution using 17 in place of 23?


stargroup100 10-23-2011 06:10 PM

Re: THE project euler thread
 
edit2: ok I was being stupid

EDIT: Rubix, your answer might be wrong but it looks pretty close :D

Reincarnate 10-23-2011 06:13 PM

Re: THE project euler thread
 
A step-by-step runthrough of the Co(100) process:

initial naive list from prime-raising alone: [1, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 81, 83, 89, 97] with sum 1263

adding 99 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 97, 99]
Updating list because biggestsum 1263 is less than 1270
adding 98 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 98, 99]
adding 96 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 96, 97]
adding 95 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 95, 97, 99]
Updating list because biggestsum 1270 is less than 1321
adding 94 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 31, 37, 41, 43, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 94, 95, 97, 99]
adding 93 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 93, 95, 97]
adding 92 to the list and removing non-coprimes to test [1, 13, 17, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
Updating list because biggestsum 1321 is less than 1326
adding 91 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97, 99]
Updating list because biggestsum 1326 is less than 1355
adding 90 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 90, 91, 97]
adding 88 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 88, 89, 91, 95, 97]
adding 87 to the list and removing non-coprimes to test [1, 17, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 87, 89, 91, 92, 95, 97]
adding 86 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 47, 53, 59, 61, 67, 71, 73, 79, 83, 86, 89, 91, 95, 97, 99]
adding 85 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 85, 89, 91, 92, 97, 99]
adding 84 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 84, 89, 95, 97]
adding 82 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 43, 47, 53, 59, 61, 67, 71, 73, 79, 82, 83, 89, 91, 95, 97, 99]
adding 81 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 81, 83, 89, 91, 92, 95, 97]
adding 80 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 80, 83, 89, 91, 97, 99]
adding 78 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 78, 79, 83, 89, 95, 97]
adding 77 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 77, 79, 83, 89, 92, 95, 97]
adding 76 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 76, 79, 83, 89, 91, 97, 99]
adding 75 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 75, 79, 83, 89, 91, 92, 97]
adding 74 to the list and removing non-coprimes to test [1, 17, 29, 31, 41, 43, 47, 53, 59, 61, 67, 71, 73, 74, 79, 83, 89, 91, 95, 97, 99]
adding 72 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 72, 73, 79, 83, 89, 91, 95, 97]
adding 70 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 70, 71, 73, 79, 83, 89, 97, 99]
adding 69 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 69, 71, 73, 79, 83, 89, 91, 95, 97]
adding 68 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 68, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 66 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 66, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 65 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 65, 67, 71, 73, 79, 83, 89, 92, 97, 99]
adding 64 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 63 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 63, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 62 to the list and removing non-coprimes to test [1, 17, 29, 37, 41, 43, 47, 53, 59, 61, 62, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 60 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 60, 61, 67, 71, 73, 79, 83, 89, 91, 97]
adding 58 to the list and removing non-coprimes to test [1, 17, 31, 37, 41, 43, 47, 53, 58, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 57 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 57, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 56 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 56, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 55 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 55, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 54 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 54, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 52 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 52, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 51 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 51, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 50 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 50, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 49 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 48 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 48, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 46 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 46, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 45 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 45, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 44 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 44, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 42 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 42, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97]
adding 40 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 40, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 39 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 39, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 38 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 38, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 36 to the list and removing non-coprimes to test [1, 17, 29, 31, 36, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 35 to the list and removing non-coprimes to test [1, 17, 29, 31, 35, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 97, 99]
adding 34 to the list and removing non-coprimes to test [1, 29, 31, 34, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 33 to the list and removing non-coprimes to test [1, 17, 29, 31, 33, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 32 to the list and removing non-coprimes to test [1, 17, 29, 31, 32, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 30 to the list and removing non-coprimes to test [1, 17, 29, 30, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97]
adding 28 to the list and removing non-coprimes to test [1, 17, 28, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 27 to the list and removing non-coprimes to test [1, 17, 27, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 26 to the list and removing non-coprimes to test [1, 17, 26, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 25 to the list and removing non-coprimes to test [1, 17, 25, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 24 to the list and removing non-coprimes to test [1, 17, 24, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 23 to the list and removing non-coprimes to test [1, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 22 to the list and removing non-coprimes to test [1, 17, 22, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 21 to the list and removing non-coprimes to test [1, 17, 21, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 20 to the list and removing non-coprimes to test [1, 17, 20, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 19 to the list and removing non-coprimes to test [1, 17, 19, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 18 to the list and removing non-coprimes to test [1, 17, 18, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 16 to the list and removing non-coprimes to test [1, 16, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 15 to the list and removing non-coprimes to test [1, 15, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 14 to the list and removing non-coprimes to test [1, 14, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 13 to the list and removing non-coprimes to test [1, 13, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 12 to the list and removing non-coprimes to test [1, 12, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 11 to the list and removing non-coprimes to test [1, 11, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 10 to the list and removing non-coprimes to test [1, 10, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 9 to the list and removing non-coprimes to test [1, 9, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 8 to the list and removing non-coprimes to test [1, 8, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 7 to the list and removing non-coprimes to test [1, 7, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 6 to the list and removing non-coprimes to test [1, 6, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 5 to the list and removing non-coprimes to test [1, 5, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 4 to the list and removing non-coprimes to test [1, 4, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 3 to the list and removing non-coprimes to test [1, 3, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 2 to the list and removing non-coprimes to test [1, 2, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]

sorted, final mainlist [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97, 99]
sum of mainlist 1355

stargroup100 10-23-2011 06:21 PM

Re: THE project euler thread
 
Your solution is too linear. You should take into consideration the possible case that immediately adding the largest possible number won't optimize the overall total.

It's possible there is a different combination of the primes that rounds out to a better sum. I recommend this method:

- Separate primes into 3 categories: between 2 and sqrt(n), between sqrt(n) and n/2, and the others
- Add up all of the primes in the last category. These don't change.
- The terms in the second category have the most room for possible optimizations, and therefore should try to be optimized first. They obviously cannot be paired with a prime from its own category, so pair it with a prime from the first category. Try every combination here.
- The last possible case is that 2 primes from the first category might be paired together. Consider this generalization last.

Do it this way and see if you can get to 1356.


NOTE: I'm not sure if the last step is necessary, I'm trying to see if I can prove whether or not that last step is needed.

Reincarnate 10-23-2011 06:24 PM

Re: THE project euler thread
 
It's not adding just the largest possible number -- here, it's adding all possible numbers from 2 to (N-1) and checking how it affects the total after removing non-coprimes

LongGone 10-23-2011 06:37 PM

Re: THE project euler thread
 
For 100, we have 25 odd primes (including 1), and one even 2. The sum of 25 odd primes (raised to any power) sum up to odd, adding the power of 2 still makes it odd

However, since we can group primes, we most likely will be grouping the smallest primes. There are 4 primes <sqrt100, 2 3 5 7. By grouping, we have 22 odd numbers and 2. 2 can be combined with an odd number leaving 21 odd numbers and one even number. The sum of that is odd. 1356 is even (?????????)

Possible explanation would be that the solution for 1356 involves -not- grouping one of 3, 5 or 7 and leaving it as its natural power. The most plausible is 3^4=81. Alternatively, there may be a case where there is a coprime which is the product of 3 primes

stargroup100 10-23-2011 06:40 PM

Re: THE project euler thread
 
FFFF YOU ARE RIGHT

im dumb

Reincarnate 10-23-2011 06:51 PM

Re: THE project euler thread
 
.ok apparently my problem is that it risks getting caught in local optima. when it detects a better sum, it may be adding a number (and keeping it) that winds up not being a part of the final solution (or prevents another number from doing the same). Going from 1 to n gives me a diff number from n to 1.

stargroup100 10-23-2011 06:56 PM

Re: THE project euler thread
 
that's what I was trying to say lol

Reincarnate 10-23-2011 06:59 PM

Re: THE project euler thread
 
ah ok misunderstood what you meant

stargroup100 10-23-2011 07:12 PM

Re: THE project euler thread
 
what the hell I went back to look at the problems I already solved in project euler and I cannot for the life of me remember how I did these LOL

all I remember is that I did most of these with pencil/paper

stargroup100 10-23-2011 07:37 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556096)
Maybe something like this (building off SG's idea)

stuff

not quite

0 <= x < sqrt(n) list: [(1), 2, 3, 5]
sqrt(n) <= x < n/2 list: [7, 11, 13]
n/2 <= x list: [17, 19, 23, 29]

however, but my idea doesn't take into account longgone's new input, the fact that some of the primes from the first group might stand by themselves. however, if you combine your method with mine it should account for both cases pretty well.

FFR4EVA_00 10-23-2011 08:37 PM

Re: THE project euler thread
 
psst
{1, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 81, 83, 88, 89, 91, 95, 97}
i went off the fact that 81 is the largest number less than 100 of the form a^b

stargroup100 10-23-2011 09:02 PM

Re: THE project euler thread
 
Thanks to lurker and LG I can fix up my method a bit.

Okay, here's my updated algorithm. It seems to be pretty tight for the most part, but it is still fairly brute force and assumes two conjectures:

- A term in a maximal sum subset can never have more than two unique prime factors.
- When optimizing the sum of a subset by choosing to multiply two powers of primes, the two primes are never both below sqrt(n).

Assuming these conjectures, we use the method:
- Separate primes into 3 categories: between 2 and sqrt(n), between sqrt(n) and n/2, and the others
- Add up all of the primes in the last category. These don't change.
- Each of the terms in the first category can either be left by itself or paired with a term from the second category. Consider and test every case.

The total number of possible subsets to test for is exactly 9507!/(9421)!.

Hopefully we can do a little bit better than that, as this number is in the order of about 10^(well over 200).

Reincarnate 10-23-2011 09:15 PM

Re: THE project euler thread
 
I'm trying to find something that doesn't require bruteforce (most of the problems I've solved don't require it) -- this problem is bugging the hell out of me because I can't figure out anything more elegant

cry4eternity 10-23-2011 09:26 PM

Re: THE project euler thread
 
I just found this on Friday. Solved 1-22 as well as 67 now :p. This is actually pretty fun.

stargroup100 10-23-2011 09:43 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556158)
I'm trying to find something that doesn't require bruteforce (most of the problems I've solved don't require it) -- this problem is bugging the hell out of me because I can't figure out anything more elegant

feelin ya bro

but it's possible this is along the lines of what they want. after all, they ARE programming problems.

FFR4EVA_00 10-23-2011 10:45 PM

Re: THE project euler thread
 
i'm gonna go ahead and drop a gigantic hint for 354 since the upper bound is so insane i have no chance of programming it correctly:
2L^2/3 = 2*3^(any non-negative integer)*n^2*(6p+1)^4*(6q+1)^4*(6r+1)^2
n must only be a multiple of 2 and any primes of the form 6k-1
6p+1, 6q+1 and 6r+1 are distinct prime numbers; p, q and r are integers

stargroup100 10-23-2011 11:49 PM

Re: THE project euler thread
 
Right now I'm trying to figure out methods to significantly reduce the number of calculations needed to solve this, whether it's skipping possible subsets or finding a totally new method.

However, it's getting late and I'm getting sleepy, difficult to focus. I'll work more on this tomorrow.

FFR4EVA_00 10-24-2011 06:27 AM

Re: THE project euler thread
 
i'm seriously advocating that the quickest method would be starting at the set for Co(100) and drawing each Co(n+1) from Co(n)

FFR4EVA_00 10-24-2011 10:26 AM

Re: THE project euler thread
 
it's predictable though
basically it comes down to an iterative process
i think the hardest part would be how to arrange the arrays for optimal speed
i was thinking that you would basically set it up like this:
[a_2, a_3, a_5, a_7, ..., a_p]
p is the largest prime below n, and the a_i are not necessarily distinct, so that when you actually wanted to find Co(n) you'd remove duplicates and add 1

FFR4EVA_00 10-24-2011 01:29 PM

Re: THE project euler thread
 

5 : [4, 3, 5]
6 < 4+3, don't insert
6 : [4, 3, 5]
7 has one prime factor, insert
7 : [4, 3, 5, 7]
8 has one prime factor, insert
8 : [8, 3, 5, 7]
9 has one prime factor, insert
9 : [8, 9, 5, 7]
10 < 8+5, don't insert
10 : [8, 9, 5, 7]
11 has one prime factor, insert
11 : [8, 9, 5, 7, 11]
12 is skipped, prime factors are too small
12 : [8, 9, 5, 7, 11]
13 has one prime factor, insert
13 : [8, 9, 5, 7, 11, 13]
14 < 8+7, don't insert
14 : [8, 9, 5, 7, 11, 13]
15 > 9+5, insert
15 : [8, 15, 15, 7, 11, 13]
16 has one prime factor, insert
16 : [16, 15, 15, 7, 11, 13]
17 has one prime factor, insert
17 : [16, 15, 15, 7, 11, 13, 17]
18 is skipped, prime factors are too small
18 : [16, 15, 15, 7, 11, 13, 17]
19 has one prime factor, insert
19 : [16, 15, 15, 7, 11, 13, 17, 19]
20 gets a bit more complex
20 drags in 16 and 15, but 15 is also a multiple of 3
it quickly becomes apparent that the only thing one could do with the 3 is use 9
20+9 < 16+15, don't insert
20 : [16, 15, 15, 7, 11, 13, 17, 19]
21+5 > 15+7, insert
[16, 21, 5, 21, 11, 13, 17, 19]
20 < 16+5, don't attempt
21 : [16, 21, 5, 21, 11, 13, 17, 19]
22 < 16+11, don't insert
22 : [16, 21, 5, 21, 11, 13, 17, 19]
23 has one prime factor, insert
23 : [16, 21, 5, 21, 11, 13, 17, 19, 23]
24 is skipped, prime factors are too small
24 : [16, 21, 5, 21, 11, 13, 17, 19, 23]
25 has one prime factor, insert
25 : [16, 21, 25, 21, 11, 13, 17, 19, 23]
26 < 16+13, don't insert
26 : [16, 21, 25, 21, 11, 13, 17, 19, 23]
27 has one prime factor, insert, 7 is left over
[16, 27, 25, 7, 11, 13, 17, 19, 23]
14 < 16+7, don't attempt
27 : [16, 27, 25, 7, 11, 13, 17, 19, 23]
28 > 16+7, insert
28 : [28, 27, 25, 28, 11, 13, 17, 19, 23]
29 has one prime factor, insert
29 : [28, 27, 25, 28, 11, 13, 17, 19, 23, 29]
30 is skipped, too many prime factors
30 : [28, 27, 25, 28, 11, 13, 17, 19, 23, 29]

FFR4EVA_00 10-24-2011 01:50 PM

Re: THE project euler thread
 
like i said: the set doesn't have to be distinct in this arrangement
i could easily just leave empty spaces but hey, programming doesn't really like those
and 16 only has one factor i have no idea what you're talking about
what's going on with 21 is this: if a < b < c, then ac+b > ab+c
i just threw in the snippet about testing 20 because i figured a program would try it

LongGone 10-24-2011 03:26 PM

Re: THE project euler thread
 

#1. I think because he's listing the numbers in order of smallest prime factors, and some numbers are made up of two prime factors so he repeated them
#2. Probably "set 1" (i.e. primes below sqrt n for Co(n), using the product of two numbers from set 1 would be a waste

I had this thought, but I don't know if its useful. See if anyone finds a use of it.
As Stargroup listed 3 sets of numbers, for Co(n^2), where set 1 is for primes<n and set 2 between n and (n^2)/2. I propose listing numbers of set 1 in the form of n-a, and set 2 in the form n+b

For products not involving powers higher than 1 for each term, we have to fulfill this condition (n-a)(n+b)≤n^2 [e.g. for Co(100), (10-5)(10+9)<10^2]

Expand to n^2-na+nb-ab≤n^2

hence n(b-a)≤ab (but we don't know if a or b is bigger or smaller)
or b≤na/(n-a)

ok now what

FFR4EVA_00 10-24-2011 03:58 PM

Re: THE project euler thread
 
longgone is correct on 1 and 2
here's what you're confused about if i am right:

Quote:

[a_2, a_3, a_5, a_7, ..., a_p]
p is the largest prime below n, and the a_i are not necessarily distinct, so that when you actually wanted to find Co(n) you'd remove duplicates and add 1
Quote:

20 gets a bit more complex
20 drags in 16 and 15, but 15 is also a multiple of 3
it quickly becomes apparent that the only thing one could do with the 3 is use 9
20+9 < 16+15, don't insert
20 : [16, 15, 15, 7, 11, 13, 17, 19]
21+5 > 15+7, insert
[16, 21, 5, 21, 11, 13, 17, 19]
20 < 16+5, don't attempt
i have no idea why you're confused
what's going on is i give the program a number and its one or two prime factors
if there's 1, it automatically goes into the list (and the consequences of said action are played out)
if there's 2, i retrieve the numbers in the list that share the two factors
so for 20, i grab a_2 and a_5, while for 21, i grab a_3 and a_7
the idea is we're seeing if a set with n in it produces a larger sum than just copying over the previous set
of course, i can't forget that one or both of the numbers i retrieved might be duplicates
in both cases, i find that a_3 = a_5

i now need to find whether i can shuffle around the three primes ((2, 3, 5) for 20, (3, 5, 7) for 21) and produce a sum larger than that of the a_i i retrieved

for 20, i already know i'm using 2 and 5 as part of 20, so i need to figure out what to do with 3
i could simply choose to multiply it by itself, giving 3*3 = 9
so now i check to see if (a_2, a_3, a_5) = (20, 9, 20) is better than (a_2, a_3, a_5) = (16, 15, 15); in the quote i find it is not
i can't multiply 3 by 7 because 21 is larger than 20, so i am done

as for 21, i already know i'm using 3 and 7 as part of 21, so i need to figure out what to do with 5
i could simply leave it as 5, so i'm testing if (a_3, a_5, a_7) = (21, 5, 21) is better than (15, 15, 7); in the quote i find that it is
however, there's also the possibility that i could combine a_2 and a_5, making both 20; in the quote i find it doesn't work, and i can't mess with a_3 now since i changed it, so i am done

Knut.Angstrom 10-24-2011 04:18 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556057)
A step-by-step runthrough of the Co(100) process:

initial naive list from prime-raising alone: [1, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 81, 83, 89, 97] with sum 1263

adding 99 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 97, 99]
Updating list because biggestsum 1263 is less than 1270
adding 98 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 98, 99]
adding 96 to the list and removing non-coprimes to test [1, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 96, 97]
adding 95 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 95, 97, 99]
Updating list because biggestsum 1270 is less than 1321
adding 94 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 31, 37, 41, 43, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 94, 95, 97, 99]
adding 93 to the list and removing non-coprimes to test [1, 13, 17, 23, 29, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 93, 95, 97]
adding 92 to the list and removing non-coprimes to test [1, 13, 17, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
Updating list because biggestsum 1321 is less than 1326
adding 91 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97, 99]
Updating list because biggestsum 1326 is less than 1355
adding 90 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 90, 91, 97]
adding 88 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 88, 89, 91, 95, 97]
adding 87 to the list and removing non-coprimes to test [1, 17, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 87, 89, 91, 92, 95, 97]
adding 86 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 47, 53, 59, 61, 67, 71, 73, 79, 83, 86, 89, 91, 95, 97, 99]
adding 85 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 85, 89, 91, 92, 97, 99]
adding 84 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 84, 89, 95, 97]
adding 82 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 43, 47, 53, 59, 61, 67, 71, 73, 79, 82, 83, 89, 91, 95, 97, 99]
adding 81 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 81, 83, 89, 91, 92, 95, 97]
adding 80 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 80, 83, 89, 91, 97, 99]
adding 78 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 78, 79, 83, 89, 95, 97]
adding 77 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 77, 79, 83, 89, 92, 95, 97]
adding 76 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 76, 79, 83, 89, 91, 97, 99]
adding 75 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 75, 79, 83, 89, 91, 92, 97]
adding 74 to the list and removing non-coprimes to test [1, 17, 29, 31, 41, 43, 47, 53, 59, 61, 67, 71, 73, 74, 79, 83, 89, 91, 95, 97, 99]
adding 72 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 72, 73, 79, 83, 89, 91, 95, 97]
adding 70 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 70, 71, 73, 79, 83, 89, 97, 99]
adding 69 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 69, 71, 73, 79, 83, 89, 91, 95, 97]
adding 68 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 68, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 66 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 66, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 65 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 65, 67, 71, 73, 79, 83, 89, 92, 97, 99]
adding 64 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 64, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 63 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 63, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 62 to the list and removing non-coprimes to test [1, 17, 29, 37, 41, 43, 47, 53, 59, 61, 62, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 60 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 60, 61, 67, 71, 73, 79, 83, 89, 91, 97]
adding 58 to the list and removing non-coprimes to test [1, 17, 31, 37, 41, 43, 47, 53, 58, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 57 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 57, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 56 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 56, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 55 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 55, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 54 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 53, 54, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 52 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 52, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 51 to the list and removing non-coprimes to test [1, 29, 31, 37, 41, 43, 47, 51, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 50 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 50, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 49 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 48 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 47, 48, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 46 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 46, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 45 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 45, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 44 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 43, 44, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 42 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 41, 42, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97]
adding 40 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 40, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 39 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 39, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 38 to the list and removing non-coprimes to test [1, 17, 29, 31, 37, 38, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 36 to the list and removing non-coprimes to test [1, 17, 29, 31, 36, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 35 to the list and removing non-coprimes to test [1, 17, 29, 31, 35, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 97, 99]
adding 34 to the list and removing non-coprimes to test [1, 29, 31, 34, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 33 to the list and removing non-coprimes to test [1, 17, 29, 31, 33, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 32 to the list and removing non-coprimes to test [1, 17, 29, 31, 32, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 30 to the list and removing non-coprimes to test [1, 17, 29, 30, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97]
adding 28 to the list and removing non-coprimes to test [1, 17, 28, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 27 to the list and removing non-coprimes to test [1, 17, 27, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 26 to the list and removing non-coprimes to test [1, 17, 26, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 25 to the list and removing non-coprimes to test [1, 17, 25, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 24 to the list and removing non-coprimes to test [1, 17, 24, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 23 to the list and removing non-coprimes to test [1, 17, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 22 to the list and removing non-coprimes to test [1, 17, 22, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 21 to the list and removing non-coprimes to test [1, 17, 21, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97]
adding 20 to the list and removing non-coprimes to test [1, 17, 20, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 19 to the list and removing non-coprimes to test [1, 17, 19, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 18 to the list and removing non-coprimes to test [1, 17, 18, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 16 to the list and removing non-coprimes to test [1, 16, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 15 to the list and removing non-coprimes to test [1, 15, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97]
adding 14 to the list and removing non-coprimes to test [1, 14, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 95, 97, 99]
adding 13 to the list and removing non-coprimes to test [1, 13, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 12 to the list and removing non-coprimes to test [1, 12, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 11 to the list and removing non-coprimes to test [1, 11, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 10 to the list and removing non-coprimes to test [1, 10, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97, 99]
adding 9 to the list and removing non-coprimes to test [1, 9, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 8 to the list and removing non-coprimes to test [1, 8, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 7 to the list and removing non-coprimes to test [1, 7, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 92, 95, 97, 99]
adding 6 to the list and removing non-coprimes to test [1, 6, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97]
adding 5 to the list and removing non-coprimes to test [1, 5, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 97, 99]
adding 4 to the list and removing non-coprimes to test [1, 4, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]
adding 3 to the list and removing non-coprimes to test [1, 3, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97]
adding 2 to the list and removing non-coprimes to test [1, 2, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 95, 97, 99]

sorted, final mainlist [1, 17, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 92, 95, 97, 99]
sum of mainlist 1355

Your sum 1355 is not correct since you use 99 instead of 88 giving 1356

Knut.Angstrom 10-24-2011 04:24 PM

Re: THE project euler thread
 
1+64+81+25+49+11+13+17+19+23+29+31+37+41+43+47+53+59+61+67+71+73+79+83+89+97+
(95-25-19)+(91-49-13)+(88-64-11) =1356

fido123 10-24-2011 04:25 PM

Re: THE project euler thread
 
Worked on this for a little bit one night. Did 1, 2, and 6 all in C:


Question 1:
Code:

#include <stdio.h>

int main() {
        int sum=0, x;
        for (x=1; x < 1000; x++) if (x % 3 == 0 || x % 5 == 0) sum += x;
        printf ("%d\n", sum);
}




Question 2:

Code:

#include <stdio.h>

int main() {
        int sum=0, x=0, y=1, z;
        do {
                z = x + y;
                x = y;
                y = z;
                if (y % 2 == 0) sum += y;
        } while (y < 4000000);
        printf ("%d\n", sum);
}




Question 6:

Code:

#include <stdio.h>
#include <math.h>

int main() {
        int x, sq=0, sum=0;
        for (x = 1; x <= 100; x++) {
                sq += pow (x, 2);
                sum += x;
        }
        sum = pow (sum, 2);
        x = sum - sq;
        printf ("%d\n", x);
}



Easy stuff so far but I'm not really all that knowledgeable about math at all so I'm not sure how far I'll get with this lol.

FFR4EVA_00 10-24-2011 04:28 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556421)
Okay but what about needing to retrieve something lost? For instance, the solution to Co(100) includes a 17, which gets removed back in Co(51)

17 is brought back as part of Co(95)
95+17 > 85+19
it's the exact same phenomenon that occurs with 21 and 5 replacing 15 and 7


Quote:

Originally Posted by Reincarnate (Post 3556421)
Also some numbers will have more than 1 unique prime factor

i heard whispers that this is true but i am trying to rigorously disprove it

FFR4EVA_00 10-24-2011 04:56 PM

Re: THE project euler thread
 
yeah, i never said what those were, i'm sorry
a_p is just the number that is divisible by p in whatever set we're looking at (since we're supposed to be looking at coprime sets there is exactly one a_p for every p but not all a_p are unique)
the reason why i'm duplicating the terms is that i think it will be easier for a computer to traverse

LongGone 10-24-2011 05:18 PM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3556421)
Also some numbers will have more than 1 unique prime factors (e.g. 30 -> unique primes 2, 3, and 5)


Stargroup originally came up with the idea that having a composite being a product of 3 primes isn't efficient and will never be part of the maximum set. I had a thought and will back this up by saying that, in order for a composite to be in the set it has to have at least two terms from group 1 (otherwise it will exceed n). And it is intuitively known to be not efficient to group together two sets of numbers from set 1 (as you remove the chance of it being paired up with a set 2 number, which is more efficient to produce larger composites. So I'll assume that the solution set involves composites with at most two distinct primes (raised to whatever power). So in this case, 30 which has 3 prime factors will not be part of the solution set of Co

Reincarnate 10-24-2011 05:22 PM

Re: THE project euler thread
 
Quote:

Originally Posted by LongGone (Post 3556451)

Stargroup originally came up with the idea that having a composite being a product of 3 primes isn't efficient and will never be part of the maximum set. I had a thought and will back this up by saying that, in order for a composite to be in the set it has to have at least two terms from group 1 (otherwise it will exceed n). And it is intuitively known to be not efficient to group together two sets of numbers from set 1 (as you remove the chance of it being paired up with a set 2 number, which is more efficient to produce larger composites. So I'll assume that the solution set involves composites with at most two distinct primes (raised to whatever power)

I think this is a reasonable assumption to make

FFR4EVA_00 10-24-2011 06:04 PM

Re: THE project euler thread
 
@Reincarnate- that is correct, yes
now i'm messing around with a brute-force solution of sorts though, NOTHING like what i was doing before

FFR4EVA_00 10-24-2011 07:42 PM

Re: THE project euler thread
 
!!!!!!!!!
http://imageshack.us/photo/my-images/90/355v.png/

Reincarnate 10-24-2011 08:19 PM

Re: THE project euler thread
 
congrats FFR4, nicely done

stargroup100 10-25-2011 12:44 AM

Re: THE project euler thread
 
http://img268.imageshack.us/img268/5532/eulero.jpg

I got 0 eulerian points for this. mad

iironiic 10-25-2011 08:53 AM

Re: THE project euler thread
 
Got #71 with pencil and paper xD

EDIT: Nice FFREva!

FFR4EVA_00 10-25-2011 09:41 AM

Re: THE project euler thread
 
http://projecteuler.net/eulerians
"For the twelve most recent problems the difference, d, in the length of time to solve the problem (in minutes) between each member and the slowest in the table is calculated and log2(max(d,2)) points are awarded."
so every time someone solves the problem, the points of everyone who already solved it go up
in other words cosmovibe has 8 points now

Reincarnate 10-25-2011 10:58 AM

Re: THE project euler thread
 
I suck at this problem pretty hard, admittedly. It's always a split between making some assumption about the composite set (which yields the wrong answer) or trying all possible combinations (too large to run in this lifetime) -- the same problem that's been knocking at me from the beginning of this damn problem -_-


All times are GMT -5. The time now is 07:58 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution