분류 전체보기

    테트로미노 [백준 14500] - python

    테트로미노 [백준 14500] - python

    def BOJ14500() : global result n,m = map(int, input().split()) graph = [] for _ in range(n) : graph.append(list(map(int, input().split()))) visited = [[0] * m for _ in range(n)] direction = [[0,1], [0,-1], [1,0], [-1,0]] result = 0 middle_finger_tetromino = [[[0,1], [0,2], [1,1]], [ [0,1], [0,2], [-1,1]], [[1,0], [2,0], [1,1]], [[1,0], [2,0], [1,-1]]] def dfs(x, y, count, number, visited): globa..

    미로 탐색 [백준 2178] - python

    미로 탐색 [백준 2178] - python

    import sys input = sys.stdin.readline INF = 1e9 def BOJ2178() : global graph global result global N, M def dfs(x, y, count) : stack = [] directions = [[1, 0], [-1, 0], [0, 1], [0, -1]] result[x][y] = count stack.append([x, y, count]) while stack : curr_x, curr_y, curr_count = stack.pop() for dir_x, dir_y in directions : next_x = curr_x + dir_x next_y = curr_y + dir_y next_count = curr_count + 1 ..

    Wifi Setup [백준 5864] - python

    Wifi Setup [백준 5864] - python

    import sys input = sys.stdin.readline INF = 1e11 def BOJ5864(): N, A, B = map(int, input().split()) dp = [INF for _ in range(1000001)] cows = [] for _ in range(N): curr_cow = int(input()) cows.append(curr_cow) cows.sort() curr_wifi = cows[0] dp[curr_wifi] = A for i in range(1, len(cows)): dp[cows[i]] = min(dp[cows[i-1]] + B * (cows[i] - cows[i-1]) / 2, dp[cows[i-1]] + A) # B * (cows[i] - cows[i-..

    로봇 청소기 [백준 14503] - python

    로봇 청소기 [백준 14503] - python

    from collections import deque import sys input = sys.stdin.readline def BOJ14503() : global N, M global directions global cleared global graph def bfs(r, c, d) : queue = deque() queue.append([r, c, d]) while queue : x, y, direction = queue.popleft() flag = True for dir_x, dir_y, dir in directions[direction] : n_x = x + dir_x n_y = y + dir_y n_dir = dir if 0

    돌 게임 [백준 9655] - python

    돌 게임 [백준 9655] - python

    import sys from collections import deque input = sys.stdin.readline def BOJ9655() : N = int(input()) players = ["SK", "CY"] dp = [3 for _ in range(1001)] dp[0] = 1 for i in range(1001) : if dp[i] != 3 : player = dp[i] next_player = player ^ 1 if i + 1 < 1001 : dp[i+1] = next_player if i + 3 < 1001: dp[i+3] = next_player print(players[dp[N]]) BOJ9655() 접근 방법 : 1. 돌 개수를 배열로 선언하고 각 개수일때에 어느 플레이어가 가..

    토마토 [백준 7576] - python

    토마토 [백준 7576] - python

    from collections import deque import sys input = sys.stdin.readline RIPE = 1 UN_RIPE = 0 def BOJ7576() : global M, N directions = [[1, 0], [-1, 0], [0, 1], [0, -1]] def bfs(graph) : queue = deque() temp = [[-1 for _ in range(M)] for _ in range(N)] visited = [[False for _ in range(M)] for _ in range(N)] for i in range(N) : for j in range(M) : if graph[i][j] == 0 : continue temp[i][j] = 0 if graph..

    console.log vs process.stdout.write

    console.log vs process.stdout.write

    최근 node 패키지를 하나 만들다가 process.stdout.write을 이용하는 경우가 생겼었습니다. 단순히 출력을 해주는 기능 같은데 기존에 자주 사용하던 console.log와는 무엇이 다른 것일까요? 위의 결과에서 어떤것이 console.log, process.stdout.write를 이용한 것 일까요 console.log("console.log") console.log("vs") console.log("process.stdout.write"); process.stdout.write("console.log ") process.stdout.write("vs "); process.stdout.write("process.stdout.write"); 개행이 들어간것이 console.log를 이용 들..

    "ENOSPC: no space left on device, write"

    "ENOSPC: no space left on device, write"

    aws ec2를 이용하여 서버를 띄워 두었는데 위와 같은 git pull, yarn install 등을 실행하려 하면 위와 같은 메시지가 출력되면서 동작이 수행되지 않았었습니다. 메시지 내용 그대로 현재 서버에 여유공간이 없는 상태인것 같습니다. 제가 행했던 행동은 다음과 같습니다 1. df -h를 이용하여 서버 disk 상태 확인 2. 용량이 부족하다면 불필요하게 사이즈가 커지고 있는 파일(log 같은 것들)이 없는지 확인하고 있으면 지워줍니다. 3. 2번에서 해결이 되지 않았다면 disk volume을 키워주어야 합니다.(저는 2번에서 해결하지 못했었네요...) 4. 저는 aws의 ec2를 사용하고 있으므로 aws console에서 volume을 키워줄 겁니다. aws로 접속 5. aws의 ec2 화..

    Android 웹뷰 alert, confirm 띄우기

    Android 웹뷰 alert, confirm 띄우기

    안드로이드 웹뷰 에서는 alert 와 confirm을 따로 커스텀 하지 않아도 띄워주긴 합니다. 아래의 내용은 좀 더 입맛에 맞게 브라우저에서 alert와 confirm을 띄워줄 때 액션을 다루기 위한 내용 입니다. WebView webview; WebChromeClient webClient = new WebChromeClient() { // 여기에서 메서드들을 override 해주면 됩니다 } webview.setWebChromeClient(webClient); 은 WebChromeClient의 객체를 생성해주는 부분인데 이 클래스 안에 정말 많은 기능들이 숨어있습니다. (제가 봤을때는 19개의 메소드가 있었고 alert, confirm, prompt, geolocation 승인 등등 다양한 내용이 있..

    Ios 웹뷰 alert, confirm 띄우기

    Ios 웹뷰 alert, confirm 띄우기

    웹뷰에서 javascript로 된 alert와 confirm을 띄우려면 코드를 추가해주어야 합니다. alert와 confirm의 경우 각각 webview에 정의되어 있는 인스턴스 메소드들을 선언해주어야 합니다. viewController 내부에 선언해주면 됩니다. UIAlertController에서 preferredStyle을 커스텀 해줄수 있습니다. .alert와 .actionSheet 두개의 형식이 있습니다. 원하는 형식을 선택해서 보여주고 싶은 형식을 보여주면 됩니다! alert func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, ..