From 4811e8362e0d356f3abf51b06d952148b2b68c63 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 12 Sep 2022 09:59:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20'd?= =?UTF-8?q?ef/count-tests.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- def/count-tests.py | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 def/count-tests.py diff --git a/def/count-tests.py b/def/count-tests.py deleted file mode 100644 index 45f9b91..0000000 --- a/def/count-tests.py +++ /dev/null @@ -1,23 +0,0 @@ -##################################### Первый способ: - -A = [10, 10, 23, 10, 123, 66, 78, 123] -counter = {} - -for elem in A: - counter[elem] = counter.get(elem, 0) + 1 - -doubles = {element: count for element, count in counter.items() if count > 1} - -print(doubles) - -##################################### Второй способ: - -from collections import Counter -counter = Counter(A) - -##################################### Третий способ: - -from collections import defaultdict -counter = defaultdict(int) -for elem in A: - counter[elem] += 1