From a70b3a6316cd2ffcea9a709d37536572969d8cb1 Mon Sep 17 00:00:00 2001 From: iblug <1115jkb@gmail.com> Date: Thu, 6 Jul 2023 19:43:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?week24=5F=EC=A0=95=EA=B4=91=EB=B0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3_\354\240\225\352\264\221\353\260\260.py" | 26 +++++++++++++++++++ ...5_\354\240\225\352\264\221\353\260\260.py" | 15 +++++++++++ ...2_\354\240\225\352\264\221\353\260\260.py" | 15 +++++++++++ 3 files changed, 56 insertions(+) create mode 100644 "week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\354\240\225\352\264\221\353\260\260.py" create mode 100644 "week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\354\240\225\352\264\221\353\260\260.py" create mode 100644 "week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\354\240\225\352\264\221\353\260\260.py" diff --git "a/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\354\240\225\352\264\221\353\260\260.py" "b/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\354\240\225\352\264\221\353\260\260.py" new file mode 100644 index 0000000..6d999bd --- /dev/null +++ "b/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\354\240\225\352\264\221\353\260\260.py" @@ -0,0 +1,26 @@ +# 방금그곡 +# 테스트 29 〉 통과 (1.27ms, 10.5MB) + +def replace_code(s): + return s.replace("C#", "c").replace("D#", "d").replace("F#", "f").replace("G#", "g").replace("A#", "a") + +def change_time(h, m): + return h*60+m + +def solution(m, musicinfos): + answer = '(None)' + m = replace_code(m) + l = 0 + for i in musicinfos: + start, end, song, code = i.split(',') + s_h, s_m = map(int, start.split(':')) + e_h, e_m = map(int, end.split(':')) + start = change_time(s_h, s_m) + end = change_time(e_h, e_m) + now_l = end - start + code = replace_code(code) + code = code*(now_l//len(code))+code[:now_l%len(code)] # 재생 길이만큼 code 늘려주기 + if m in code and l < now_l: + answer = song + l = now_l + return answer \ No newline at end of file diff --git "a/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\354\240\225\352\264\221\353\260\260.py" "b/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\354\240\225\352\264\221\353\260\260.py" new file mode 100644 index 0000000..f972e24 --- /dev/null +++ "b/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\354\240\225\352\264\221\353\260\260.py" @@ -0,0 +1,15 @@ +# 구명보트 +# 테스트 2 〉 통과 (10.06ms, 10.6MB) + +def solution(people, limit): + answer = 0 + people.sort() + + s = 0 + e = len(people) - 1 + while s <= e: + if people[s] + people[e] <= limit: + s += 1 + answer += 1 + e -= 1 + return answer \ No newline at end of file diff --git "a/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\354\240\225\352\264\221\353\260\260.py" "b/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\354\240\225\352\264\221\353\260\260.py" new file mode 100644 index 0000000..3507126 --- /dev/null +++ "b/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\354\240\225\352\264\221\353\260\260.py" @@ -0,0 +1,15 @@ +# 모음사전 +# 테스트 17 〉 통과 (0.11ms, 10.4MB) + +from itertools import product + +V = ['A','E','I','O','U'] +words = [] +for i in range(1, 6): + for j in product(V, repeat=i): + words.append(''.join(j)) +words.sort() # 사전 순 정렬 + +def solution(word): + answer = words.index(word)+1 + return answer \ No newline at end of file From e035f79afcb13dc596bdf090a94e7cd958022081 Mon Sep 17 00:00:00 2001 From: Park Date: Thu, 6 Jul 2023 20:00:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?week24=5F=EB=B0=95=ED=98=84=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3_\353\260\225\355\230\204\354\244\200.py" | 34 +++++++++++++++++++ ...5_\353\260\225\355\230\204\354\244\200.py" | 16 +++++++++ ...2_\353\260\225\355\230\204\354\244\200.py" | 14 ++++++++ 3 files changed, 64 insertions(+) create mode 100644 "week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\353\260\225\355\230\204\354\244\200.py" create mode 100644 "week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\353\260\225\355\230\204\354\244\200.py" create mode 100644 "week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\353\260\225\355\230\204\354\244\200.py" diff --git "a/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\353\260\225\355\230\204\354\244\200.py" "b/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\353\260\225\355\230\204\354\244\200.py" new file mode 100644 index 0000000..5b3e303 --- /dev/null +++ "b/week24_230706/pg17683_\353\260\251\352\270\210\352\267\270\352\263\241/pg17683_\353\260\225\355\230\204\354\244\200.py" @@ -0,0 +1,34 @@ +def change_music(music): + if 'C#' in music: + music = music.replace('C#', 'c') + if 'D#' in music: + music = music.replace('D#', 'd') + if 'F#' in music: + music = music.replace('F#', 'f') + if 'G#' in music: + music = music.replace('G#', 'g') + if 'A#' in music: + music = music.replace('A#', 'a') + return music +def solution(m, musicinfos): + answer = [] + for index, info in enumerate(musicinfos): + temp = info.split(',') + + start_time = list(map(int, temp[0].split(':'))) + end_time = list(map(int, temp[1].split(':'))) + name = temp[2] + music = change_music(temp[3]) + music_length = len(music) + + music_playtime = (end_time[0] * 60 + end_time[1]) - (start_time[0] * 60 + start_time[1]) + played_music = music * int(music_playtime / music_length) + music[:music_playtime%music_length] + if change_music(m) in played_music: + answer.append([music_playtime, index, name]) + + answer = sorted(answer, key=lambda x: (-x[0], x[1])) + + if not answer: + return "(None)" + else: + return answer[0][2] \ No newline at end of file diff --git "a/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\353\260\225\355\230\204\354\244\200.py" "b/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\353\260\225\355\230\204\354\244\200.py" new file mode 100644 index 0000000..92bdddc --- /dev/null +++ "b/week24_230706/pg42885_\352\265\254\353\252\205\353\263\264\355\212\270/pg42885_\353\260\225\355\230\204\354\244\200.py" @@ -0,0 +1,16 @@ +def solution(people, limit): + answer = 0 + people = sorted(people) + left = 0 + right = len(people) - 1 + + while left <= right: + if people[left] + people[right] > limit: + answer += 1 + right -= 1 + else: + answer += 1 + left += 1 + right -= 1 + + return answer \ No newline at end of file diff --git "a/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\353\260\225\355\230\204\354\244\200.py" "b/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\353\260\225\355\230\204\354\244\200.py" new file mode 100644 index 0000000..57796dd --- /dev/null +++ "b/week24_230706/pg84512_\353\252\250\354\235\214\354\202\254\354\240\204/pg84512_\353\260\225\355\230\204\354\244\200.py" @@ -0,0 +1,14 @@ +def solution(word): + answer = 0 + words = ['A', 'E', 'I', 'O', 'U'] + dict = [] + def find_dict(index, word): + if index == 5: + return + for i in range(5): + temp = word + words[i] + dict.append(temp) + find_dict(index + 1, word + words[i]) + find_dict(0, '') + answer = dict.index(word) + 1 + return answer \ No newline at end of file