Improve Python code for importing modules.

pull/874/head
krahets 1 year ago
parent 1e49574332
commit 5aacf2dfe0

@ -4,10 +4,11 @@ Created Time: 2022-11-25
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode, print_linked_list
def insert(n0: ListNode, P: ListNode):

@ -43,7 +43,7 @@ if __name__ == "__main__":
for i in range(len(nums)):
tmp.append(nums[i])
print(f"\n通过索引遍历列表得到 tmp = {tmp}")
tmp.clear()
for num in nums:
tmp.append(num)

@ -4,11 +4,6 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
def backtrack(
state: list[int], choices: list[int], selected: list[bool], res: list[list[int]]

@ -4,11 +4,6 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
def backtrack(
state: list[int], choices: list[int], selected: list[bool], res: list[list[int]]

@ -4,10 +4,11 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree, list_to_tree
def pre_order(root: TreeNode):

@ -4,10 +4,11 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree, list_to_tree
def pre_order(root: TreeNode):

@ -4,10 +4,11 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree, list_to_tree
def pre_order(root: TreeNode):

@ -4,10 +4,11 @@ Created Time: 2023-04-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree, list_to_tree
def is_solution(state: list[TreeNode]) -> bool:

@ -4,10 +4,11 @@ Created Time: 2022-11-25
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode, TreeNode, print_tree
def function() -> int:

@ -4,10 +4,11 @@ Created Time: 2023-07-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree
def dfs(

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import Vertex, vals_to_vets
class GraphAdjList:

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import Vertex, print_matrix
class GraphAdjMat:

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import Vertex, vals_to_vets, vets_to_vals
from collections import deque
from graph_adjacency_list import GraphAdjList

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import Vertex, vets_to_vals, vals_to_vets
from graph_adjacency_list import GraphAdjList

@ -4,10 +4,11 @@ Created Time: 2023-06-15
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode
"""Driver Code"""
if __name__ == "__main__":

@ -4,10 +4,11 @@ Created Time: 2022-12-14
Author: msk397 (machangxinq@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import print_dict
"""Driver Code"""
if __name__ == "__main__":

@ -4,9 +4,10 @@ Created Time: 2023-06-13
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
sys.path.append(str(Path(__file__).parent.parent))
from chapter_hashing.array_hash_map import Pair

@ -4,9 +4,10 @@ Created Time: 2023-06-13
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
sys.path.append(str(Path(__file__).parent.parent))
from chapter_hashing.array_hash_map import Pair

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import print_heap
import heapq

@ -4,10 +4,11 @@ Created Time: 2023-02-23
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import print_heap
class MaxHeap:

@ -4,10 +4,11 @@ Created Time: 2023-06-10
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import print_heap
import heapq

@ -4,9 +4,10 @@ Created Time: 2023-08-04
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
sys.path.append(str(Path(__file__).parent.parent))
from binary_search_insertion import binary_search_insertion

@ -4,10 +4,11 @@ Created Time: 2022-11-26
Author: timi (xisunyy@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode, list_to_linked_list
def hashing_search_array(hmap: dict[int, int], target: int) -> int:

@ -4,10 +4,11 @@ Created Time: 2022-11-26
Author: timi (xisunyy@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode, list_to_linked_list
def linear_search_array(nums: list[int], target: int) -> int:

@ -4,10 +4,11 @@ Created Time: 2022-12-01
Author: Peng Chen (pengchzn@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode
class LinkedListQueue:

@ -4,10 +4,11 @@ Created Time: 2022-11-29
Author: Peng Chen (pengchzn@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode
class LinkedListStack:

@ -4,10 +4,11 @@ Created Time: 2023-07-19
Author: Krahets (krahets@163.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, list_to_tree, print_tree
class ArrayBinaryTree:

@ -4,10 +4,11 @@ Created Time: 2022-12-20
Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree
class AVLTree:

@ -4,10 +4,11 @@ Created Time: 2022-12-20
Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree
class BinarySearchTree:

@ -4,10 +4,11 @@ Created Time: 2022-12-20
Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, print_tree
"""Driver Code"""

@ -4,10 +4,11 @@ Created Time: 2022-12-20
Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, list_to_tree, print_tree
from collections import deque

@ -4,10 +4,11 @@ Created Time: 2022-12-20
Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import sys
from pathlib import Path
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from modules import *
sys.path.append(str(Path(__file__).parent.parent))
from modules import TreeNode, list_to_tree, print_tree
def pre_order(root: TreeNode | None):

Loading…
Cancel
Save