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)

iironiic 11-12-2011 10:22 PM

Re: THE project euler thread
 
I haven't been doing these problems lately. I"ll get back to them when I have the time

reuben_tate 11-13-2011 06:42 AM

Re: THE project euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3566598)
We need more people to be in on this -- come join us in chat!

irc.chatspike.net
room Euler

I would, but I'm not as pr0 as you guys and I would feel left out. :<

Anyhow, just got 20 and 48. ^_^

EDIT: And 18! :razz:
Quote:

Originally Posted by Euler
18)
20) Find the sum of digits in 100!
48) Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000.


Choofers 11-13-2011 08:53 AM

Re: THE project euler thread
 
lol I'm reinstalling visual basic for this

stargroup100 11-15-2011 06:36 PM

Re: THE project euler thread
 
Quote:

Originally Posted by reuben_tate (Post 3566804)
I would, but I'm not as pr0 as you guys and I would feel left out. :<

Anyhow, just got 20 and 48. ^_^

EDIT: And 18! :razz:

I don't know about the other guys, but I'm willing to help anyone who is having trouble with problems I know how to do.

If you ever want to talk to me on irc, just type any form of my name and it'll ping me.

Reincarnate 11-15-2011 09:07 PM

Re: THE project euler thread
 
fffffffffffffffffffffffff---

leonid 11-19-2011 04:18 PM

Re: THE project euler thread
 
359 is going to be REALLY tough. 27 minutes in and nobody has solved yet wtf ??


EDIT: GET OWNED !!!!!!!!!!!!!!!


FFR4EVA_00 11-19-2011 07:36 PM

Re: THE project euler thread
 
I COMPLETELY forgot about 359 happening today

Reincarnate 11-19-2011 08:32 PM

Re: THE project euler thread
 


w00t

LongGone 11-19-2011 08:41 PM

Re: THE project euler thread
 
I obtained the general formula for 359 but idk how to code/program (and 358 too)

):

Reincarnate 11-19-2011 09:19 PM

Re: THE project euler thread
 
Learn either Python or C++ (Python is my baby although Ruby is leonid's) -- both come in handy depending on the problem.

C++ is better for speed (if I know the problem is going to require ugly bruteforce), but stuff like Python/Ruby is easy to script with.

Reincarnate 11-22-2011 07:05 PM

Re: THE project euler thread
 
fffff some of these are getting pretty tough

Reincarnate 11-27-2011 12:32 AM

Re: THE project euler thread
 
welp

360 is pretty much 353 on steroids

leonid 11-27-2011 01:23 AM

Re: THE project euler thread
 
360 ;_;

leonid 11-27-2011 02:41 AM

Re: THE project euler thread
 




yelm 11-27-2011 08:31 AM

Re: THE project euler thread
 
Gosh, can anybody give any hint about 360? I made an optimized bruteforce and it's still slow :( Anything I can do is prove that answer is divisible by 6 :(
357,358 and 359 was much simpler.

linky123456 11-27-2011 08:38 AM

Re: THE project euler thread
 
well this looks like fun :D

leonid 11-28-2011 06:34 AM

Re: THE project euler thread
 
now I'm level 8 :') (200 problems solved)


reuben_tate 12-4-2011 06:20 PM

Re: THE project euler thread
 
Quote:

Originally Posted by leonid (Post 3578037)
now I'm level 8 :') (200 problems solved)


Congrats! I'd have more problems solved, if only I could stop coming up with algorithms that takes O(2^n) time. >_<

Reincarnate 12-6-2011 03:09 PM

Re: THE project euler thread
 


awwww yeah

leonid 12-6-2011 03:13 PM

Re: THE project euler thread
 
dam nice

PriestREA 12-10-2011 08:32 PM

Re: THE project euler thread
 
For the sake of adding to the Project Euler thread, finished 1-10 so far.

Reincarnate 12-21-2011 05:24 PM

Re: THE project euler thread
 

Made it from level 10 to level 12 (50 more problems, or 300 total solved) -- and that's at a nonstop rate. I got a LOT of easy problems knocked out today (including a few brute-forcers that I've been letting run on my desktop while I work on the laptop).

What a rush ;-; Taking a break for now. My brain's frazzled and I feel like I've been a slave to this site for eons now.

iironiic 12-21-2011 05:26 PM

Re: THE project euler thread
 
Congrats Marcus! I haven't have the time to tackle this lately, but I'll change that in the next few days!

Reincarnate 12-21-2011 05:29 PM

Re: THE project euler thread
 
Some of my solutions suck though.

leonid, remember that question with the 2000x2000 matrix thing? I brute-forced it with squaring ;-;

One guy had a hilarious solution to... can't remember which problem, but he brute-forced it in 500+ hours in VBA, lmfao.

stargroup100 12-22-2011 12:13 AM

Re: THE project euler thread
 
why have so few people solved 177? looks pretty easy to me

gonna attempt that next I think

Reincarnate 12-22-2011 10:16 AM

Re: THE project euler thread
 
I've been working on 177 for like a week. It's hard. It was one of those annoying "low-numbered but crazy" problems like 152 that give a lot of trouble and are hard to get out of the way.

Also the inverse phi one was kinda cool.

PriestREA 12-26-2011 01:55 PM

Re: THE project euler thread
 
Done some work on Project Euler, well on my way to level 3 with 53 problems solved.

Reincarnate 12-31-2011 01:01 AM

Re: THE project euler thread
 


YEEEEEEEEESSSSSSSSSSSSSS!!!!!!!

This was such a hard problem, it's not even funny. ;-;

Reincarnate 02-24-2012 11:25 AM

Re: The Project Euler thread
 
doot doot doot



procrastinated on this one pretty hard

robertsona 02-24-2012 08:51 PM

Re: The Project Euler thread
 
starting this right now, have no idea what to expect

edit: (feeling really stupid but) do you need, like, a computer input type program for this. guh

Izzy 02-24-2012 09:03 PM

Re: The Project Euler thread
 
I haven't started it, but I think you would normally write a program that spits out text into a console and then you copy and paste that as your answer.

Reincarnate 02-24-2012 09:22 PM

Re: The Project Euler thread
 
Quote:

Originally Posted by robertsona (Post 3645181)
starting this right now, have no idea what to expect

edit: (feeling really stupid but) do you need, like, a computer input type program for this. guh

You just need any programming language.

I usually use either Python or C++ (mostly Python).

Reincarnate 03-15-2012 11:42 PM

Re: The Project Euler thread
 


Bam! Oh how I have wanted this badge for so very long

Reincarnate 04-16-2012 04:37 PM

Re: The Project Euler thread
 
Almost forgot to post this one:


Reincarnate 04-24-2012 06:59 PM

Re: The Project Euler thread
 
100 paasento

C1004A 04-24-2012 07:08 PM

Re: The Project Euler thread
 
project euler dominated :o

Reincarnate 04-28-2012 11:18 PM

Re: The Project Euler thread
 
lucked out getting the Perfection badge just in time... this new one is a doozy.

FFR4EVA_00 05-10-2012 02:43 PM

Re: The Project Euler thread
 
383 looks easy as ****
EDIT: as of 5:29 i have a formula for T5(5^n)
EDIT: as of 5:38 i have a general formula for T5(n)... sorta
EDIT: BAM

the most coding i did was with spreadsheets and i found the answer about 2 hours from starting work on it

Reincarnate 05-10-2012 04:36 PM

Re: The Project Euler thread
 
Haven't even looked at 383 yet... tried 382 for a bit and couldn't solve it, so I took a break, haha.

Reincarnate 05-10-2012 04:44 PM

Re: The Project Euler thread
 
Decided to try 383. Got a working approach for T5(n) very quickly but I don't think it's scalable yet

EDIT: Figured out T5(5^n)

iironiic 05-10-2012 05:22 PM

Re: The Project Euler thread
 
I'm working on 383 too. I got a formula for f5(n!) but nothing for T5(n) yet :(

Reincarnate 05-11-2012 12:15 AM

Re: The Project Euler thread
 
Just gotta knock back 382 and that's that
Not really a fan of recurrence-relation problems but meh

Reincarnate 05-30-2012 05:46 PM

Re: The Project Euler thread
 
Weeee, got it -- 100% again


Reincarnate 06-21-2012 12:05 AM

Re: The Project Euler thread
 
390 should be ok, but I am fearing 391. it's likely going to be brutal

Reincarnate 07-1-2012 03:42 PM

Re: The Project Euler thread
 
I've got a program that will solve for M(n) but is not scalable to higher levels

You know it's a tough problem when very few of the usual heavy hitters have solved it, even 24 hours after its release.

Reincarnate 07-4-2012 11:34 PM

Re: The Project Euler thread
 
391 solved, back to 100%. That one was tricky.

Bluearrowll 07-5-2012 07:20 PM

Re: The Project Euler thread
 
Until 392..

Choofers 07-26-2012 03:25 PM

Re: The Project Euler thread
 
So I'm teaching myself BASIC and I figure that this would be a good way to learn
Unfortunately, I can't even solve problem 1 because I'm a dumb shit rofl (I could solve on paper, but that'd take forever)

There's something wrong with my code.
Don't hate, I haven't touched a programming language since high school (so 2008)

Code:

count = 0
addNumber = 0
a$ = ""

[loop]
count = count + 1
if (count mod 3 = 0) or (count mod 5 = 0) then
addNumber = addNumber + count
print "Count = "; count
print "addNumber ="; addNumber
else
print "Count = "; count
print "addNumber ="; addNumber
end if

if count < 1000 then
goto [loop]
else
print addNumber
end if
stop



Some info regarding my code:
The a$ was a variable I used to make the code stop during the first if-then statement. It originally looked like this:
Code:

print "Count = "; count
print "addNumber ="; addNumber
print "press any button and enter to continue"
input a$
else

I know using goto makes me look like a newb programmer, but that's fine. I'm not too keen on streamlining my code just yet.

Choofers 07-26-2012 03:57 PM

Re: The Project Euler thread
 
Shit, I think I know what's wrong with my code. 2 mod 3 would end being 0. So it's adding to addNumber before it should be.

Reincarnate 07-26-2012 09:25 PM

Re: The Project Euler thread
 
2 mod 3 is 2

(x mod y is the remainder of x / y)

PS use Python instead, it's cooler



sumTotal = 0
num = 1
while num < 1000:
if (num % 3 == 0) or (num % 5 == 0):
sumTotal = sumTotal + num
num = num + 1
print sumTotal


Damn thing doesn't save formatting but w/e

Choofers 07-27-2012 02:46 PM

Re: The Project Euler thread
 
I am obviously retarded, because I'm still stuck on problem 1. I mirrored that code into BASIC (took me a bit to figure out while loops), and now I'm getting a huge number, literally twice as large as my original code. I downloaded Python though, let's see how that goes.

ugh I can't wait to go back to school rofl

edit: python's gay, going back to BASIC

leonid 07-27-2012 02:56 PM

Re: The Project Euler thread
 
ur gay

Choofers 07-27-2012 02:58 PM

Re: The Project Euler thread
 
thank you for your help

edit: Took a break from problem 1 and went onto a random problem under 10. Solved 6 after a bit of trouble, I was finding the difference for the first 1000 natural numbers and not 100. Whoops.

Reincarnate 07-27-2012 07:28 PM

Re: The Project Euler thread
 
What is your current code for problem 1

and seriously stop using BASIC, aaaaoooogugughghhh

Choofers 07-27-2012 10:16 PM

Re: The Project Euler thread
 
whats wrong with basic rofl, I download python 2.whatever and wanted to kill the lady making my chai latte.

I'll post my code tonight after I mess with it a bit.

Choofers 08-12-2012 06:21 AM

Re: The Project Euler thread
 
I actually never touched my code that night...

i touched myself.................

Reincarnate 11-16-2012 11:42 PM

Re: The Project Euler thread
 
Anyone else still playing any?

Eagerly awaiting #402

infinity. 11-17-2012 12:23 AM

Re: The Project Euler thread
 
i started on tuesday. i've got 17 correct answers so far, but i only know a semester's worth of python haha. the problems are starting to get out of my threshold

my account name is lpauley if you can do anything with it

infinity. 11-17-2012 12:24 AM

Re: The Project Euler thread
 
Quote:

Originally Posted by Choofers (Post 3734304)
whats wrong with basic rofl

also

EVERYTHING

Reincarnate 11-17-2012 11:03 AM

Re: The Project Euler thread
 
You use friend codes instead of usernames

Reincarnate 11-24-2012 10:45 PM

Re: The Project Euler thread
 
fuck

infinity. 11-24-2012 11:53 PM

Re: The Project Euler thread
 
74432925402977_edc6e913519320b2bbdef524348d21cc

kaiten123 12-10-2012 06:48 PM

Re: The Project Euler thread
 
started this a little while ago (i think registered years ago lol, but never solved anything til just recently), a few days of work and i'm at lvl 2.
probably wont solve much for a couple weeks because finals but some of these are pretty interesting.

axith 12-10-2012 08:35 PM

Re: The Project Euler thread
 
Just stumbled across this thread. I have 38 problems solved. I learned a bit of python for these problems. My problem is that I can often see an easy, brute force solution, but I don't have the math knowhow to get stuff solved in less than a few weeks (or at least such math isn't that intuitive to me). I think it's time to revisit these torturous problems.

Reincarnate 12-10-2012 08:46 PM

Re: The Project Euler thread
 
Practice makes perfect -- the more you solve, the more you'll learn

axith 12-13-2012 12:21 PM

Re: The Project Euler thread
 
for all it's worth, here's my friend key: 83532459359302_e704d4c6b1d37a7739410f38da156b2a

axith 12-18-2012 09:31 PM

Re: The Project Euler thread
 
So which keywords make python read from a text file? My eyes are buggy from looking though online reference stuff and there's several problems that require it..

emerald000 12-18-2012 10:00 PM

Re: The Project Euler thread
 
You will want to use:

Code:

file = open('/path/to/file')

file.read()      # Returns whole file.
file.readline()  # Will return line by line.
file.readlines()  # Returns a list of every line.

file.close()      # Close the file after you have read everything you need.


kaiten123 12-21-2012 08:13 PM

Re: The Project Euler thread
 
just did 96 which was cool since i never really used recursion in a way that was non-trivial before
no idea how you guys do some of the higher numbered ones, highest one i did was 243, which for some reason is many times easier than everything around it, didnt even write any code.

edit: got to lvl 3 :)

kaiten123 12-28-2012 10:24 PM

Re: The Project Euler thread
 
brute forced 407 lol
never saw that box at the bottom right before, is that new? or does it pop up when you solve something recent?

leonid 12-30-2012 12:11 AM

Re: The Project Euler thread
 
i should get back to solve rest of the problems

Arkuski 01-4-2013 02:36 PM

Re: The Project Euler thread
 
This is pretty awesome I'm giving some of these a go

Reincarnate 01-22-2013 07:52 PM

Re: The Project Euler thread
 
411 wasn't too bad -- pretty much an exercise in programming

Reincarnate 02-17-2013 11:40 AM

Re: The Project Euler thread
 
415... only 3 solvers after 7 and a half hours.

Yeah I can pretty much kiss my 100% goodbye

It's been fun, PE :(

MracY 02-21-2013 04:25 PM

Re: The Project Euler thread
 
Quote:

Originally Posted by Reincarnate (Post 3733717)
2 mod 3 is 2

(x mod y is the remainder of x / y)

PS use Python instead, it's cooler



sumTotal = 0
num = 1
while num < 1000:
if (num % 3 == 0) or (num % 5 == 0):
sumTotal = sumTotal + num
num = num + 1
print sumTotal


Damn thing doesn't save formatting but w/e

Just as a note to people who want to join Project Euler: this solution is not necessarily representative of what you will be doing.

Here are some of my crude notes for problem 1, that used logic in stead of programming:





vertical axis is m
horizontal axis is n


Sum of the series of 5 is 0.5nm+0.5m
Sum of the series of 3 is 0.5pq+0.5q

1000/5 = 200.
The last value here is 1000, so n = 199
m = 1000-5 = 995

1000/3 = 333 with 1 remainder, so p = 333
q = 1000-1 = 999

Sum5 = 0.5*199*995+0.5*995
= 99500

Sum3 = 0.5*333*999+0.5*999
= 167166

99500+166833=266333



There is overlap between the sums of multiples of 15.
1000/15 is 66 with 10 remainder, so x = 66
y = 1000-10 = 990

Sum of this series is 0.5xy+0.5y
= 0.5*66*990+0.5*990 = 33165

So the answer is: 99500+166833-33165 = 233168

leonid 02-22-2013 10:21 PM

Re: The Project Euler thread
 
@Reincarnate use code tag

Code:

while 1:
  print "INDENT"
  if "INDENT":
    print "MORE INDENT"
print "NEVER REACHES HERE"


reuben_tate 02-22-2013 10:32 PM

Re: The Project Euler thread
 
Maybe ill try to play around and do some more problems this weekend :) (I haven't touched PE in awhile) . gotta start on my take-home test and other school stuff first though xP

reuben_tate 02-26-2013 11:55 AM

Re: The Project Euler thread
 
Started doing this in my free time again :3 Just got problem 34 this morning. Problem and code below; any tips that can make me a better programmer or mathematician is greatly appreciated :P

problem:

145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.

Find the sum of all numbers which are equal to the sum of the factorial of their digits.

Note: as 1! = 1 and 2! = 2 are not sums they are not included.


solution: (in Java)

Code:

//this will be our final answer
                int probSum = 0;
               
                //at some point, the sum of the factorials of the digits won't be large enough to add up to the number
                //so choose our digits to be 9 and find when we have too many digits
                //our upper bound for curious numbers becomes k
                int i = 1;
                int nFact = factorial(9);
                int k = 9;
                while(i*nFact > k)
                {
                                k += 9*Math.pow(10, i);
                                i++;
                }
               
                for(int j=10; j <=k ; j++)
                {
                        String[] digits = (j+"").split("");
                       
                        int sum = 0;
                        for(int l = 1; l < digits.length; l++)
                        {
                                sum += factorial(Integer.parseInt(digits[l]));
                        }
                       
                        if(j==sum)
                        {
                                probSum += j;
                        }
                }
               
                System.out.println(probSum);




EDIT: cool, got another :3


Problem:

Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.

For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 53 = 49714.

What is the total of all the name scores in the file?


Solution:

Code:

int totalScore = 0;
               
                File file = new File("names.txt");
                Scanner scan = null;
                try
                {
                        scan = new Scanner(file);
                }
                catch (FileNotFoundException e) {}
                String nameString = scan.next();
                String[] names = nameString.split("\",\"");
                ArrayList<String> names2 = new ArrayList<String>();
                for(int i = 0; i < names.length; i++)
                {
                        names2.add(names[i]);
                }
               
                Collections.sort(names2);
                for(int i = 0; i < names2.size(); i++)
                {
                        char[] chars = names2.get(i).toCharArray();
                        int charSum = 0;
                        for(int j = 0; j < chars.length; j++)
                        {
                                charSum += chars[j] - 'A' + 1;
                        }
                        totalScore += charSum*(i+1);
                }
                System.out.println(totalScore);


Arkuski 03-1-2013 09:44 AM

Re: The Project Euler thread
 
Learned some jython, and these are all much easier

Choofers 07-15-2013 02:30 PM

Re: The Project Euler thread
 
I'm currently on my lunch break, so I decided that instead of studying for my ethernet and osi model exam tomorrow, I'd delve into powershell.

Had a bit of an issue getting custom scripts to work without having digital signatures, but oh well.


Code:

$count = 0
$total = 0
do{if (($count % 3 -eq 0) -or ($count % 5 -eq 0))
  {
  $total = $total + $count
  }
  else
  {
  $total = $total
  }
$count++
}
while ($count -lt 1000)
echo $total



this feels very reminiscent of java and maybe you DuDeZ will stop hating me because I'm not using BASIC

maybe ???


edit: problem two solved, I was originally incrementing my variables one number at a time but I quickly realized that this would need a variable for every number in the sequence lol


Code:

$f0 = 0
$f1 = 1
$fsum = 0
do{
  if ($f1 % 2 -eq 0)
  {
    $fsum = $fsum + $f1
  }
  if ($f0 % 2 -eq 0)
  {
    $fsum = $fsum + $f0
  }
  $f0 = $f0 + $f1
  $f1 = $f1 + $f0
  }
while ($f0 -lt 4000000)
echo $fsum



All times are GMT -5. The time now is 10:27 AM.

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