Back
Close

Sequence with specific digits

Statement

 Goal

Given N, X and a line with X numbers between 0 and 9.

Print all valid numbers between 0 and N inclusive.

A number is valid if all of your digits are in line.

If the sequence is empty, print NONE.
Input
Line 1: Two space separated integers N and X.
Line 2: X space separated integers.
Output
A single line with the sequence.
Constraints
0 ≤ N ≤ 10000
1 ≤ X ≤ 10
The integers in Line 2 are between 0 and 9 inclusive.
Example
Input
20 2
1 2
Output
1 2 11 12

Game modes
FastestShortest

Test cases
Test 1 Test
Input
20 2 1 2
Output
1 2 11 12

Validator 1 Validator
Input
20 2 1 5
Output
1 5 11 15

Test 2 Test
Input
0 10 0 1 2 3 4 5 6 7 8 9
Output
0

Validator 2 Validator
Input
0 4 0 1 2 3
Output
0

Test 3 Test
Input
0 1 1
Output
NONE

Validator 3 Validator
Input
0 1 9
Output
NONE

Test 4 Test
Input
100 3 1 2 7
Output
1 2 7 11 12 17 21 22 27 71 72 77

Validator 4 Validator
Input
100 3 1 2 5
Output
1 2 5 11 12 15 21 22 25 51 52 55

Test 5 Test
Input
1000 2 2 3
Output
2 3 22 23 32 33 222 223 232 233 322 323 332 333

Validator 5 Validator
Input
1000 2 4 7
Output
4 7 44 47 74 77 444 447 474 477 744 747 774 777

Test 6 Test
Input
5 4 6 7 8 9
Output
NONE

Validator 6 Validator
Input
3 6 4 5 6 7 8 9
Output
NONE

Test 7 Test
Input
10000 3 1 2 3
Output
1 2 3 11 12 13 21 22 23 31 32 33 111 112 113 121 122 123 131 132 133 211 212 213 221 222 223 231 232 233 311 312 313 321 322 323 331 332 333 1111 1112 1113 1121 1122 1123 1131 1132 1133 1211 1212 1213 1221 1222 1223 1231 1232 1233 1311 1312 1313 1321 1322 1323 1331 1332 1333 2111 2112 2113 2121 2122 2123 2131 2132 2133 2211 2212 2213 2221 2222 2223 2231 2232 2233 2311 2312 2313 2321 2322 2323 2331 2332 2333 3111 3112 3113 3121 3122 3123 3131 3132 3133 3211 3212 3213 3221 3222 3223 3231 3232 3233 3311 3312 3313 3321 3322 3323 3331 3332 3333

Validator 7 Validator
Input
10000 3 4 5 6
Output
4 5 6 44 45 46 54 55 56 64 65 66 444 445 446 454 455 456 464 465 466 544 545 546 554 555 556 564 565 566 644 645 646 654 655 656 664 665 666 4444 4445 4446 4454 4455 4456 4464 4465 4466 4544 4545 4546 4554 4555 4556 4564 4565 4566 4644 4645 4646 4654 4655 4656 4664 4665 4666 5444 5445 5446 5454 5455 5456 5464 5465 5466 5544 5545 5546 5554 5555 5556 5564 5565 5566 5644 5645 5646 5654 5655 5656 5664 5665 5666 6444 6445 6446 6454 6455 6456 6464 6465 6466 6544 6545 6546 6554 6555 6556 6564 6565 6566 6644 6645 6646 6654 6655 6656 6664 6665 6666

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants