[Community Puzzle] Number Partition

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Jsw7524,validated by @_vcxl,@Neckers and @texus.
If you have any issues, feel free to ping them.

Wiki defines lexicographical order as lexical order, or dictionary order, which is a generalization of the alphabetical order

According to this definition and the reverse sort requirement in the problem,
if string1 is “10” and string2 is “2 2”
they should be sorted as:

2 2
10

because ‘2’ precedes ‘1’.

Correct?

1 Like

Thanks for your thoughtful question!

There are likely better alternative words to represent the desired order in the question instead of reverse lexicographic order.

For the sake of rigor, n temporarily restricts to less than 10 for now. It is welcome for anyone to submit a better statement that can accurately represent required order in the question.

hi. i get this arror message

Validators

The following validators differ from the puzzle test cases to prevent hard coded solutions. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.

[Mod edit: Please avoid posting codes on the forum]

The message is just a generic reminder of two things:

  1. It’s not sufficient to pass the tests. Your code may still contain bugs so you do not pass the validators, which are different from tests.
  2. You cannot pass the validators with a hardcoding code.

In addition, please avoid posting your code on the forum. Try describing your approach instead next time.

Now back to your issue: your code doesn’t handle any of the validators correctly. You need to correct your code so that it handles input of 1, 6, 7, 8 and 9 properly (four of those numbers are inputs to the validators…).

ok, what is the issue with this output for 6
6
5 1
4 2
4 1 1
3 2 1
3 1 1 1
2 2 1 1
2 1 1 1 1
1 1 1 1 1 1

The correct answer should be:

6
5 1
4 2
4 1 1
3 3          <- this is missing
3 2 1
3 1 1 1
2 2 2        <- this is missing
2 2 1 1
2 1 1 1 1
1 1 1 1 1 1