Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879578 Posts in 32990 Topics- by 24371 Members - Latest Member: bullfrogma

May 24, 2013, 11:17:33 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Project Euler
Pages: 1 [2] 3 4 5
Print
Author Topic: Project Euler  (Read 4329 times)
Moczan
Level 5
*****



View Profile
« Reply #15 on: April 07, 2012, 01:50:38 AM »

Andy is using #C and you are listed as using ECMAScript, but what dialect are you using?

I've used Action Script 3, mainly because that's what I use daily and have a nice workspace already set up. Also, I solved a lot of similar problems using C and C++ while I was in school, so most of them were really trivial for me.
I will probably set up a Visual Studio C# and solve other problems with it as I always wanted to learn C# and that seems like a perfect opportunity to get familiar with the basic syntax.
Logged
JMickle
Level 10
*****


lqikq come home


View Profile
« Reply #16 on: April 07, 2012, 11:23:25 AM »

did it! haha i was completely mind-blocked the other night, using modulus is so obvious now, thinking about it.
Logged

Dialock
Level 0
**


View Profile Email
« Reply #17 on: April 07, 2012, 10:15:18 PM »

Thanks man, I really appreciate this site you recommended.  Math is not my strong suit, but improving my programming skills to make something else do the work is great.
Logged
imaginationac
Level 2
**


Makin' games instead of makin' money.

imaginationac@msn.com imaginationac1 imaginationac1
View Profile WWW Email
« Reply #18 on: April 08, 2012, 11:12:10 AM »

The site seems to be having major MySQL issues at the moment Sad
Logged

Youtube channel | Charger! Dev Log
              
Dacke
Level 10
*****


I have never been to Woodstock


View Profile
« Reply #19 on: April 08, 2012, 01:49:36 PM »

I'm really glad this is catching on!

Good job JMickle, I knew you could do it Wizard

Dialock, that's why I love programming! I have added you to the high score table Grin

imaginationac, apparently the site has had some trouble keeping up with all the traffic on Sundays (when new problems are added). They are working on upgrading their servers, but at least they are back online again now.

Personally I have been working on a small python "library" with practical functions and classes that are not part of Python. I'm just adding random stuff as I go along, but so far I have functionality for:
Code: (euler.py)
multiply(listOfNumbers)

Permutations(listOfElements/string) {next(), hasNext()}
//generating permutations one at a time, rather than all at once

BooleanPermutations(listSize) {next(), hasNext()}
//for listSize=2, it returns: [False, False], [False, True], [True, False], [True, True]

uniqueItems(listOfItems/string)

arePermutationsOfEachother(list1/string1, list2/string2)

reversed(integer)

isPalindrome(integer)

digitSum(integer)

binomialCoefficient(n, k)

PrimeSieve(limit) {isPrime(integer), getPrimeList()}

primeFactorization(integer)

greatestCommonDevisor(integer1, integer2)

leastCommonDenominator(integer1, integer2)

(The actual names in the library are a bit shorter though)
Logged

vegan • socialist • atheist • humanist • liberal • FOSSer
programmer • feminist • animal rights activist • pacifist • teetotaller
Ashkin
Level 10
*****



View Profile
« Reply #20 on: April 08, 2012, 01:58:59 PM »

... Wait, you're supposed to program functions to solve these problems? No wonder trying to solve the first one in my head was so hard. Facepalm
Anyway, just registered:
17340617327248_4330b9cda8e862e6254c2c02d799836f
I'll probably be terrible at this, but hey, it's worth a try.
Logged
Dacke
Level 10
*****


I have never been to Woodstock


View Profile
« Reply #21 on: April 08, 2012, 02:06:05 PM »

Hehe, yeah, that's the whole point Durr...?

Quote from: Project Euler
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

(But the first problem can be solved in your head, if you know the right formula(s). When you complete the problem you'll get access to a secret forum thread, where you can learn how Wink)

But anyway, glad to have you aboard! Grin
« Last Edit: April 08, 2012, 02:12:40 PM by Dacke » Logged

vegan • socialist • atheist • humanist • liberal • FOSSer
programmer • feminist • animal rights activist • pacifist • teetotaller
imaginationac
Level 2
**


Makin' games instead of makin' money.

imaginationac@msn.com imaginationac1 imaginationac1
View Profile WWW Email
« Reply #22 on: April 08, 2012, 03:04:32 PM »

Here's my key:

50667612327256_708fa68d07e1623bed1580aea227b9a0
Logged

Youtube channel | Charger! Dev Log
              
Ashkin
Level 10
*****



View Profile
« Reply #23 on: April 08, 2012, 09:41:20 PM »

Is problem 3 supposed to take up a lot of CPU and take forever (stupid default script timeout), or am I just doing something terribly, terribly wrong?
Logged
mokesmoe
Level 10
*****



View Profile Email
« Reply #24 on: April 08, 2012, 11:10:22 PM »

If it's taking forever you are doing something at least slightly wrong.

Are you stopping the script at some point? You make it sound like you aren't.
Logged
Ashkin
Level 10
*****



View Profile
« Reply #25 on: April 08, 2012, 11:15:18 PM »

If it's taking forever you are doing something at least slightly wrong.

Are you stopping the script at some point? You make it sound like you aren't.
Here's my code. FIX IT.
Code:
var largestnum:int;
for (var num:int = 1; num < 600851475143 / 2; num++)
{
for (var i:int = 3; i < Math.sqrt(num); i++)
{
if (600851475143 % num != 0) break;
if (i == (Math.sqrt(num) - 1)) trace(num);
if (num % i == 0) break;
}
}
trace(largestnum);
I had a (I think) stupider approach before, but even this times out (I hate FlashDevelop sometimes.)
Logged
Moczan
Level 5
*****



View Profile
« Reply #26 on: April 09, 2012, 12:55:36 AM »

FlashDevelop is just an IDE, you can't hate it for timing out cause that's FlashPlayer's work  Wink Also your code doesn't do anything. You should look up integer factorization to solve this problem.
Logged
Ashkin
Level 10
*****



View Profile
« Reply #27 on: April 09, 2012, 01:29:11 AM »

I already fixed it. On to problem 4 now.
Man, I feel stupid.
Logged
mokesmoe
Level 10
*****



View Profile Email
« Reply #28 on: April 09, 2012, 01:34:59 AM »

I misunderstood timing out. I though you meant you letting it run until it timed out, not that it timed out before finishing.

Anyways, I used a different method of solving it than checking each value:

I just kept dividing it by numbers, staring with two and going up by one whenever when it isn't divisible. The final number I use when the starting number reaches one is the largest prime factor.

Basically I take out prime factors one at a time until I've reached the last one.



Also nothing seems to ever change largestnum in your code and your if statement for trace(num) seems like it would never fire. (Unless sqrt returns an int.)

EDIT: ninja'd but oh well.
Logged
Toeofdoom
Level 2
**



View Profile WWW
« Reply #29 on: April 09, 2012, 04:01:11 AM »

I haven't done any for a while, but this is mine:


and a friend key: 10848697140136_72f6d8fa7b0732794b402f3dbeb406e6
I might have to try some more soon.

I managed to get in the first 30 for problem #345, but it was the easiest of 5 that came out at the same time. It's interesting seeing all the tricks you build up over time.
Logged

Pages: 1 [2] 3 4 5
Print
Jump to:  

Theme orange-lt created by panic