From 8716772dec4a64b24a5f98d60c75287a9d041165 Mon Sep 17 00:00:00 2001 From: Automata Date: Mon, 25 Jul 2022 12:07:45 +0900 Subject: [PATCH] save tmp --- 1/{1.py => 1_time.py} | 0 1/{2.py => 2_useful_source.py} | 0 7/5MySol.py | 10 ++++++++ ..._2\354\247\204\355\203\220\354\203\211.py" | 25 +++++++++++++++++++ basic/counter_lib.py | 4 +++ ...21\353\263\265\354\241\260\355\225\251.py" | 7 ++++++ .../\354\236\220\353\243\214\355\230\225.py" | 6 +++++ ...14\352\263\265\353\260\260\354\210\230.py" | 8 ++++++ 8 files changed, 60 insertions(+) rename 1/{1.py => 1_time.py} (100%) rename 1/{2.py => 2_useful_source.py} (100%) create mode 100644 7/5MySol.py create mode 100644 "7/5_2\354\247\204\355\203\220\354\203\211.py" create mode 100644 basic/counter_lib.py create mode 100644 "basic/\354\210\234\354\227\264\354\241\260\355\225\251\354\244\221\353\263\265\354\210\234\354\227\264\354\244\221\353\263\265\354\241\260\355\225\251.py" create mode 100644 "basic/\354\236\220\353\243\214\355\230\225.py" create mode 100644 "basic/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" diff --git a/1/1.py b/1/1_time.py similarity index 100% rename from 1/1.py rename to 1/1_time.py diff --git a/1/2.py b/1/2_useful_source.py similarity index 100% rename from 1/2.py rename to 1/2_useful_source.py diff --git a/7/5MySol.py b/7/5MySol.py new file mode 100644 index 0000000..0002646 --- /dev/null +++ b/7/5MySol.py @@ -0,0 +1,10 @@ +N = 5 # 기계부품 +nums = [8, 3, 7, 9, 2] # 부품번호 +M = 3 # 확인개수 +chks = [3, 7, 9] # 부품번호 + +for i in chks: + if i in nums: + print('yes') + else: + print('no') diff --git "a/7/5_2\354\247\204\355\203\220\354\203\211.py" "b/7/5_2\354\247\204\355\203\220\354\203\211.py" new file mode 100644 index 0000000..35b8ec1 --- /dev/null +++ "b/7/5_2\354\247\204\355\203\220\354\203\211.py" @@ -0,0 +1,25 @@ +N = 5 # 기계부품 +nums = [8, 3, 7, 9, 2] # 부품번호 +M = 3 # 확인개수 +chks = [5, 7, 9] # 부품번호 +nums.sort() +chks.sort() + + +def binary_search(array, target, start, end): + while start <= end: + mid = (start + end) // 2 + if array[mid] == target: + return mid + elif array[mid] > target: + end = mid - 1 + else: + start = mid + 1 + return None + +for i in chks: + result = binary_search(nums, i , 0, N-1) + if result != None: + print('yes') + else: + print('no') \ No newline at end of file diff --git a/basic/counter_lib.py b/basic/counter_lib.py new file mode 100644 index 0000000..1911a35 --- /dev/null +++ b/basic/counter_lib.py @@ -0,0 +1,4 @@ +from collections import Counter +list = ['red','blue','red','green','blue','blue'] +print(dict(Counter(list))) +print(Counter(list)['blue']) diff --git "a/basic/\354\210\234\354\227\264\354\241\260\355\225\251\354\244\221\353\263\265\354\210\234\354\227\264\354\244\221\353\263\265\354\241\260\355\225\251.py" "b/basic/\354\210\234\354\227\264\354\241\260\355\225\251\354\244\221\353\263\265\354\210\234\354\227\264\354\244\221\353\263\265\354\241\260\355\225\251.py" new file mode 100644 index 0000000..fe7a6be --- /dev/null +++ "b/basic/\354\210\234\354\227\264\354\241\260\355\225\251\354\244\221\353\263\265\354\210\234\354\227\264\354\244\221\353\263\265\354\241\260\355\225\251.py" @@ -0,0 +1,7 @@ +from itertools import permutations, combinations, product, combinations_with_replacement +data = ['A','B','C'] +순열 = list(permutations(data,2)) +조합 = list(combinations(data,2)) +중복순열 = list(product(data,repeat=2)) +중복조합 = list(combinations_with_replacement(data,2)) +print(순열,조합,중복순열,중복조합, sep='\n') diff --git "a/basic/\354\236\220\353\243\214\355\230\225.py" "b/basic/\354\236\220\353\243\214\355\230\225.py" new file mode 100644 index 0000000..3f50898 --- /dev/null +++ "b/basic/\354\236\220\353\243\214\355\230\225.py" @@ -0,0 +1,6 @@ +# 자료형 초기화 +list_ = [1,2,3] +tuple_ = (1,2,3) +dict_ = {'one':1, 'two':2, 'three': 3} # 순서없음, O(1) +set_ = {1,2,3} # 중복불가, 순서없음, O(1) + diff --git "a/basic/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" "b/basic/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" new file mode 100644 index 0000000..d9b62ba --- /dev/null +++ "b/basic/\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.py" @@ -0,0 +1,8 @@ +import math + +print(math.gcd(21,14)) + +def lcm(a,b): + return (a*b)//math.gcd(a,b) + +print(lcm(21,14))