From 3a6dbffdb042bde06ce86b4212cd86d3c4941945 Mon Sep 17 00:00:00 2001 From: SeoHyeon Date: Mon, 17 Mar 2025 16:46:18 +0900 Subject: [PATCH 1/2] fix: priority_queue.py, main.py --- .github/workflows/python-app.yml | 2 +- .idea/.gitignore | 8 ++++ .idea/inspectionProfiles/Project_Default.xml | 42 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/material_theme_project_new.xml | 13 ++++++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ .idea/week2_question.iml | 8 ++++ main.py | 20 ++++----- priority_queue.py | 8 ++-- 11 files changed, 113 insertions(+), 15 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/material_theme_project_new.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/week2_question.iml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 5420c17..9f5aafd 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -41,4 +41,4 @@ jobs: pylint *.py - name: Test with pytest run: | - pytest + python test.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8d3c1af --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,42 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..cc27e86 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d4deccd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..23a8490 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/week2_question.iml b/.idea/week2_question.iml new file mode 100644 index 0000000..6bd5ba5 --- /dev/null +++ b/.idea/week2_question.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py index 5a3e755..d6ec0bd 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,14 @@ from priority_queue import PriorityQueue def main(): - pq = PriorityQueue() - - pq.push("Task 1", 3) - pq.push("Task 2", 1) - pq.push("Task 3", 2) - - print(pq.pop()) - print(pq.pop()) - print(pq.pop()) + pq = PriorityQueue() + + pq.push("Task 1", 3) + pq.push("Task 2", 1) + pq.push("Task 3", 2) + + print(pq.pop()) + print(pq.pop()) + print(pq.pop()) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/priority_queue.py b/priority_queue.py index 6994ec7..f54f6be 100644 --- a/priority_queue.py +++ b/priority_queue.py @@ -10,11 +10,11 @@ def push(self, item, priority): def pop(self): if len(self.heap) > 1: self._swap(0, len(self.heap) - 1) - priority, item = self.heap.pop() + _, item = self.heap.pop() self._sift_down(0) return item elif len(self.heap) == 1: - priority, item = self.heap.pop() + _, item = self.heap.pop() return item else: return None @@ -35,11 +35,11 @@ def _sift_down(self, index): smallest = index if left_child_index < len(self.heap) and \ - self.heap[left_child_index][0] > self.heap[smallest][0]: + self.heap[left_child_index][0] < self.heap[smallest][0]: smallest = left_child_index if right_child_index < len(self.heap) and \ - self.heap[right_child_index][0] > self.heap[smallest][0]: + self.heap[right_child_index][0] < self.heap[smallest][0]: smallest = right_child_index if smallest != index: From af2dd9ee46f8fe46eb51c0bc5d8eee2f44e05051 Mon Sep 17 00:00:00 2001 From: SeoHyeon Date: Mon, 17 Mar 2025 17:05:08 +0900 Subject: [PATCH 2/2] fix: removed unnessesory files --- .idea/.gitignore | 8 ---- .idea/inspectionProfiles/Project_Default.xml | 42 ------------------- .../inspectionProfiles/profiles_settings.xml | 6 --- .idea/material_theme_project_new.xml | 13 ------ .idea/misc.xml | 7 ---- .idea/modules.xml | 8 ---- .idea/vcs.xml | 6 --- .idea/week2_question.iml | 8 ---- 8 files changed, 98 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/material_theme_project_new.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/week2_question.iml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index c3f502a..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 8d3c1af..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml deleted file mode 100644 index cc27e86..0000000 --- a/.idea/material_theme_project_new.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index d4deccd..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 23a8490..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/week2_question.iml b/.idea/week2_question.iml deleted file mode 100644 index 6bd5ba5..0000000 --- a/.idea/week2_question.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file