코딩/Python (75) 썸네일형 리스트형 머신러닝 알고리즘 익히기(Logistic Regression, Random Forest, Gradient Boosting, Light GBM), import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline #노트북안에서 바로 그래프를 출력하여 보여줌 import warnings warnings.filterwarnings('ignore') #데이터 불러오기 datapath = 'https://github.com/mchoimis/tsdl/raw/main/income/' df = pd.io.parsers.read_csv(datapath + 'income.csv') df.head() # 데이터 형태 확인 print(df.shape) print(df.columns) df.info() # 결측치(NA, 없는 값)를 Na.. 파이썬, openpyxl(6) 수식작성, 병합, 이미지삽입 #수식작성, 저장하기 import datetime from openpyxl import Workbook wb = Workbook() ws = wb.active ws["A1"] = datetime.datetime.today() ws["A2"] = "=SUM(1,2,3)" ws["A4"] = 10 ws["A5"] = 20 ws["A6"] = "=average(A4:A5)" wb.save("./Desktop/코딩공부/sample.xlsx") from openpyxl import Workbook wb = Workbook() ws = wb.active #수식작성, 불러오기 from openpyxl import load_workbook wb = load_workbook("./Desktop/코딩공부/sample.xl.. [Python] 백준 6603 로또 6603번: 로또 (acmicpc.net) 6603번: 로또 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있다. 첫 번째 수는 k (6 < k < 13)이고, 다음 k개 수는 집합 S에 포함되는 수이다. S의 원소는 오름차순으로 www.acmicpc.net 코드 작성 def dfs(lott, num): if lott == 6: print(*ans) return for i in range(num, k): ans.append(s[i]) dfs(lott + 1, i + 1) ans.pop() while True: arr = list(map(int, input().split())) k = arr[0] s = arr[1:] ans = [] dfs(0, 0) print().. [Python] 백준 10819 차이를 최대로 10819번: 차이를 최대로 (acmicpc.net) 10819번: 차이를 최대로 첫째 줄에 N (3 ≤ N ≤ 8)이 주어진다. 둘째 줄에는 배열 A에 들어있는 정수가 주어진다. 배열에 들어있는 정수는 -100보다 크거나 같고, 100보다 작거나 같다. www.acmicpc.net 코드 작성 from itertools import permutations n = int(input()) arr = list(map(int, input().split())) ans = 0 for per in permutations(arr): #2 temp = 0 for i in range(n-1): temp += abs(per[i] - per[i+1]) ans = max(ans, temp) print(ans) 코드 풀이 #1... [Python] 백준 15667 15667번: 2018 연세대학교 프로그래밍 경진대회 (acmicpc.net) 15667번: 2018 연세대학교 프로그래밍 경진대회 2015, 2016, 2017년에 이어 올해도 연세대학교 컴퓨터과학과 프로그래밍 경진대회가 열린다. 도현이는 4년 연속 교내대회가 개최된다는 것에 감격하여, 사비를 털 각오로 화려한 개막식을 준비했다. www.acmicpc.net 코드 작성 k = int(input()) for i in range(1, k+1): if 1 + i + i**2 == k: print(i) break [Python] 백준 10972 다음순열 https://www.acmicpc.net/problem/10972 10972번: 다음 순열 첫째 줄에 입력으로 주어진 순열의 다음에 오는 순열을 출력한다. 만약, 사전순으로 마지막에 오는 순열인 경우에는 -1을 출력한다. www.acmicpc.net 코드 작성 n = int(input()) arr = list(map(int, input().split())) for i in range(n-1, 0, -1): if arr[i] > arr[i-1]: for j in range(n-1, 0, -1): if arr[i-1] < arr[j]: arr[i-1] , arr[j] = arr[j], arr[i-1] arr = arr[:i] + sorted(arr[i:]) print(*arr) exit(0) print(-.. [Python] 백준 1107 리모컨 https://www.acmicpc.net/problem/1107 1107번: 리모컨 첫째 줄에 수빈이가 이동하려고 하는 채널 N (0 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 고장난 버튼의 개수 M (0 ≤ M ≤ 10)이 주어진다. 고장난 버튼이 있는 경우에는 셋째 줄에는 고장난 버튼 www.acmicpc.net 코드 작성 cha = int(input()) #channel m = int(input()) ans = abs(100-cha) if m : bttn = set(input().split()) #button else: bttn = set() for num in range(1000001): for i in str(num): if i in bttn: break: else: ans = min.. [Python] 백준 3085 사탕 게임 https://www.acmicpc.net/problem/3085 3085번: 사탕 게임 예제 3의 경우 4번 행의 Y와 C를 바꾸면 사탕 네 개를 먹을 수 있다. www.acmicpc.net 코드 작성 n = int(input()) arr = [] for i in range(n): arr.append(list(input())) maxcnt = 0 def check(): global maxcnt for i in range(n): cnt = 1 for j in range(n-1): if arr[i][j] == arr[i][j+1]: cnt += 1 maxcnt = max(maxcnt, cnt) else: cnt = 1 cnt = 1 for j in range(n-1): if arr[j][i] == arr[.. 이전 1 2 3 4 5 ··· 10 다음 목록 더보기