No Idea!

  • + 1 comment

    Awesome solution, but you don't really need to sum list.

    It is enough to sum generator expression which may be defined with no parentheses in this context:

    print sum( (i in A) - (i in B) for i in sc_ar ) (don't mind whitespaces inside of sum() )

    It leads to little economy of time because we don't waste it on creating list and storing it at some temporary place and only then summing elements of it.

    Instead, we calculate each element on-the-fly, only when we need it