|
-
July 22nd, 2003, 11:32 AM
#11
Senior Member
The page reloads and the problem continues.
\"I have a 386 Pentium.\"
-
July 22nd, 2003, 02:38 PM
#12
Haha, nice feature...has anyone put it in the bugs thread?
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
-
July 22nd, 2003, 02:51 PM
#13
Originally posted here by debwalin
Haha, nice feature...has anyone put it in the bugs thread?
The way JM has responded to the other bugs posted, do you think it will actually do any good to post this problem there?
Cheers:
-
July 22nd, 2003, 03:43 PM
#14
Well, at least if we put it in there we will be justified in complaining, we can't complain if no one has even bothered to notify them
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
-
July 22nd, 2003, 04:10 PM
#15
Originally posted here by debwalin
Well, at least if we put it in there we will be justified in complaining, we can't complain if no one has even bothered to notify them
Point taken Deb.
Cheers:
-
July 25th, 2003, 04:16 PM
#16
i am surprised no one came out with a solution more legant than me... i was hoping for a more better and efficient method. the solution provided by me will cripple fro large nos.
hey any algo masters here..............
guru@linux:~> who I grep -i blonde I talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; mount; fsck; more; yes; gasp; umount; make clean; sleep;
-
July 25th, 2003, 04:37 PM
#17
Senior Member
Although he said he didn't want an algorithm in the original post, here's what I've come up with.
The input number squared tends to be the middle number in the sequence, so in the case of even numbers there will always be an even number of numbers... (kind of confusing isn't it) and for odd numbers, there will be an odd number of numbers. For most cases it seems that input_number^3 will equal closest_odd_numbers to the input_number^2 and counting away until you reach the cube... so for like invader said in the first post:
2 -> 2^2 = 4, closest odd numbers: 3 & 5, 3+5 = 8, done.
3 -> 3^2 = 9, closest odd numbers: 9, not 27 yet so keep going, 7 + 9 + 11, the numbers around 9, they equal 27, you're done. and so on.
The only catch is that this won't yield the lowest number starting the sequence like in the case of 4
Reality is the one who has it wrong, not you
-
July 25th, 2003, 04:49 PM
#18
another catch ... in which way to proceed while adding...
4 * 4 * 4 = 64 = I + 3 + 5 + 7 + 9 + II + 13 + 15
4*4= 16 closest odd no. 15 ...and add all the odd nos. lower than 15
but
for 5 * 5 * 5 = 125 =21 +23 +25 +27 +29
5*5=25
while adding proceed in both ways....
so how to decide in which way to proceed.
guru@linux:~> who I grep -i blonde I talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; mount; fsck; more; yes; gasp; umount; make clean; sleep;
-
July 25th, 2003, 04:52 PM
#19
Member
This will do it:
#include <iostream.h>
#include <list.h> //for list (obviously)
#include <math.h> //for char to int conversion
// Made by scat (Ryan Lucas)
int main() {
char * input = new char[5]; // 6 place holders
int num, cube;
list<int> list;
cout << " Please input desired number: " ;
cin >> input; cout "/n";
//Algorithim
_itoa (input, num, 10) //base ten conversion
cube = num * num * num;
cout << "/n Cube of "<< num << " : " << cube << "/n";
int checksum;
int odd = 1;
while(1) {
if (checksum == num) {
int count = list.GetCount();
for (int i = 0; i++; i < count) { //Gets numbers in list
int oNum = list.GetAt(i);
cout << "/nNumber (" << i << ") " << oNum << "/n";
}
break;
}
else if (checksum > num ) { //If addition didn't work
int get = list.GetCount();
odd = list.GetAt(get);
for (int i = 0; i++ ; i < (get - 1) ) { //Removes all numbers except the last one used
list.RemoveAt(i);
}
checksum = 0; //Resets checksum
continue; //Repeat loop with new number
}
else {
checksum = odd + (odd + 2); //total checksum
odd = odd + 2; //get next odd number
list.SetTail(odd); //put in the list
}
}
cout << "/n/n Goodbye!";
return 1;
}
I really am a genius. That's a tight algorithim. Someone hook the greenies...I'm close to grey!
Scat
 If the scatman can do it so can you.
-
July 25th, 2003, 04:58 PM
#20
Senior Member
Null, yeah that's what I meant when I said the catch for 4, you get 13 + 15 + 17 + 19 using my method but the lowest starting sequence starts at 1, not 13. You could always test both conditions, counting down from the floor of the closest odd integers as well as expanding from the square using odd numbers and see which is lower but there's more than likely another way to do it, maybe dynamically using smaller numbers to start with that we know the sequence for? Who knows, I'm at work so testing anything is hard with no compiler but I might take a look at doing it dynamically once I get home. If you can somehow get the endpoints of the sequence then it's nothing to loop through and print them all out.
Scat: You should initialize checksum, it could cause some crazy results..
Also look at your code"
checksum = odd + (odd + 2); //total checksum
odd = odd + 2; //get next odd number
list.SetTail(odd); //put in the list
This is the only place you set values in list. Since odd started as 1, the first value entered will be 3..
Otherwise it looks like it should work, though the whole checksum thing is slightly confusing but does keep it from erasing the everything except the next number all the time, though it seems like it could erase too much, just a thought to where it might break, I haven't done the math to see if it will always keep it from erasing too much but if you have then yes it's a good algorithm.
Reality is the one who has it wrong, not you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|