Jump to content

Bar Trivia


Khran

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...