diff --git a/README.md b/README.md index bf0c375..d09ff9a 100644 --- a/README.md +++ b/README.md @@ -114,3 +114,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM ### re-id * Completed in: 10 mins, 19 secs. + +### minion-work-assignments +* Completed in: 7 mins, 40 secs. diff --git a/extra/minion-work-assignments/solution.py b/extra/minion-work-assignments/solution.py new file mode 100644 index 0000000..45d4ca9 --- /dev/null +++ b/extra/minion-work-assignments/solution.py @@ -0,0 +1,18 @@ +def solution(data, n): + memo = {} + for i in data: + if i not in memo: + memo[i] = 1 + else: + memo[i] += 1 + + return [d for d in data if memo[d] <= n] + +tests = [ + ([[1, 2, 3], 0], []), + ([[1, 2, 2, 3, 3, 3, 4, 5, 5], 1], [1, 4]), + ] + +for i, o in tests: + result = solution(*i) + print (i, result == o, result, o)