OK, so in the spirit of Code-Golf, I\'m trying out something new here: Code-Bowling.
In golf, you try to get the lowest score (smallest application, mos
Here we are. I use recursion, express all my numbers in their factorized form, and only output one char at a time. Unfortunately, the random number generator is simple.
#include
#include
using namespace std;
void startPutCharSequence(double currChar, double prevChar, double firstChar)
{
if (prevChar == 0)
{
putchar(currChar);
if(currChar / 11 == 7)
startPutCharSequence(3 * 37, currChar, currChar);
else if (currChar / 23 == 3)
startPutCharSequence(2 * 59, currChar, currChar);
else if (currChar / 13 == 5)
startPutCharSequence(2 * 3 * 17, currChar, currChar);
else if (currChar / 13 == 2 * 3)
startPutCharSequence(3 * 5 * 7, currChar, currChar);
}
else if (prevChar != 0 && currChar != 3)
{
putchar(currChar);
if(currChar == 3 * 37 && prevChar == 7 * 11 && firstChar == 7 * 11)
startPutCharSequence(2 * 3 * 19, currChar, firstChar);
else if (currChar == 2 * 3 * 19 && prevChar == 3 * 37 && firstChar == 7 * 11)
startPutCharSequence(2 * 5 * 11, currChar, firstChar);
else if (currChar == 2 * 5 * 11 && prevChar == 2 * 3 * 19 && firstChar == 7 * 11)
startPutCharSequence(3 * 5 * 7, currChar, firstChar);
else if (currChar == 3 * 5 * 7 && prevChar == 2 * 5 * 11 && firstChar == 7 * 11)
startPutCharSequence(2 * 5 * 11, currChar, firstChar);
else if (currChar == 2 * 5 * 11 && prevChar == 3 * 5 * 7 && firstChar ==7 * 11)
startPutCharSequence(103, 0 , 3);
else if(currChar == 2 * 59 && prevChar == 23 * 3 && firstChar == 23 * 3)
startPutCharSequence(101, currChar, firstChar);
else if(currChar == 101 && prevChar == 2 * 59 && firstChar == 23 * 3)
startPutCharSequence(2 * 5 * 11, currChar, firstChar);
else if(currChar == 2 * 5 * 11 && prevChar == 101 && firstChar == 23 * 3)
startPutCharSequence(3 * 5 * 7, currChar, firstChar);
else if(currChar == 3 * 5 * 7 && prevChar == 2 * 5 * 11 && firstChar == 23 * 3)
startPutCharSequence(2 * 5 * 11, currChar, firstChar);
else if(currChar == 2 * 5 * 11 && prevChar == 3 * 5 * 7 && firstChar == 23 * 3)
startPutCharSequence(103, 0, 3);
else if(currChar == 2 * 3 * 17 && prevChar == 13 * 5 && firstChar == 13 * 5)
startPutCharSequence(2 * 2 * 29, currChar, firstChar);
else if(currChar == 2 * 2 * 29 && prevChar == 2 * 3 * 17 && firstChar == 13 * 5)
startPutCharSequence(101, currChar, firstChar);
else if(currChar == 101 && prevChar == 2 * 2 * 29 && firstChar == 13 * 5)
startPutCharSequence(2 * 3 * 19, currChar, firstChar);
else if(currChar == 2 * 3 * 19 && prevChar == 101 && firstChar == 13 * 5)
startPutCharSequence(2 * 5 * 11, currChar, firstChar);
else if(currChar == 2 * 5 * 11 && prevChar == 2 * 3 * 19 && firstChar == 13 * 5)
startPutCharSequence(3 * 37, currChar, firstChar);
else if(currChar == 3 * 37 && prevChar == 2 * 5 * 11 && firstChar == 13 * 5)
startPutCharSequence(3 * 37, currChar, firstChar);
else if(currChar == 3 * 37 && prevChar == 3 * 37 && firstChar == 13 * 5)
startPutCharSequence(2 * 5 * 11, 0, 3);
else if(currChar == 3 * 5 * 7 && prevChar == 2 * 3 * 13 && firstChar == 2 * 3 * 13)
startPutCharSequence(103, currChar, firstChar);
else if(currChar == 103 && prevChar == 3 * 5 * 7 && firstChar == 2 * 3 * 13)
startPutCharSequence(2 * 2 * 2 * 13, currChar, firstChar);
else if(currChar == 2 * 2 * 2 * 13 && prevChar == 103 && firstChar == 2 * 3 * 13)
startPutCharSequence(2 * 2 * 29, 0, 3);
}
}
int main()
{
int start = 2 * 2 * 2 * 3 * 3;
putchar(--start);
putchar((start += (2 * 2 * 2 * 5)));
putchar(start);
putchar((start -= 11));
putchar((start -= 2 * 2 * 17));
srand((unsigned)time(0));
while(true)
{
int timeOfDay = rand() % 128;
if (timeOfDay == 11 * 7 || timeOfDay == 13 * 5 || timeOfDay == 3 * 23 || timeOfDay == 2 * 3 * 13)
{
startPutCharSequence(timeOfDay, 0, timeOfDay);
break;
}
}
putchar((start -= 19));
putchar((start -= 3));
return 0;
}