
백준 1149 RGB거리 (파이썬)
2022. 10. 23. 18:58
백준
풀이 import sys N = int(sys.stdin.readline()) arr = [list(map(int, sys.stdin.readline().strip().split())) for _ in range(N)] for i in range(1, N): arr[i][0] = min(arr[i-1][1], arr[i-1][2]) + arr[i][0] arr[i][1] = min(arr[i-1][0], arr[i-1][2]) + arr[i][1] arr[i][2] = min(arr[i-1][1], arr[i-1][0]) + arr[i][2] rst = 9e9 for j in range(3): rst = min(rst, arr[N-1][j]) print(rst) 후기 백트래킹 문제인줄 알고 백트래킹으로 ..

리트코드 130 Surrounded Regions (파이썬)
2022. 10. 23. 15:50
리트코드
https://leetcode.com/problems/surrounded-regions/submissions/ Surrounded Regions - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 및 해설(주석) class Solution(object): def solve(self, board): N, M = len(board), len(board[0]) def dfs(r, c): if r < 0 or c < 0 or r == N or c == M or bo..

[자바스크립트] 홀수, 짝수 판별, 글자 색깔 바꾸기 웹사이트
2022. 10. 22. 21:37
재미로 만드는 웹
구현 내용 숫자를 입력할 수 있는 텍스트 창과 옆에 제출버튼, 색깔바꾸기 버튼이 있습니다. 숫자를 입력하고 제출을 누르면, 밑에 홀수인지 짝수인지 알려주는 텍스트를 띄여 줍니다. 숫자가 아닌 다른 문자를 입력하면 숫자를 입력하라고 띄웁니다. 제출을 눌렀다면, 입력할 수 있는 텍스트 창이 비워지고, 재입력할 수 있게 커서를 위치시킵니다. 색깔바꾸기 버튼을 클릭하면, 알려주는 텍스트의 색깔을 바꿉니다. See the Pen 홀수, 짝수 by ryuwc (@ryuwc) on CodePen. html 코드 숫자를 입력하세요 제출 색깔바꾸기

[자바스크립트] 계산기 웹사이트 만들기
2022. 10. 21. 22:06
JS 토이프로젝트
See the Pen Untitled by ryuwc (@ryuwc) on CodePen.

백준 2304 창고 다각형 (파이썬)
2022. 10. 20. 21:44
백준
풀이 and 해설(주석) import sys N = int(sys.stdin.readline()) max_hei = 0 max_idx = 0 len_info = 0 # 기둥의 최대 수는 1000, 입력되는 위치에 기둥을 추가 할 것 record = [0] * 1001 for _ in range(N): p, h = map(int, sys.stdin.readline().strip().split()) # 가장 높은 기둥을 중심으로 양쪽에서 접근 할 것이므로 가장 높은 기둥의 위치 정보가 필요함 if h > max_hei: max_hei = h max_idx = p # 마지막 기둥이 있는 위치 len_info = max(len_info, p) record[p] = h rst = 0 tmp = 0 # 첫 위치부터..

[자바스크립트] 별찍기2
2022. 10. 20. 16:25
JavaScript 알고리즘 연습
문제 다음 그림 처럼 별을 찍어라 풀이 for (i = 1; i < 6; i++) { rst = ' '.repeat(5-i) + '*'.repeat(i*2-1) console.log(rst) }

[자바스크립트] Array Helper Method 작성하기 실습
2022. 10. 20. 14:29
JavaScript 알고리즘 연습
users const users = [ { name: 'John', age: 31, isMarried: true, balance: 100, }, { name: 'Sarah', age: 22, isMarried: false, balance: 200, }, { name: 'Ashley', age: 25, isMarried: true, balance: 300, }, { name: 'Robert', age: 27, isMarried: false, balance: 400, }, { name: 'Tom', age: 35, isMarried: true, balance: 500, }, ] forEach 메서드를 활용해 모든 사용자들의 이름을 출력하시오. // 1. const usersName = users.forEac..

[자바스크립트] 가위바위보 알고리즘
2022. 10. 20. 14:20
JavaScript 알고리즘 연습
문제 player 1 과 player 2 의 가위바위보 경우의 수가 차례대로 배열로 주어질 때, 각 회차마다 어느 플레이어가 이겼는지 출력하시오. 풀이 const p1 = ['rock', 'paper', 'scissors', 'scissors', 'rock', 'rock', 'paper', 'paper', 'rock', 'scissors'] const p2 = ['paper', 'paper', 'rock', 'scissors', 'paper', 'scissors', 'scissors', 'rock', 'rock', 'rock'] const playGame = (p1, p2) => { for (let i = 0; i < p1.length; i++) { let p1_choice = p1[i] let p2_c..