Special String Again

  • + 0 comments

    The triangular number sequence is simple:

    (sequence number) -> (value)

    t0 -> 0

    t1 -> 1

    t2 -> 3

    t3 -> 6

    t4 -> 10

    ...

    The result of next value is the sum of previous sequence number (t+1) plus previous value.

    There are many applications using this sequence. You can see more about here: https://en.wikipedia.org/wiki/Triangular_number

    In this problem it's possible to find the number of repeated char combinations throught triangular number sequence. Here an example:

    t0 -> a -> 0

    t1 -> aa -> 1

    t2 -> aaa -> 3

    t3 -> aaaa -> 6

    t4 -> aaaaa -> 10

    ...

    It's the same sequence, but you'll need to use len()-1.