[Community Puzzle] 1D Snake Arrange - Puzzle discussion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @pluieciel,validated by @Rafarafa,@cedricdd and @DavidAugustoVilla.
If you have any issues, feel free to ping them.

Hi,

Could you please explain the third case of Test 1?

Input: ?###???????? 3,2,1
Expected output: 10

So there should exist only 10 possible arrangements. However, I count 20 possible arrangements:

.###.##.#...
.###.##..#..
.###.##...#.
.###.##....#
.###..##.#..
.###..##..#.
.###..##...#
.###.#.##...
.###...##.#.
.###...##..#
.###.#..##..
.###..#.##..
.###....##.#
.###.#...##.
.###..#..##.
.###...#.##.
.###.#....##
.###..#...##
.###...#..##
.###....#.##

The order is relevant: (3, 1, 2) != (3, 2, 1)

.###.#.##... <- Not valid

The 10 valid ones are:

.###.##.#...
.###.##..#..
.###.##...#.
.###.##....#
.###..##.#..
.###..##..#.
.###..##...#
.###...##.#.
.###...##..#
.###....##.#
1 Like

Thanks! That actually made the code simpler!