|  |
03-15-2009, 08:04 PM
|
#1 (permalink)
|
It's all just 1s and 0s Join Date: Jan 2004 Location: in the lab Posts: 4,410
| programming problems for you solve Project Euler Quote:
What is 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.
The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.
Who are the problems aimed at?
The intended audience include students for whom the basic curriculum is not feeding their hunger to learn, adults whose background was not primarily mathematics but had an interest in things mathematical, and professionals who want to keep their problem solving and mathematics on the edge.
Can anyone solve the problems?
The problems range in difficulty and for many the experience is inductive chain learning. That is, by solving one problem it will expose you to a new concept that allows you to undertake a previously inaccessible problem. So the determined participant will slowly but surely work his/her way through every problem. | |
| |
07-08-2009, 03:27 PM
|
#2 (permalink)
|
True Techie Join Date: Jun 2009 Location: Europe Posts: 103
| Re: programming problems for you solve Have you managed to solve any yet?
I'm just getting into the language, just needing a couple more resources and I should in a couple of months, be able to attempt these. |
| |
07-09-2009, 02:48 AM
|
#3 (permalink)
|
01001100011011110110110 Join Date: Mar 2007 Location: Perth, Australia Posts: 1,940
| Re: programming problems for you solve Hmmm, how interesting! Let's see if we can get some compact code for problem 1. Code: void main (void)
{
uns16 var,answer;
while(var!=999)
{
var=var+3;
answer=answer+var;
}
var=0;
while(var!=1000)
{
var=var+5;
answer=answer+var;
}
}
__________________ "As a result of all this hardship, dirt, thirst, and wombats, you would expect Australians to be a dour lot. Instead, they are genial, jolly, cheerful, and always willing to share a kind word with a stranger, unless they are an American." -- Douglas Adams Click this if I helped you >>>> <<<< |
| |
07-09-2009, 06:12 PM
|
#4 (permalink)
|
Join Date: Jul 2005 Location: England Posts: 2,159
| Re: programming problems for you solve Code: int MAX = 10;
int calc(int q);
int main(void)
{
int q1 = 3;
int q2 = 5;
printf("%d + %d = %d\n", calc(q1), calc(q2), calc(q1) + calc(q2));
return EXIT_SUCCESS;
}
int calc(int q)
{
int points = (MAX - 1) / q; //points on the graph
int yDiff = (points * q) - q; //height of the slope
int area = (yDiff * points) / 2; //area under the graph
return area + (points * q); //return the area plus the graph offset
}
EDIT: just change MAX to 1000, I was testing it against 10 because that gave a known answer.
__________________ MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11 
There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
Last edited by kmote; 07-09-2009 at 06:16 PM.
|
| |
07-09-2009, 07:51 PM
|
#5 (permalink)
|
01001100011011110110110 Join Date: Mar 2007 Location: Perth, Australia Posts: 1,940
| Re: programming problems for you solve ^so what answer do you get? I haven't tested my code yet, as I'm on a Mac and I don't have a compiler...
edit: and lol, that's a pretty complicated way of doing it don'tcha think?
__________________ "As a result of all this hardship, dirt, thirst, and wombats, you would expect Australians to be a dour lot. Instead, they are genial, jolly, cheerful, and always willing to share a kind word with a stranger, unless they are an American." -- Douglas Adams Click this if I helped you >>>> <<<< |
| |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | |