• xsevensinzx - Friday, June 8, 2018 5:31 AM


    def array_query(s, t, i, j):
    if t == 1:
    s[:0] = s[i-1:j]
    del(s[i+(j-i):j+(j-i+1)])
    elif t == 2:
    s += s[i-1:j]
    del(s[i-1:j])

    return s

    Code like this would need comments for sure. But why not change the names of things instead so that it is more obvious what is going on? i.e. rename "array_query" to "shift_sub_array", rename 's' to "query_string", make t an enum so you know what 1 and 2 mean, etc.