240324

Regular Kim·2024년 3월 24일
0

회고

목록 보기
34/59

240324 회고 💬

송진 가루와 함께 올라간 기온으로 봄이 왔음이 완연해진 한주였다. 24년의 봄이 다가오는 3월 넷째 주를 되돌아본다.

Keep 👍

  • 알고리즘 풀이를 7일 연속으로 해냈다. 거기에 24년 3월 20일 기준으로 풀이 문제수 500을 달성했다. 😘 브론즈 문제가 300문제이지만 그럼에도! 500이라는 기념비적인 숫자를 달성했음에 기분이 좋다.
    - 빙고 문제를 풀었다. 2차원 배열 문제는 풀이 방법 떠올리기가 늘 쉽지 않다. 실버 4 수준의 문제였지만 생각보다 코드가 길게 나왔다. 짧게 짧게 코드를 만들 수 있을까 했는데 더이상은 줄일 수 없어서 아쉽게 됐다.
  • 토이프로젝트를 하기 전! 뭔가 핑계라면 핑계지만,,, 서블릿 공부에 재미가 들렸다. 그래서 오랜만에 깃허브 레포도 하나 만들었다. 아주 간단한 내용이라도 한 번에 해결하지 못했으면 트러블슈팅 내용으로 작성했다. 그리고 글보다는 가능하다면 그림을 보여주려고 마크다운에 그래프도 추가하려고 노력했다. 이번 기회로 서블릿 공부를 제대로 할 수 있으리라 기대한다. 이번 주에는 서블릿 생명주기를 공부했다.
  • 이번 주에는 어깨 운동을 했다. 작년에는 매일 운동했는데 요즘은 매일 운동은 힘들고, 못해도 격일에 운동할 수 있도록 신경 쓰고 있다.
  • "프로그래머의 길 멘토에게 묻다"를 계속 읽고 있다.
  • 출퇴근 공부도 진행했다. 이번 주에는 상속을 복습했다. 상속 관련해서 개념만 알고 있었지 사실 메모리 구조가 어떤 식으로 되어있는지는 몰랐다. 이번에라도 알게 되어 다행이다.

Problem 🤢

알고리즘 문제 풀이를 꾸준히 하고는 있다. 다른 개념 공부도 하고 싶은데 시간 분배가 어려워서 고민이 많다. 회사, 서블릿, 알고리즘 1문제 풀이가 끝나면 하루가 끝나기 때문이다. 주말 시간을 내서 공부를 해보려고 하지만 이래저래 일이 많아서 공부를 진득이 하지는 못하고 있다. (핑계임)
- 알고리즘 강의 복습은 회사 스터디 시간에 하려고 했지만, 회사 일정으로 스터디를 못하게 돼서 진행 못하고 있음
- CS 공부를 잠시 멈춰두고 토이 프로젝트를 시작하려고 했으나 서블릿 공부로 방향을 바꿈
한 가지 주제에 집중 못하고 이리저리 흔들리는 중이다.

Extras 😀

빙고

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            int[][] board = getInput(br);
            int[][] ip = getInput(br);
            Solution s = new Solution();
            System.out.println(s.solution(board, ip));

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[][] getInput(BufferedReader br) throws IOException {
        int[][] input = new int[5][5];

        for (int i = 0; i < input.length; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            for (int j = 0; j < input[i].length; j++) {
                input[i][j] = Integer.parseInt(st.nextToken());
            }
        }
        return input;
    }
}

class Solution {

    public int solution(int[][] board, int[][] input) {
        Calculator c = new Calculator(board, input);
        return c.getCnt();
    }

    class Calculator {

        int[][] board;
        boolean[][] check;
        int[][] input;
        int cnt = 0;

        public Calculator(int[][] board, int[][] input) {
            this.board = board;
            this.check = new boolean[board.length][board[0].length];
            this.input = input;
        }

        public int getCnt() {
            for (int i = 0; i < this.input.length; i++) {
                for (int j = 0; j < this.input[i].length; j++) {
                    check(this.input[i][j]);
                    if(isCompleted()) return this.cnt;
                }
            }
            return -1;
        }

        private void check(int num) {
            for (int i = 0; i < this.board.length; i++) {
                for (int j = 0; j < this.board[i].length; j++) {
                    if (this.board[i][j] == num) {
                        this.check[i][j] = true;
                        this.cnt++;
                    }
                }
            }
        }

        private boolean isCompleted() {
            int crossedLines = 0;
            for (int i = 0; i < this.board.length; i++) {
                int completeCnt1 = 0;
                int completeCnt2 = 0;
                for (int j = 0; j < this.board[i].length; j++) {
                    if(this.check[i][j]) completeCnt1++;
                    if(this.check[j][i]) completeCnt2++;
                }
                if(completeCnt1 == 5) crossedLines++;
                if(completeCnt2 == 5) crossedLines++;
            }

            int completeCnt3 = 0;
            int completeCnt4 = 0;
            for (int i = 0; i < this.board.length; i++) {
                if(this.check[i][i]) completeCnt3++;
                if(this.check[i][this.board[i].length - 1 - i]) completeCnt4++;
            }
            if(completeCnt3 == 5) crossedLines++;
            if(completeCnt4 == 5) crossedLines++;

            return crossedLines >= 3;
        }
    }

}
profile
What doesn't kill you, makes you stronger

0개의 댓글