Quote:
this is a hard problem
Not really, when you think about it.
Start by doing it manually, on a piece of paper and make a note of what you do at each step.
Then do it again, following only the notes you made last time. If they don't work, change them and try again.
When you have the notes correctly generating your sequence successfully, you can start translating that into code, and it should be pretty trivial.
But I'd start by re-reading your assignment to check exactly what the rules are for "this sequence is not allowed" because your current ones are too vague:
1 1 1 1 1 1 ==> ok
1 1 1 1 1 2 ==> ok
1 1 1 1 1 3 ==> not ok because if I replace 3 by 2 I get an existed series (1 1 1 1 1 2)
Why is 1 1 1 1 1 2 allowed, when if I replace 2 by 1 I get an existing series?