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

Login with username, password and session length

 
Advanced search

1403717 Posts in 68278 Topics- by 61944 Members - Latest Member: flaxseedplease

November 30, 2022, 10:34:19 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Project Euler
Pages: 1 2 [3] 4
Print
Author Topic: Project Euler  (Read 17074 times)
brettchalupa
Guest
« Reply #40 on: April 10, 2012, 05:32:15 PM »

Alright, going to start tonight with working on some. Going to use Ruby and do most of it within my browser or with Hackety Hack. Smiley
« Last Edit: April 10, 2012, 05:37:34 PM by brettchalupa » Logged
Dacke
Level 10
*****



View Profile
« Reply #41 on: April 10, 2012, 09:42:29 PM »

Oooh, sweet approach!
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Geeze
Level 5
*****


Totally.


View Profile
« Reply #42 on: April 10, 2012, 10:42:42 PM »

Add me
54856317327372_17246ea57cedf7d469046fcc4f8741bf
Logged

Dacke
Level 10
*****



View Profile
« Reply #43 on: April 10, 2012, 11:51:02 PM »

Mattivc and Geeze, I have added you both to the high score table Smiley

I am curious; who will be the first to reach Level 1 (25 problems solved) out of those who joined after the creation of this thread? Andy Wolff has a strong lead with 17 problems solved, but he solved his last problem four days ago so he is lacking in momentum.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Moczan
Level 5
*****



View Profile
« Reply #44 on: April 11, 2012, 02:13:18 AM »

Mattivc and Geeze, I have added you both to the high score table Smiley

I am curious; who will be the first to reach Level 1 (25 problems solved) out of those who joined after the creation of this thread? Andy Wolff has a strong lead with 17 problems solved, but he solved his last problem four days ago so he is lacking in momentum.

I'm on it, I didn't have internet whole day yesterday so I spent time polishing my C# skills. Had only first 25 problems saved so I couldn't do more  Sad
Logged
Geeze
Level 5
*****


Totally.


View Profile
« Reply #45 on: April 11, 2012, 04:33:36 AM »

ideone.com
I found this pretty useful if you want to work on problems when on any computer.
Pretty good selection of languages
Quote from: indeone.com
Briefly about ideone
ideone.com is a... pastebin. But a pastebin like no other on the Internet. More accurate expression would be online mini IDE and debugging tool.

Ideone is an Italian word for great ideas - because ideone.com is a place where your greatest ideas can spring to life.

ideone.com is designed mostly for programmers (but, of course, common plain text can also be uploaded). You can use it to:

    share your code (that's obvious - it is a pastebin, isn't it? Smiley) in a neat way,
    run your code on server side in more than 40 programming languages (number still growing)
    and do it all with your own input data!
    ideone.com also provides free Ideone API which is availabe as a webservice. Its functionality allows you to build your own ideone-like service!
    for logged in users Ideone offers possibility to manage their codes, publish multiple submissions at one go, and more.

All codes can be accessed through convenient hash links. Source code pages provide information about the code and its execution: memory usage, execution time, language and compiler version, code itself, input uploaded by the user, output generated by the program and error messages from compilers and interpreters.

It is in great measure your contribution that this service exists - it is you who share your ideas with us and report bugs and suggestions. We hope it is still going to be like this - as long as this site works! Thank you!


Also I envy python users who have lot bigger number limits, because there's many problems that have those very big numbers(And I don't trust doubles).
I kinda cheated on problem 20 (Find sum of digits in 100!) because int/long max is WAAAAYYY too small. I just calculated 100! using python and used the result as input for java-code.
Logged

Dacke
Level 10
*****



View Profile
« Reply #46 on: April 11, 2012, 05:11:07 AM »

If you are using Java, you may find BigInteger helpful:
http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html

It gives you an unlimited size for integers and has some prime-stuff built in that is missing in Python:

Quote from: BigInteger
Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in two's-complement notation (like Java's primitive integer types). BigInteger provides analogues to all of Java's primitive integer operators, and all relevant methods from java.lang.Math. Additionally, BigInteger provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.
 

Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Geeze
Level 5
*****


Totally.


View Profile
« Reply #47 on: April 11, 2012, 05:34:37 AM »

It gives you an unlimited size for integers and has some prime-stuff built
Logged

Moczan
Level 5
*****



View Profile
« Reply #48 on: April 11, 2012, 09:47:26 AM »

I think the whole point is in learning this stuff on your own. Many of the problems can be easily solved by using Wolfram Alpha/Mathematica but you won't learn much doing it like that  Wink
Logged
Dacke
Level 10
*****



View Profile
« Reply #49 on: April 11, 2012, 09:57:56 AM »

I limit my self to using Python, but I use lots of built in stuff even if it makes certain problems trivial. I also installed a bitarray-library, because Python sucks at big arrays. I guess it has to do with what your personal goals are. My main goal is to become efficient with Python. But if someone else just wants to focus on solving them in any way possible, that's totally fine too.

But if you don't take the time to solve the early problems properly in your language of choice, I think that the later problems will kick your ass. So if you "cheat" using Wolfram Alpha, you will probably be screwed later Smiley
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
andy wolff
Level 10
*****


-------


View Profile
« Reply #50 on: April 11, 2012, 10:15:36 AM »

I haven't had time for this since last weekend, but I want to get back to it as soon as I can. I'm doing this not to get a huge number of problems solved, but to write a large number of useful mathematical functions and learn as much as I can, so I haven't been cheating or taking the easy way out (more or less). Problem 18 is taking me longer to solve than it should because I'm trying to solve it in such a way that the same method will work for problem 67


Anyway, good work, everyone. It's good to see so many people doing this
Logged

imaginationac
Level 2
**


Makin' games instead of makin' money.


View Profile WWW
« Reply #51 on: April 11, 2012, 01:03:42 PM »

I started solving the problems using JavaScript, but wanted to learn CoffeeScript so I'm going back through the ones I've done so far.
Logged

Youtube channel | Charger! Dev Log
              
Ashkin
Guest
« Reply #52 on: April 11, 2012, 03:42:12 PM »

If you are using Java, you may find BigInteger helpful:
http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html

It gives you an unlimited size for integers and has some prime-stuff built in
Do you know if AS3 has an equivalent for this, or should I just use Number?
Logged
andy wolff
Level 10
*****


-------


View Profile
« Reply #53 on: April 11, 2012, 03:45:02 PM »

You should write methods for adding strings of arbitrary length like I did :s
Logged

Dacke
Level 10
*****



View Profile
« Reply #54 on: April 11, 2012, 03:56:57 PM »

@Ashkin: The main thing we use BigInteger for is to store big integers (the other stuff is just a bonus). But AS3 Number can store huge numbers and is much easier to use (because it is a primitive type rather than a class (I think?)). So in fact, Java programmers should be envious of Number Smiley
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
ham and brie
Level 3
***



View Profile
« Reply #55 on: April 11, 2012, 04:39:03 PM »

@Ashkin: The main thing we use BigInteger for is to store big integers (the other stuff is just a bonus). But AS3 Number can store huge numbers and is much easier to use (because it is a primitive type rather than a class (I think?)). So in fact, Java programmers should be envious of Number Smiley

AS3's Number is the same as Java's double. It can't store as many different integer values as Java's long.
Logged
Dacke
Level 10
*****



View Profile
« Reply #56 on: April 12, 2012, 04:21:45 AM »

Ah, thank you ham and brie, I was mistaken. I thought that Number was an integer format with max_value=10³⁰⁸; I (foolishly) didn't realize that it was a floating point number. I jumped to the wrong conclusion, because the AS3 documentation recommended using Number over int for big integers (which is horrible advice). I should be more careful when it comes to languages I know so little about.

AS3 Number is a double precision floating point number (FP64) and is therefore somewhat unsuitable for handling integers (it will start to bug out for big numbers and has some nasty side effects). It is the same as double in languages like Java.

But Number is not the same as Java's long. A long in Java is an int64, which has a much lower max_value (~10¹⁹) than a double's max_value (~10³⁰⁸). But in return int64 actually works for big numbers, as it is able store every integer up to it's limit (while Number/double just tries to approximate stuff).

Anyway, back to the actual question: Does AS3 have Big Integer support?
The answer seems to be no, it does not. At least not as a built-in. This is no reason for despair, though. The Project Euler problems were probably created under the assumption that you wouldn't have access to a BigInteger class. The actual challenge (that many of us have circumvented) is to implement your own handling of big integers (like Andy Wolff has)

First off you should probably do some reading on how integers are represented. Then write a simple class that supports what you need. You can have stuff like someBigInt.add(someOtherNumber). Where "someOtherNumber" can be an integer, another BigInt or a string representation of a number. Internally you can store the number as a String (Andy Wolff's approach), but I think you'll get better results if you store it as an array (or list) of unsigned integers (uint).

Or if you don't feel up to the task you can always use someone else's full-fledged BigInt implementation, perhaps this one?
http://kingtut666.wordpress.com/2011/04/19/bigint-in-actionscript-3-0/
(But do note that your own implementation would be much simpler that this one, because you don't need everything that is supported in that library)
« Last Edit: April 12, 2012, 04:31:51 AM by Dacke » Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #57 on: April 12, 2012, 11:31:25 AM »

the AS3 documentation recommended using Number over int for big integers (which is horrible advice).
That's because it can hold more integers than an int can. It does all integers up to 2^53, vs 2^32 for ints. In some circumstances this is handy, but not that many.
Logged
Dacke
Level 10
*****



View Profile
« Reply #58 on: April 12, 2012, 12:06:28 PM »

Yes, that's true of course Smiley
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
paste
Level 6
*


BARF!


View Profile WWW
« Reply #59 on: April 13, 2012, 03:39:07 AM »

I started trying one of these in order to help out Ashkin, but I think it would be a good tool to maintain/improve my c++ chops. Count me in!

26208935327762_b2070546136d1abdea67c7b31621a715
Logged

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

Theme orange-lt created by panic