From a48d0c4e3945fd91fd64f5ede613e2e8d82df2df Mon Sep 17 00:00:00 2001 From: beeniii Date: Sun, 21 Jun 2026 21:52:46 +0900 Subject: [PATCH 01/18] =?UTF-8?q?[PGS]=20=EB=8B=AC=EB=A6=AC=EA=B8=B0=20?= =?UTF-8?q?=EA=B2=BD=EC=A3=BC]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" diff --git "a/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" "b/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" new file mode 100644 index 0000000..e69de29 From f477a210e92f2380b58c7d85d4f93a64d707c197 Mon Sep 17 00:00:00 2001 From: beeniii Date: Sun, 21 Jun 2026 21:53:39 +0900 Subject: [PATCH 02/18] =?UTF-8?q?[PGS]=20=EB=8B=AC=EB=A6=AC=EA=B8=B0=20?= =?UTF-8?q?=EA=B2=BD=EC=A3=BC]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...46\254\352\270\260_\352\262\275\354\243\274.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git "a/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" "b/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" index e69de29..1b5b419 100644 --- "a/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" +++ "b/Programmers/Been/Week1/\353\213\254\353\246\254\352\270\260_\352\262\275\354\243\274.py" @@ -0,0 +1,14 @@ +def solution(players, callings): + rank = {name: i for i, name in enumerate(players)} + order = players[:] + + for name in callings: + idx = rank[name] + prev_idx = idx - 1 + prev_name = order[prev_idx] + + order[idx], order[prev_idx] = order[prev_idx], order[idx] + rank[name] = prev_idx + rank[prev_name] = idx + + return order \ No newline at end of file From 3f3df060b573dee476eec28e5e998e391f425272 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 19:28:10 +0900 Subject: [PATCH 03/18] =?UTF-8?q?[PGS]=20=EC=B5=9C=EB=8C=93=EA=B0=92?= =?UTF-8?q?=EA=B3=BC=20=EC=B5=9C=EC=86=9F=EA=B0=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...222\352\263\274_\354\265\234\354\206\237\352\260\222.py" | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 "Programmers/Been/Week2/\354\265\234\353\214\223\352\260\222\352\263\274_\354\265\234\354\206\237\352\260\222.py" diff --git "a/Programmers/Been/Week2/\354\265\234\353\214\223\352\260\222\352\263\274_\354\265\234\354\206\237\352\260\222.py" "b/Programmers/Been/Week2/\354\265\234\353\214\223\352\260\222\352\263\274_\354\265\234\354\206\237\352\260\222.py" new file mode 100644 index 0000000..ab1e888 --- /dev/null +++ "b/Programmers/Been/Week2/\354\265\234\353\214\223\352\260\222\352\263\274_\354\265\234\354\206\237\352\260\222.py" @@ -0,0 +1,6 @@ +def solution(s): + answer = s.split(" ") + result = list(map(int, answer)) + min_val = min(result) + max_val = max(result) + return f"{min_val} {max_val}" \ No newline at end of file From e618201721d506993ccd3859c87e244c3dddca60 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 19:35:35 +0900 Subject: [PATCH 04/18] =?UTF-8?q?[PGS]=20=EC=88=AB=EC=9E=90=20=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=EC=97=B4=EA=B3=BC=20=EC=98=81=EB=8B=A8=EC=96=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4_\354\230\201\353\213\250\354\226\264.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "Programmers/Been/Week2/\354\210\253\354\236\220_\353\254\270\354\236\220\354\227\264\352\263\274_\354\230\201\353\213\250\354\226\264.py" diff --git "a/Programmers/Been/Week2/\354\210\253\354\236\220_\353\254\270\354\236\220\354\227\264\352\263\274_\354\230\201\353\213\250\354\226\264.py" "b/Programmers/Been/Week2/\354\210\253\354\236\220_\353\254\270\354\236\220\354\227\264\352\263\274_\354\230\201\353\213\250\354\226\264.py" new file mode 100644 index 0000000..47e2350 --- /dev/null +++ "b/Programmers/Been/Week2/\354\210\253\354\236\220_\353\254\270\354\236\220\354\227\264\352\263\274_\354\230\201\353\213\250\354\226\264.py" @@ -0,0 +1,19 @@ +def solution(s): + word_to_num = { + "zero": "0", "one": "1", "two": "2", "three": "3", "four": "4", + "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9" + } + answer = '' + i = 0 + while i < len(s): + if s[i].isdigit(): + answer += s[i] + i += 1 + else: + for k,v in word_to_num.items(): + if s[i: i+len(k)] == k: + answer += v + i += len(k) + pass + + return int(answer) \ No newline at end of file From 7b564b8274c44b40e35f39d92ffeeaa7cf73562b Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 19:45:47 +0900 Subject: [PATCH 05/18] =?UTF-8?q?[PGS]=20=EC=98=81=EC=96=B4=20=EB=81=9D?= =?UTF-8?q?=EB=A7=90=EC=9E=87=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\201\235\353\247\220\354\236\207\352\270\260.py" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "Programmers/Been/Week2/\354\230\201\354\226\264_\353\201\235\353\247\220\354\236\207\352\270\260.py" diff --git "a/Programmers/Been/Week2/\354\230\201\354\226\264_\353\201\235\353\247\220\354\236\207\352\270\260.py" "b/Programmers/Been/Week2/\354\230\201\354\226\264_\353\201\235\353\247\220\354\236\207\352\270\260.py" new file mode 100644 index 0000000..57c3c2b --- /dev/null +++ "b/Programmers/Been/Week2/\354\230\201\354\226\264_\353\201\235\353\247\220\354\236\207\352\270\260.py" @@ -0,0 +1,12 @@ +def solution(n, words): + answer = [] + for i in range(len(words)): + if answer == []: + answer.append(words[i]) + elif answer != [] and words[i-1][-1] == words[i][0] and words[i] not in answer: + answer.append(words[i]) + else: + return [i % n + 1, i // n + 1] + + + return [0,0] \ No newline at end of file From 90a9105a6b23f0b9af0c91015a3094add6d64bd1 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 19:51:40 +0900 Subject: [PATCH 06/18] =?UTF-8?q?[PGS]=20=EB=AA=A8=EC=9D=98=EA=B3=A0?= =?UTF-8?q?=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...250\354\235\230\352\263\240\354\202\254.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "Programmers/Been/Week2/\353\252\250\354\235\230\352\263\240\354\202\254.py" diff --git "a/Programmers/Been/Week2/\353\252\250\354\235\230\352\263\240\354\202\254.py" "b/Programmers/Been/Week2/\353\252\250\354\235\230\352\263\240\354\202\254.py" new file mode 100644 index 0000000..1209714 --- /dev/null +++ "b/Programmers/Been/Week2/\353\252\250\354\235\230\352\263\240\354\202\254.py" @@ -0,0 +1,18 @@ +def solution(answers): + answer = [] + patterns = [ + [1,2,3,4,5], + [2,1,2,3,2,4,2,5], + [3,3,1,1,2,2,4,4,5,5] + ] + counts = [0, 0, 0] + + for i in range(len(answers)): + for j in range(3): + if answers[i] == patterns[j][i % len(patterns[j])]: + counts[j] += 1 + + max_count = max(counts) + answer = [i+1 for i in range(3) if counts[i] == max_count] + + return answer \ No newline at end of file From 89cbd6f2908617f86eafe7e9f0e7b923ed647d9a Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 20:05:07 +0900 Subject: [PATCH 07/18] =?UTF-8?q?[PGS]=20=EC=BD=9C=EB=9D=BC=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\275\234\353\235\274_\353\254\270\354\240\234.py" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "Programmers/Been/Week2/\354\275\234\353\235\274_\353\254\270\354\240\234.py" diff --git "a/Programmers/Been/Week2/\354\275\234\353\235\274_\353\254\270\354\240\234.py" "b/Programmers/Been/Week2/\354\275\234\353\235\274_\353\254\270\354\240\234.py" new file mode 100644 index 0000000..aecc1cc --- /dev/null +++ "b/Programmers/Been/Week2/\354\275\234\353\235\274_\353\254\270\354\240\234.py" @@ -0,0 +1,10 @@ +def solution(a, b, n): + answer = 0 + num = n + while num >= a: + time = num // a + num_cola = time * b + answer += num_cola + num = num % a + num_cola + + return answer \ No newline at end of file From 53a390204b1d4ca1e709ff97e2bfd78994308ca5 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 20:16:18 +0900 Subject: [PATCH 08/18] =?UTF-8?q?[PGS]=20=EC=BD=9C=EB=9D=BC=EC=B8=A0=20?= =?UTF-8?q?=EC=B6=94=EC=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\274\354\270\240_\354\266\224\354\270\241.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "Programmers/Been/Week2/\354\275\234\353\235\274\354\270\240_\354\266\224\354\270\241.py" diff --git "a/Programmers/Been/Week2/\354\275\234\353\235\274\354\270\240_\354\266\224\354\270\241.py" "b/Programmers/Been/Week2/\354\275\234\353\235\274\354\270\240_\354\266\224\354\270\241.py" new file mode 100644 index 0000000..d68228f --- /dev/null +++ "b/Programmers/Been/Week2/\354\275\234\353\235\274\354\270\240_\354\266\224\354\270\241.py" @@ -0,0 +1,15 @@ +def solution(num): + answer = 0 + if num == 1: + return 0 + while num != 1 and answer < 500: + if num % 2 == 0: + num = num // 2 + answer += 1 + elif num % 2 != 0: + num = num * 3 + 1 + answer += 1 + if answer == 500: + return -1 + return answer + \ No newline at end of file From 2372f2ebe34701cbf55209e939b849af99fce177 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 29 Jun 2026 20:18:30 +0900 Subject: [PATCH 09/18] =?UTF-8?q?[PGS]=20=ED=8F=B0=EC=BC=93=EB=AA=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Been/Week2/\355\217\260\354\274\223\353\252\254.py" | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 "Programmers/Been/Week2/\355\217\260\354\274\223\353\252\254.py" diff --git "a/Programmers/Been/Week2/\355\217\260\354\274\223\353\252\254.py" "b/Programmers/Been/Week2/\355\217\260\354\274\223\353\252\254.py" new file mode 100644 index 0000000..a8275bc --- /dev/null +++ "b/Programmers/Been/Week2/\355\217\260\354\274\223\353\252\254.py" @@ -0,0 +1,4 @@ +from collections import Counter +def solution(nums): + answer = Counter(nums) + return min(len(Counter(nums)), len(nums) // 2) \ No newline at end of file From b59300a3764b27abac90c46cf48954677f772b42 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 6 Jul 2026 22:27:06 +0900 Subject: [PATCH 10/18] =?UTF-8?q?[PGS]=20=EB=95=85=EB=94=B0=EB=A8=B9?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\353\225\205\353\224\260\353\250\271\352\270\260.py" | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 "Programmers/Been/Week3/\353\225\205\353\224\260\353\250\271\352\270\260.py" diff --git "a/Programmers/Been/Week3/\353\225\205\353\224\260\353\250\271\352\270\260.py" "b/Programmers/Been/Week3/\353\225\205\353\224\260\353\250\271\352\270\260.py" new file mode 100644 index 0000000..35cefbe --- /dev/null +++ "b/Programmers/Been/Week3/\353\225\205\353\224\260\353\250\271\352\270\260.py" @@ -0,0 +1,6 @@ +def solution(land): + for i in range(1, len(land)): + for j in range(4): + land[i][j] += max(land[i-1][:j] +land[i-1][j+1:]) + + return max(land[-1]) \ No newline at end of file From 7e3cdf2f758f9042691b64e99121e777c2de800d Mon Sep 17 00:00:00 2001 From: beeniii Date: Wed, 8 Jul 2026 09:08:53 +0900 Subject: [PATCH 11/18] =?UTF-8?q?[PGS]=20=EC=98=B9=EC=95=8C=EC=9D=B4=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\230\271\354\225\214\354\235\264(2).py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "Programmers/Been/Week3/\354\230\271\354\225\214\354\235\264(2).py" diff --git "a/Programmers/Been/Week3/\354\230\271\354\225\214\354\235\264(2).py" "b/Programmers/Been/Week3/\354\230\271\354\225\214\354\235\264(2).py" new file mode 100644 index 0000000..6b9ad61 --- /dev/null +++ "b/Programmers/Been/Week3/\354\230\271\354\225\214\354\235\264(2).py" @@ -0,0 +1,14 @@ +from itertools import groupby + +def solution(babbling): + words = ["aya", "ye", "woo", "ma"] + answer = 0 + + for word in babbling: + for wd in words: + word = word.replace(wd, wd + " ") + parts = word.split() + if all(p in words for p in parts) and len(parts) == len(list(groupby(parts))): + answer += 1 + + return answer \ No newline at end of file From f3b96fb457a19868e4576ca3888e548a6d3041ad Mon Sep 17 00:00:00 2001 From: beeniii Date: Thu, 9 Jul 2026 11:03:50 +0900 Subject: [PATCH 12/18] =?UTF-8?q?[PGS]=20=EC=98=88=EC=83=81=EB=8C=80?= =?UTF-8?q?=EC=A7=84=ED=91=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...210\354\203\201\353\214\200\354\247\204\355\221\234.py" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "Programmers/Been/Week3/\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.py" diff --git "a/Programmers/Been/Week3/\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.py" "b/Programmers/Been/Week3/\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.py" new file mode 100644 index 0000000..95e0ab1 --- /dev/null +++ "b/Programmers/Been/Week3/\354\230\210\354\203\201\353\214\200\354\247\204\355\221\234.py" @@ -0,0 +1,7 @@ +def solution(n, a, b): + answer = 0 + while a != b: + a = (a + 1) // 2 + b = (b + 1) // 2 + answer += 1 + return answer \ No newline at end of file From 47f43d9a8f619864fdba918ee0598bc6292faaf9 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 21:34:47 +0900 Subject: [PATCH 13/18] =?UTF-8?q?[PGS]=20=EC=8B=A4=ED=8C=A8=EC=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/fail_rate.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Programmers/Been/Week4/fail_rate.py diff --git a/Programmers/Been/Week4/fail_rate.py b/Programmers/Been/Week4/fail_rate.py new file mode 100644 index 0000000..108b363 --- /dev/null +++ b/Programmers/Been/Week4/fail_rate.py @@ -0,0 +1,15 @@ +from collections import Counter +def solution(N, stages): + counter = Counter(stages) + total = len(stages) + fail_rate = {} + + for stage in range(1, N+1): + if total == 0: + fail_rate[stage] = 0 + else: + fail_rate[stage] = counter[stage] / total + total -= counter[stage] + + return sorted(fail_rate, key=lambda x: fail_rate[x], reverse=True) + \ No newline at end of file From 328eb179f8a14e2bf24980802642627ab8a5a614 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 21:52:25 +0900 Subject: [PATCH 14/18] =?UTF-8?q?[PGS]=20=EB=AC=B8=EC=9E=90=EC=97=B4=20?= =?UTF-8?q?=EB=82=98=EB=88=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/split_string.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Programmers/Been/Week4/split_string.py diff --git a/Programmers/Been/Week4/split_string.py b/Programmers/Been/Week4/split_string.py new file mode 100644 index 0000000..53eee71 --- /dev/null +++ b/Programmers/Been/Week4/split_string.py @@ -0,0 +1,16 @@ +def solution(s): + answer = 0 + cnt = 0 + std = 0 + + for i in s: + if cnt == 0: + std = i + answer += 1 + + if i == std: + cnt += 1 + else: + cnt -= 1 + + return answer \ No newline at end of file From 4470c6db2e0f0d940866d5633c9462986dcdbf23 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 21:55:10 +0900 Subject: [PATCH 15/18] =?UTF-8?q?[PGS]=20=EC=86=8C=EC=88=98=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/make_prime.Py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Programmers/Been/Week4/make_prime.Py diff --git a/Programmers/Been/Week4/make_prime.Py b/Programmers/Been/Week4/make_prime.Py new file mode 100644 index 0000000..27c75f0 --- /dev/null +++ b/Programmers/Been/Week4/make_prime.Py @@ -0,0 +1,18 @@ +from itertools import combinations + +def solution(nums): + answer = 0 + + def is_prime(n): + if n < 2: + return False + for i in range(2, int(n ** 0.5) + 1): + if n % i == 0: + return False + return True + + for combo in combinations(nums, 3): + if is_prime(sum(combo)): + answer += 1 + + return answer \ No newline at end of file From e11b5553f56001bbc5646a65f5d0f5b471d65ab0 Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 22:01:35 +0900 Subject: [PATCH 16/18] =?UTF-8?q?[PGS]=20=EC=98=AC=EB=B0=94=EB=A5=B8=20?= =?UTF-8?q?=EA=B4=84=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/valid_parentheses.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Programmers/Been/Week4/valid_parentheses.py diff --git a/Programmers/Been/Week4/valid_parentheses.py b/Programmers/Been/Week4/valid_parentheses.py new file mode 100644 index 0000000..813d345 --- /dev/null +++ b/Programmers/Been/Week4/valid_parentheses.py @@ -0,0 +1,10 @@ +def solution(s): + stack = [] + for c in s: + if not stack: + stack.append(c) + elif stack[-1] == '(' and c == ')': + stack.pop() + else: + stack.append(c) + return not stack \ No newline at end of file From 7926eb52cf86d2731da942c5b20eb56b725051fe Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 22:07:59 +0900 Subject: [PATCH 17/18] =?UTF-8?q?[PGS]=20=EB=91=98=EB=A7=8C=EC=9D=98=20?= =?UTF-8?q?=EC=95=94=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/only_two_cipher.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Programmers/Been/Week4/only_two_cipher.py diff --git a/Programmers/Been/Week4/only_two_cipher.py b/Programmers/Been/Week4/only_two_cipher.py new file mode 100644 index 0000000..78063a8 --- /dev/null +++ b/Programmers/Been/Week4/only_two_cipher.py @@ -0,0 +1,14 @@ +def solution(s, skip, index): + answer = '' + for i in s: + value = ord(i) + moved = 0 + while moved < index: + value += 1 + if value > ord('z'): + value = ord('a') + if chr(value) not in skip: + moved += 1 + answer += chr(value) + + return answer \ No newline at end of file From 3079d5d69e41e6321acb48d53b9b6db8b47546de Mon Sep 17 00:00:00 2001 From: beeniii Date: Mon, 13 Jul 2026 22:14:15 +0900 Subject: [PATCH 18/18] =?UTF-8?q?[PGS]=20=EC=9D=B4=EC=9B=83=ED=95=9C=20?= =?UTF-8?q?=EC=B9=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Programmers/Been/Week4/adjacent_cells.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Programmers/Been/Week4/adjacent_cells.py diff --git a/Programmers/Been/Week4/adjacent_cells.py b/Programmers/Been/Week4/adjacent_cells.py new file mode 100644 index 0000000..e32bb2d --- /dev/null +++ b/Programmers/Been/Week4/adjacent_cells.py @@ -0,0 +1,14 @@ +def solution(board, h, w): + count = 0 + len_board = len(board) + dx = [0, 1, 0, -1] + dy = [1, 0, -1, 0] + for i in range(4): + h_check = h + dx[i] + w_check = w + dy[i] + if 0 <= h_check < len_board and 0 <= w_check < len_board: + if board[h][w] == board[h_check][w_check]: + count += 1 + + + return count \ No newline at end of file