Advertisement Jump to content
Sign in to follow this  
bratiefanut

Unknown string of numbers..

This topic is 1755 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

How did you found this string? It's an excercise from a book or something? Or you know a crazy man how repeats them? If it's the latter, don't us them to win the lottery!

 

Anyway, if it's really supposed to be a sequence with some logic it also depends if it's a learning excercice or a lateral thinking excercise.

 

The only points I can see are:

  • Every number contains a 9
  • After a number composed of all 9's a new digit is added
  • For a certain number of digit, the valid values for each digits are 1 less than the valid values (1 digit > 9, 2 digits > 8 and 9, 3 digits > 7, 8 and 9).
  • It looks like if a number starts with 9, the next number has the first 2 digits swapped.
  • I have no idea of more rules, but clearly there are more things going on (why is it 899 the next number? no idea)

So, for the next number I'd guess is something like 6789 and the next one maybe 6798, but it's just a guess, there's no function or arlgorithm I can think of.

Share this post


Link to post
Share on other sites

Found it, thanks to DiegoSLTS observations...

 

Every time a new digit is added.

 

First you start with a nine, you can't swap anything there. Then you add a second digit and you allow numbers 8 and 9. Then you have three possibilities if every number should include at least one 9: 98, 89 and 99. After that you add another digit. The numbers allowed are 7, 8 and 9 like DiegoSLTS said. All numbers should again not have two times the same number except for the nine.

 

9

89 98 99

789 798 879 897 899 978 987 989 998 999

As you can see the numbers are grouped in terms of number of digits. The first number starts with the lowest digit first. The last number contains only nines. Aside from that I don't see the exact order inside a "digit group". But it looks like the order "prefers" lower digits first. Is this the pattern or is there also a pattern inside the groups?

Edited by ProtectedMode

Share this post


Link to post
Share on other sites

Those are the numbers whose histograms of digits are weakly increasing.

 

perl -e 'NUMBER: for $n (1..1000) {%c=(); for $d (split "",$n){$c{$d}++}; for $d (1..9) {next NUMBER if $c{$d} < $c{$d-1}} print "$n\n"}'

Share this post


Link to post
Share on other sites

Those are the numbers whose histograms of digits are weakly increasing.

perl -e 'NUMBER: for $n (1..1000) {%c=(); for $d (split "",$n){$c{$d}++}; for $d (1..9) {next NUMBER if $c{$d} < $c{$d-1}} print "$n\n"}'

Could you maybe provide the output too for people who don't have Perl installed? wink.png

Share this post


Link to post
Share on other sites

Outer loop seed = {9, 89, 789, 6789, ... 123456789, MAYBE 0123456789 }

 

Inner loop:  Take the digits you have available (for example with 789, you have the digits 7,8, and 9 to work with) and find the next higher integer with the same number of digits which uses only the digits you have available.  Terminate the inner loop when all digits are 9.

 

Your method would produce 877, but that wasn't in the list.

Share this post


Link to post
Share on other sites

 

Those are the numbers whose histograms of digits are weakly increasing.

perl -e 'NUMBER: for $n (1..1000) {%c=(); for $d (split "",$n){$c{$d}++}; for $d (1..9) {next NUMBER if $c{$d} < $c{$d-1}} print "$n\n"}'

Could you maybe provide the output too for people who don't have Perl installed? wink.png

 

9
89
98
99
789
798
879
897
899
978
987
989
998
999

 

 

If you loop till 10000, you get

9
89
98
99
789
798
879
897
899
978
987
989
998
999
6789
6798
6879
6897
6978
6987
7689
7698
7869
7896
7899
7968
7986
7989
7998
8679
8697
8769
8796
8799
8899
8967
8976
8979
8989
8997
8998
8999
9678
9687
9768
9786
9789
9798
9867
9876
9879
9889
9897
9898
9899
9978
9987
9988
9989
9998
9999

Share this post


Link to post
Share on other sites

Found it, thanks to DiegoSLTS observations...

 

Every time a new digit is added.

 

First you start with a nine, you can't swap anything there. Then you add a second digit and you allow numbers 8 and 9. Then you have three possibilities if every number should include at least one 9: 98, 89 and 99. After that you add another digit. The numbers allowed are 7, 8 and 9 like DiegoSLTS said. All numbers should again not have two times the same number except for the nine.

 

9

89 98 99

789 798 879 897 899 978 987 989 998 999

As you can see the numbers are grouped in terms of number of digits. The first number starts with the lowest digit first. The last number contains only nines. Aside from that I don't see the exact order inside a "digit group". But it looks like the order "prefers" lower digits first. Is this the pattern or is there also a pattern inside the groups?

 

Your method would produce 799, but that wasn't in the list.

Share this post


Link to post
Share on other sites
Your method would produce 877, but that wasn't in the list.
All numbers should again not have two times the same number except for the nine.
Edited by ProtectedMode

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!