Search found 12 matches

by suitti
Tue Aug 16, 2011 8:54 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 096
Replies: 15
Views: 4404

Problem 096

I was going to simply solve the 50 sudoku problems by hand. That would be 'pencil and paper', right? I started the first one (the one that has the solution given, no less). It turned out that the simple rule i was using by hand was enough to solve it. So i coded that rule up. It turns out that this ...
by suitti
Tue Aug 16, 2011 8:43 pm
Forum: Programming languages
Topic: Pick a Language
Replies: 19
Views: 14142

Re: Pick a Language

I recently spent free time over about two years with the LISP family language 'Scheme'. I had an implementation on a Palm Pilot, and on Linux (guile). Both implementations were quite slow compared to C. The Palm is incredibly portable, and i could spend a few minutes on some idea from time to time. ...
by suitti
Tue Aug 16, 2011 8:23 pm
Forum: Programming languages
Topic: for loops
Replies: 2
Views: 1758

Re: for loops

One of the problems with i, j is that in some fonts, i and j look very much alike. This is particularly bad when combined with copy and paste code. I learned Fortran in 1977. It was Fortran 66. Variables starting with the letters i through m were defaulted to integers, and therefore were handy for l...
by suitti
Tue Aug 16, 2011 7:06 pm
Forum: Programming languages
Topic: Creating a sieve of Eratosthenes in C ++
Replies: 16
Views: 7859

Re: Creating a sieve of Eratosthenes in C ++

Using <bool> may be considerably slower than a character or byte array. The computer will have to read a byte or word at a time and mask it on read. It will have to shift bits and or them in on write. If you only use one bit per byte, you can skip the masking code. My 9 or 10 year old machine has 1....
by suitti
Tue Aug 16, 2011 6:56 pm
Forum: Programming languages
Topic: c++ numbers out of range
Replies: 9
Views: 5147

Re: c++ numbers out of range

I don't always use the same language to work out problems. Some of the languages, like Unix's bc, and scheme have big number support. Perl has a module you can load. There are C & C++ bignum libraries. So, while i worked out how to do problem 97 in C without bignums, I kicked it off in bc. I mean, i...
by suitti
Tue Aug 16, 2011 6:42 pm
Forum: Programming languages
Topic: How to read in data with C?
Replies: 2
Views: 1910

Re: How to read in data with C?

Hmm. If you're reading a projecteuler.net (PE) file, you can eyeball the file in advance and construct an fscanf() string to parse it. In the real world, you seldom have enough control over the input so that fscanf() is a good idea. The problem is that fscanf() gives you very little feedback for inp...
by suitti
Tue Aug 16, 2011 6:23 pm
Forum: Programming languages
Topic: Int/String conversion in C
Replies: 3
Views: 2478

Re: Int/String conversion in C

Sometimes you need to do things like reverse digits in a number. For this you do not necessarily have to convert to a string. You can use the modulus operator to pick digits off of the least significant end of a number: a = x % 10; /* a gets the low digit */ x /= 10; /* x gets 'shifted' one decimal ...
by suitti
Tue Aug 16, 2011 3:13 pm
Forum: Resources
Topic: fast permutation
Replies: 5
Views: 5585

Re: fast permutation

A short algorithm, or piece of code, is not necessarily the fastest. For example, a selection sort is maybe five lines of code, which is much shorter than a quick sort. But selection sort grows in time proportional to the square of the number of elements, where quick sort generally grows in time pro...
by suitti
Fri Aug 12, 2011 3:36 pm
Forum: Recreational
Topic: Understanding the Universe
Replies: 14
Views: 5656

Re: Understanding the Universe

Another way to look at it is energy. With e = m c^2, it's the same thing. Let's say you have a ball in your hand. Toss it up. As the kinetic energy goes down, the potential energy goes up. You can define the sum of these energies as zero. So, the sum of the energy in the Universe is zero. We live in...
by suitti
Thu Aug 11, 2011 2:49 pm
Forum: Recreational
Topic: Suggested Careers that involve PE type thinking
Replies: 2
Views: 3086

Re: Suggested Careers that involve PE type thinking

Quite a bit of software is "bean counting". And one expects it to be boring. I've found some interesting problems where an upstream feed has data that simply can't be parsed, and can't be fixed, or fixed soon enough. Some really imaginative heuristics can save the day. Another problem was a data for...
by suitti
Thu Aug 11, 2011 2:29 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 032
Replies: 31
Views: 8086

Re: Problem 32

Remember, the word product means the answer you get from multiplying. In grade school, i thought i was good at word problems. But it wasn't until teaching my son how to get through them that i discovered how it is that i do them. Apparently, i think of lots of interpretations, pick one that seems m...
by suitti
Thu Aug 11, 2011 1:58 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 072
Replies: 36
Views: 7842

Re: Problem 072

I'm a programmer. I've got lots of engineering math behind me, but almost no number theory. Engineers don't use integers much, unless pi is about 3. Also, while the site encourages looking stuff up, i generally don't. For this problem, I started with the straight forward approach, and tested to make...