Re: A83: STOP!!!!!
[Prev][Next][Index][Thread]
Re: A83: STOP!!!!!
Bryan Rabeler wrote:
>
> James Matthews wrote:
>
> > STOP!!!! PLEASE!!!!
> >
> > Ha-ha, this is HILARIOUS! Christ guys...its cool, it was only 5% on my
> > math exam...I'll survive! :)
> >
> > Thanks for all the help...this IS a story to tell my teacher...lol. LMAO.
> >
> > James.
>
> Your welcome. :) But I still want to know how that guy got all 240 odd
> numbers in that email in what seems to be a total random order.
He he he, I'll never tell.
...
Actually:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define LEN 6
int main (void)
{
char str [LEN + 1] = "123451";
unsigned long *list = NULL;
int count = 0;
srand ((unsigned) time (NULL));
while (!kbhit ())
{
int i, found = 0;
unsigned long x;
for (i = 0; i < LEN; i++)
{
char temp = str [i];
int rnd = rand () % LEN;
str [i] = str [rnd];
str [rnd] = temp;
}
x = strtoul (str, NULL, 10);
for (i = 0; i < count; i++)
found = found || list [i] == x;
if (!found && x % 2)
{
list = realloc (list, (unsigned long) (count + 1)
* sizeof (unsigned long));
if (!list)
{
puts ("\n\nOut of memory!\n\n");
return EXIT_FAILURE;
}
list [count++] = x;
fprintf (stderr, "\b\b\b\b\b");
printf ("%s ", str);
fflush (stdout);
if (count % (60 / (LEN + 1)) == 0)
putchar ('\n');
fprintf (stderr, "%05d", count);
}
}
if (!getch ()) getch ();
fputs ("\b\b\b\b\b \b\b\b\b\b", stderr);
printf ("%s\nFinal count: %d\n", count % (74 / (LEN + 1)) ? "\n" :
"", count);
return 0;
}
It's probably even more brute force than any one imagined. :-) Except
for the kbhit() and getch() calls, it's standard C.
--
John Kugelman. kugelman@mnsinc.com
I believe we can change anything.
I believe in my dream.
- Joe Satriani
Follow-Ups:
References: