Undulating numbers: Difference between revisions

Content added Content deleted
(J draft (hopefully these expressions are sufficient labels for their results))
m (→‎{{header|J}}: presort undul numbers - this could be made more efficient by sorting when the base is chosen)
Line 233: Line 233:
So, given:
So, given:
<syntaxhighlight lang=J>require'stats'
<syntaxhighlight lang=J>require'stats'
undul=: {{ m #. y$"1 (,|."1)2 comb m }}
undul=: {{ /:~ m #. y$"1(<:m)}.(,|."1)2 comb m }}
und10=: 10 undul
und10=: 10 undul
und7=: 7 undul
und7=: 7 undul


fmt7=: 7{{' '-.~":m&#.inv y}}</syntaxhighlight>
fmt7=: 7{{' '-.~":m&#.inv y}}</syntaxhighlight>

We get:


<syntaxhighlight lang=J> 9 9$und10 3
<syntaxhighlight lang=J> 9 9$und10 3
121 131 141 151 161 171 181 191 232
101 121 131 141 151 161 171 181 191
242 252 262 272 282 292 343 353 363
202 212 232 242 252 262 272 282 292
373 383 393 454 464 474 484 494 565
303 313 323 343 353 363 373 383 393
575 585 595 676 686 696 787 797 898
404 414 424 434 454 464 474 484 494
101 202 303 404 505 606 707 808 909
505 515 525 535 545 565 575 585 595
212 313 414 515 616 717 818 919 323
606 616 626 636 646 656 676 686 696
424 525 626 727 828 929 434 535 636
707 717 727 737 747 757 767 787 797
737 838 939 545 646 747 848 949 656
808 818 828 838 848 858 868 878 898
757 858 959 767 868 969 878 979 989
909 919 929 939 949 959 969 979 989
9 9$und10 4
9 9$und10 4
1212 1313 1414 1515 1616 1717 1818 1919 2323
1010 1212 1313 1414 1515 1616 1717 1818 1919
2424 2525 2626 2727 2828 2929 3434 3535 3636
2020 2121 2323 2424 2525 2626 2727 2828 2929
3030 3131 3232 3434 3535 3636 3737 3838 3939
3737 3838 3939 4545 4646 4747 4848 4949 5656
4040 4141 4242 4343 4545 4646 4747 4848 4949
5757 5858 5959 6767 6868 6969 7878 7979 8989
5050 5151 5252 5353 5454 5656 5757 5858 5959
1010 2020 3030 4040 5050 6060 7070 8080 9090
6060 6161 6262 6363 6464 6565 6767 6868 6969
2121 3131 4141 5151 6161 7171 8181 9191 3232
4242 5252 6262 7272 8282 9292 4343 5353 6363
7070 7171 7272 7373 7474 7575 7676 7878 7979
8080 8181 8282 8383 8484 8585 8686 8787 8989
7373 8383 9393 5454 6464 7474 8484 9494 6565
7575 8585 9595 7676 8686 9696 8787 9797 9898
9090 9191 9292 9393 9494 9595 9696 9797 9898
(#~ 1 p:])und10 3
(#~ 1 p:])und10 3
131 151 181 191 353 373 383 787 797 101 313 919 727 929 757
101 131 151 181 191 313 353 373 383 727 757 787 797 919 929
(<:600){/:~;und10&.>3+i.>.600%81
(<:600){;und10&.>3+i.>.600%81
4646464646
4646464646
(#,{:)/:~(#~ (2^53)>:]);und10&.>3+i.>.10^.2^53
(#,{:)(#~ (2^53)>:]);und10&.>3+i.>.10^.2^53
1125 8989898989898989
1125 8989898989898989
6 7$ und7 3
6 7$ und7 3
64 71 78 85 92 121 128
50 64 71 78 85 92 100
135 142 178 185 192 235 242
107 121 128 135 142 150 157
292 50 100 150 200 250 300
164 178 185 192 200 207 214
107 157 207 257 307 164 214
221 235 242 250 257 264 271
264 314 221 271 321 278 328
278 292 300 307 314 321 328
335 64 71 78 85 92 121
335 50 64 71 78 85 92
6 7$ und7 4
6 7$ und7 4
450 500 550 600 650 850 900
350 450 500 550 600 650 700
750 850 900 950 1000 1050 1100
950 1000 1250 1300 1350 1650 1700
2050 350 700 1050 1400 1750 2100
1150 1250 1300 1350 1400 1450 1500
1550 1650 1700 1750 1800 1850 1900
750 1100 1450 1800 2150 1150 1500
1850 2200 1550 1900 2250 1950 2300
1950 2050 2100 2150 2200 2250 2300
2350 450 500 550 600 650 850
2350 350 450 500 550 600 650
(#~ 1 p:])und7 3
(#~ 1 p:])und7 3
71 107 157 257 307 271
71 107 157 257 271 307
fmt7(<:600){/:~;und7&.>3+i.>.600%36
fmt7(<:600){;und7&.>3+i.>.600%36
4646464646464646464
4646464646464646464
(#,&":' ',fmt7@{:)/:~(#~ (2^53)>:]);und7&.>3+i.>.7^.2^53
(#,&":' ',fmt7@{:)(#~ (2^53)>:]);und7&.>3+i.>.7^.2^53
603 5252525252525252525</syntaxhighlight>
603 5252525252525252525</syntaxhighlight>