Here’s my math/logic for n=3 that expands to a general case simply in my mind (if it doesn’t I can work on a more formal proof)
Given:
a<=b<=c
a==b OR b==c
Therefore:
distinct(a,b,c) must be equal to (a,c) OR (a)
aba is never a legal pattern
Explanation of the second therefore: By looking at a 4 digit number that is abca we see that since this implies c<=a<=b that this isn’t a legal string. We can also insert any number of digits (that follow the rules) between b and c and the contradiction with given #1 still occurs.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Where in
part1()
are you checking that 2 adjacent digits are the same?Here’s my math/logic for n=3 that expands to a general case simply in my mind (if it doesn’t I can work on a more formal proof)
Given:
a<=b<=c
a==b
ORb==c
Therefore:
distinct(a,b,c)
must be equal to(a,c)
OR(a)
aba
is never a legal patternExplanation of the second therefore: By looking at a 4 digit number that is
abca
we see that since this impliesc<=a<=b
that this isn’t a legal string. We can also insert any number of digits (that follow the rules) betweenb
andc
and the contradiction with given #1 still occurs.