Khran Posted February 23, 2007 Report Share Posted February 23, 2007 I'm normally good at these things, but tonight I just couldn't see this one. What do you all think it is and what is your logic behind your answer? What would the next number sequence be? * 1 * 11 * 21 * 1211 * 111221 * 312211 * 13112211 * 1113212221 * 311312113211 * Link to comment Share on other sites More sharing options...
BobcatFan Posted February 23, 2007 Report Share Posted February 23, 2007 easy 132113111221131221 I think that is right Link to comment Share on other sites More sharing options...
spiegel06 Posted February 23, 2007 Report Share Posted February 23, 2007 132113111221131221 I think this is it but I might be wrong, a bit tired at the moment, Link to comment Share on other sites More sharing options...
spiegel06 Posted February 23, 2007 Report Share Posted February 23, 2007 damn you bobcat you beat me to the punch.... Link to comment Share on other sites More sharing options...
BobcatFan Posted February 23, 2007 Report Share Posted February 23, 2007 I'm normally good at these things, but tonight I just couldn't see this one. What do you all think it is and what is your logic behind your answer? What would the next number sequence be? * 1 * 11 * 21 * 1211 * 111221 * 312211 * 1312211--- * 1113212221 * 311312113211 * you messed up on the 7th line i think Link to comment Share on other sites More sharing options...
Khran Posted February 23, 2007 Author Report Share Posted February 23, 2007 Yea, well I figured it out now. ***** SPOILER ***** 1 (next line is exactly the same thing, sort of...you have ONE one) 11 (next line same thing....two one) 21 (next line one two and one one) 1211 (next line the same thing, one one and one two and two one) 111221 312211 13112211 1113212221 311312113211 Link to comment Share on other sites More sharing options...
Khran Posted February 23, 2007 Author Report Share Posted February 23, 2007 Or if you want to solve it the easy way.... #include #include unsigned nextnum(unsigned k) { unsigned breakout[10]; unsigned i; for(i=0; i < 10; i++) breakout=0; while(k > 0) { breakout[k%10]++; k /= 10; } for(i=9; i > 0; i--) if (breakout>0) k = k*100 + 10*breakout + i; return k; } int main(int argc, char** argv) { unsigned x = 1; unsigned i; unsigned max = argc > 1 ? atoi(argv[1]) : 14; printf("iteration %2i: %8i\n", 0, x); for(i=1; i < max; i++) { x = nextnum(x); printf("iteration %2i: %8i\n", i, x); } return 0; } Link to comment Share on other sites More sharing options...
Fiere Posted February 23, 2007 Report Share Posted February 23, 2007 That way does not look easy to me at all. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.