« first day (2414 days earlier)      last day (2550 days later) » 
05:00 - 21:0021:00 - 00:00

9:00 PM
going to visit some family
And now, going-to-dig-in-the-yard rhubarb
 
I am getting timeout with my code, any idea why? - I think I have optimized quite well.

s = [int(x) for x in input()]
k, b, m = (int(x) for x in input().split() )

result = 0
for i in range(k-1, len(s)):

    substring = ()
    for n in range(i, i-k, -1):
        substring += (s[n],)

    result += sum(substring[i] * b**i for i in range(k)) % m

print(result)
I think that the issue might lay in the creation of the substring, being very insufficient.
 
your "strings" are lists and tuples
 
Yeah, that's just bad naming :P
I think this could be optimized:

    substring = ()
    for n in range(2, 2-3, -1):     # I put the numbers in to make it clearer
        substring += (s[n],)
It's basically going to create a long tuple (s[5], s[4], s[3] and so on...)
depending on the giving k value
It's just insufficient in the way that it makes a tuple, adds a new tuple to it again and again... k times
 
9:20 PM
if only there was a list comprehension to do it all at once
 
or even slices
 
I don't believe it's possible to do it in a list comprehension
 
life's hard
 
It's basically equivalent to substring = tuple(s[i:i-k:-1]) ah no
 
[s[n] for n in range(2, 2-3, -1)]
hehe
 
9:24 PM
anyway, that list comprehension is correct
It's slightly odd that the behaviour of range is different in case of negative arguments
 
Anyway, it didn't make any different on the point board.
Still the same amount of timeouts
s = [int(x) for x in input()]
k, b, m = (int(x) for x in input().split() )

result = 0
for i in range(k-1, len(s)):

    substring = tuple(s[n] for n in range(i, i-k, -1))
    result += sum(substring[i] * b**i for i in range(k)) % m

print(result)
 
just wondering, what does everyone here think of this? gist.github.com/BytesAndCoffee/48935c1db28c8e8d901c9b60b9d42332
 
I think it's a github gist
 
har har har
this is what the served page looks like, i.imgur.com/VjeMbqu.png
 
 
2 hours later…
11:24 PM
yo is anybody on
 
05:00 - 21:0021:00 - 00:00

« first day (2414 days earlier)      last day (2550 days later) »