{"id":26099359,"url":"https://github.com/okyungjin/algorithm","last_synced_at":"2026-05-28T01:02:39.783Z","repository":{"id":51275866,"uuid":"443930245","full_name":"okyungjin/ALGORITHM","owner":"okyungjin","description":"✔ JUST DO IT.","archived":false,"fork":false,"pushed_at":"2022-10-12T13:28:19.000Z","size":226,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T01:14:09.344Z","etag":null,"topics":["algorithm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okyungjin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-03T03:31:26.000Z","updated_at":"2022-11-12T08:07:51.000Z","dependencies_parsed_at":"2022-08-22T02:00:14.315Z","dependency_job_id":null,"html_url":"https://github.com/okyungjin/ALGORITHM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/okyungjin/ALGORITHM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okyungjin%2FALGORITHM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okyungjin%2FALGORITHM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okyungjin%2FALGORITHM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okyungjin%2FALGORITHM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okyungjin","download_url":"https://codeload.github.com/okyungjin/ALGORITHM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okyungjin%2FALGORITHM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33589684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm"],"created_at":"2025-03-09T16:37:24.423Z","updated_at":"2026-05-28T01:02:39.763Z","avatar_url":"https://github.com/okyungjin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ALGORITHM\n- [그래프](#그래프)\n  - [1부터 채워진 2차원 그래프 생성](#1부터-채워진-2차원-그래프-생성)\n  - [2차원 그래프 출력](#2차원-그래프-출력)\n  - [2차원 그래프 slice](#2차원-그래프-slice)\n  - [2차원 좌표 자료구조](#2차원-좌표-자료구조)\n  - [2차원 그래프 회전](#2차원-그래프-회전)\n## 그래프\n### 1부터 채워진 2차원 그래프 생성\n```py\n''' Generate 2d retangle fiiled with ascending numbers '''\ndef generate_2d_rectangle_filled_with_ascending_numbers(n_rows, n_cols):\n    return [[r * n_cols + c + 1 for c in range(n_cols)] for r in range(n_rows)]\n```\n\n다음과 같이 펼쳐서 사용할 수도 있다.\n```py\n''' Transpose of matrix using nested loops '''\ngraph = [[0] * n_cols for r in range(n_rows)]\nfor r in range(n_rows):\n    for c in range(n_cols):\n        graph[r][c] = r * n_cols + c + 1\n    \n```\n\n### 2차원 그래프 출력\n#### 원소가 한 자리 수\n```py\n''' Print 2d list'''\ndef print_2d_list(arr: List[List[int]]) -\u003e None:\n    for row in arr:\n        for col in row:\n            print(col, end = ' ')\n        print()\n    print()\n```\n#### 원소가 두 자리 수\n\n```py\ndef print_2d_graph(graph):\n    print('======= graph =======')\n    for row in graph:\n        res = ''\n        for col in row:\n            col = str(col)\n            res += col + ' ' if len(col) \u003e 1 else ' ' + col + ' '\n        print(res)\n    print('======= graph =======')        \n    print()\n```\n\n### 2차원 그래프 slice\n```py\n''' Slice rectangle '''\ndef slice_rectangle_based_on_upper_left_point_and_lower_right_point(graph: List[List[int]], upper_left: Point, lower_right: Point) -\u003e List[List[int]]:\n    res = []\n    for row in range(upper_left.x - 1, lower_right.x):\n        res.append(graph[row][upper_left.y - 1:lower_right.y])\n    return res\n```\n\n### 2차원 좌표 자료구조\n```py\n''' [Data Structure] 2D Point '''\nclass Point:\n    def __init__(self, x, y):\n        self.x = x\n        self.y = y\n\n    def __str__(self):\n        return f'({self.x}, {self.y})'\n```\n\n### 2차원 그래프 회전\n#### 시계 방향\n```\n[example]\n1 2      5 3 1\n3 4  =\u003e  6 4 2\n5 6\n\n[roated pos]\n(0,0) (0,1)      (2,0) (1,0) (0,0)\n(1,0) (1,1)  =\u003e  (2,1) (1,1) (0,1)\n(2,0) (2,1)      \n                 -- origin pos --\n                 (0,0) (0,1) (0,2)\n                 (1,0) (1,1) (1,2)\n```\n```py\n''' Rotate Rectangle '''\ndef rotate_rectangle_clockwise(rectangle: List[List[int]], is_square: bool = False) -\u003e List[List[int]]:\n    if not rectangle: return [[]]\n\n    height = len(rectangle)\n    width = height if is_square else len(rectangle[0])\n    rotated = [[0] * height for _ in range(width)]\n\n    # _col: index of colum / _row: index of row\n    for _col in range(width):\n        for _row in range(height):\n            rotated[_col][height - _row - 1] = rectangle[_row][_col]\n\n    return rotated\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokyungjin%2Falgorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokyungjin%2Falgorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokyungjin%2Falgorithm/lists"}