<reponame>citrok25/Codewars-1<gh_stars>10-100
from collections import Counter
from functools import reduce

PAIRS = {'N':'S','S':'N','E':'W','W':'E'}

def directions(goal):
    c=Counter(goal)
    return list(
              reduce(lambda x,y: x+y, 
                 [[d]*(c[d] - c[PAIRS[d]]) for d in 'NSEW']
                    )
               )

from collections import Counter
from functools import reduce

PAIRS = {'N':'S','S':'N','E':'W','W':'E'}

def directions(goal):
    c=Counter(goal)
    return list(
              reduce(lambda x,y: x+y, 
                 [[d]*(c[d] - c[PAIRS[d]]) for d in 'NSEW']
                    )
               )