?- nsol(2, L, C).
L = [[2], [1, 1]],
C = 2.
?- nsol(4, L, C).
L = [[2, 2], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 1, 1, 1]],
C = 5.
?- nsol(5, L, C).
L = [[1, 2, 2], [2, 1, 2], [2, 2, 1], [1, 1, 1, 2], [1, 1, 2, 1], [1, 2, 1|...], [2, 1|...], [1|...]],
C = 8.
?- nsol(10, L, C).
L = [[2, 2, 2, 2, 2], [1, 1, 2, 2, 2, 2], [1, 2, 1, 2, 2, 2], [1, 2, 2, 1, 2|...], [1, 2, 2, 2|...], [1, 2, 2|...], [2, 1|...], [2|...], [...|...]|...],
C = 89.
Perhaps there are more optimal implementations, but I figure it out quickly by using some library predicates.
Best Regards,