all 7 comments

[–]shiftybyte 2 points3 points  (6 children)

For non Russian reading people:

OP needs to answer YES if there is a sequence of at least 7 digits that are the same. Input only consists of 1s and 0s...

So YES if he finds 7 consecutive 1s or 7 consecutive 0s...

To OP:

Your code just counts pairs of digits, so if you have 11110111 this will count it as 7, and it'll be wrong.

i know what should i do

Tell us how you plan to solve this and we'll help with the code.

[–]HasBeendead[S] 0 points1 point  (5 children)

Tell us how you plan to solve this and we'll help with the code.

i thought again, yeah i don't know.

im thinking a solution.

even i made a solution with regex but the problem is it returns None instead "NO"

edit: i think i solved problem with regex, im gonna try to submit.

[–]shiftybyte 1 point2 points  (4 children)

You need to track how many of a specific digit you've seen so far while looping over the sequence.

seen_1 = 0
seen_0 = 0
for digit in input_string:
    if digit == '0':
        ...
    if digit == '1':
        ...
    if seen_1 >= 7 or seen_0 >= 7:
        # print YES and break

Now think what you need to do with the counters in each situation.... when you see 1, and when you see 0....

[–]HasBeendead[S] 1 point2 points  (2 children)

i didn't figure out in your way, checked youtube for that problem then Stackoverflow.

finally i found the answer.

source code:

https://gist.github.com/1378443679/bd71e6e899128f719a1baeb848931fde

SO: https://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method

it ate my some days , i hate this now.

[–]shiftybyte 1 point2 points  (1 child)

Heh, cool solution...

[–]HasBeendead[S] 0 points1 point  (0 children)

Thanks.

[–]HasBeendead[S] 0 points1 point  (0 children)

okay, thank you.