We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defread_line():"""Read a line of integers from STDIN."""returnmap(int,input().split())input()array=read_line()a,b={*read_line()},{*read_line()}print(sum(1ifiinaelse-1ifiinbelse0foriinarray))
Here is a more verbose Python 3 solution using Counter:
fromcollectionsimportCounterinput()defread_input(sequence):"""Read a line of integers from STDIN."""returnsequence(map(int,input().split()))defcreate_happiness_calculator(scores):"""Create a happiness calculator for the given scores."""def_happiness_calculator(subset):"""Calculate the happiness of the given subset."""returnsum(scores[key]forkeyinscores.keys()&subset)return_happiness_calculatorcalculate_happiness=create_happiness_calculator(read_input(Counter))print(calculate_happiness(read_input(set))-calculate_happiness(read_input(set)))
Here is a code-golfed Python 3 solution (107 characters):
No Idea!
You are viewing a single comment's thread. Return to all comments →
Here is a simple Python 3 solution:
Here is a more verbose Python 3 solution using
Counter:Here is a code-golfed Python 3 solution (107 characters):