From 4738a5d07df8c4a2e6d72567a424b81dab20ac34 Mon Sep 17 00:00:00 2001 From: Yoonseo Kim Date: Tue, 28 Dec 2021 23:20:01 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=B4=EC=9C=A1=EB=B3=B5=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\262\264\354\234\241\353\263\265.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "Algorithm/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/\354\262\264\354\234\241\353\263\265.py" diff --git "a/Algorithm/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/\354\262\264\354\234\241\353\263\265.py" "b/Algorithm/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/\354\262\264\354\234\241\353\263\265.py" new file mode 100644 index 0000000..2ab863d --- /dev/null +++ "b/Algorithm/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244/\354\262\264\354\234\241\353\263\265.py" @@ -0,0 +1,19 @@ +n = 6 +lost = [2, 4] +reserve = [1, 3, 5] + +set_lost = set(lost) - set(reserve) +set_reserve = set(reserve) - set(lost) + +for i in set_reserve: + if i - 1 in set_lost: + set_lost.remove(i-1) + continue + + if i + 1 in set_lost: + set_lost.remove(i+1) + continue + +answer = n - len(set_lost) + +print(answer)