Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from collections import Counter
  2. from math import sqrt
  3.  
  4.  
  5. def is_prime(n):
  6.     if n == 2:
  7.         return True
  8.     elif n < 2 or n % 2 == 0:
  9.         return False
  10.  
  11.     k = 3
  12.     while k <= int(sqrt(n)):
  13.         if n % k == 0:
  14.             return False
  15.         k += 2
  16.     return True
  17.  
  18.  
  19. def fun(A, B):
  20.     counter = Counter()
  21.     for b in B:
  22.         counter[b] += 1
  23.     C = []
  24.     for a in A:
  25.         # if a was not in B counter[a]=0
  26.         if not is_prime(counter[a]):
  27.             C.append(a)
  28.     return C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement