Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# for cpp
a.out
54 changes: 54 additions & 0 deletions 190624/2580-sudoku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <iostream>
#include <map>

int b[9][9];

using namespace std;

vector<int> findNums(int i,int j) {
//map <int, bool> nums;
//checkv(i, nums);
//checkh(j, nums);
//checkbox(i,j, nums);
}

bool find = false;

void fillNums(int i, int j) {
if (find) return;
if (i == 9 && j == 9 && b[i][j] != 0) {
find = true;
return;
}

int jn = j < 9 ? j + 1: j;
int in = jn == j && i < 9; i + 1: i;

if (b[i][j] == 0) {
vector <int> nums = findNums(i,j);
if (nums.size() == 0) return;
for (auto n: nums) {
board[i][j] = n;
fillNums(in, jn);
}
}
return;
}

int main() {
char c;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
cin >> c;
b[i][j] = c - '0';
}
}
fillNums(0,0);
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
cout << b[i][j] << " ";
}
cout << "\n";
}
return 0;
}
9 changes: 9 additions & 0 deletions 190624/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0 3 5 4 6 9 2 7 8
7 8 2 1 0 5 6 0 9
0 6 0 2 7 8 1 3 5
3 2 1 0 4 6 8 9 7
8 0 4 9 1 3 5 0 6
5 9 6 8 2 0 4 1 3
9 1 7 6 5 2 0 8 0
6 0 3 7 0 1 9 5 2
2 5 8 3 9 4 7 6 0
6 changes: 6 additions & 0 deletions 200203/honux77/59415.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- 가장 최근에 동물이 들어온 날짜를 좋아하는 SQL 문
SELECT DATETIME FROM ANIMAL_INS ORDER BY DATETIME DESC LIMIT 1;

-- 다른 풀이
SELECT MAX(DATETIME) FROM ANIMAL_INS;

34 changes: 34 additions & 0 deletions 200203/ksundong/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 프로그래머스 - 체육복(https://programmers.co.kr/learn/courses/30/lessons/42862)
* 1. 일단 Test Case를 만들었다.
* 2. 일단 배열의 length값을 빼고 더해보았다. (test 1, 3 실패)
* 3. 만들어 둔 Test Case를 모두 만족하는 코드를 작성하였다.
* 4. 예외 상황이 있어서(조건을 제대로 안읽어서) 코드를 수정했다. (먼저 같은 경우를 비교)
*/
public class Solution {
// 전체 학생의 수 n, 도난당한 학생의 배열 lost, 여벌의 체육복을 가진 학생의 배열 reserve
public int solution(int n, int[] lost, int[] reserve) {
n -= lost.length;
for (int i = 0; i < lost.length; i++) {
for (int j = 0; j < reserve.length; j++) {
if (lost[i] == reserve[j]) {
n++;
lost[i] = 32;
reserve[j] = -1;
break;
}
}
}
for (int i = 0; i < lost.length; i++) {
for (int j = 0; j < reserve.length; j++) {
if (lost[i] == reserve[j] + 1 || lost[i] == reserve[j] - 1) {
n++;
lost[i] = 32;
reserve[j] = -1;
break;
}
}
}
return n;
}
}
63 changes: 63 additions & 0 deletions 200203/ksundong/SolutionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class SolutionTest {
Solution solution;

@BeforeEach
void setUp() {
solution = new Solution();
}

@Test
void testSolution1() {
int n = 5;
int[] lost = {2, 4};
int[] reserve = {1, 3, 5};
int expected = 5;
int actual = solution.solution(n, lost, reserve);
assertEquals(expected, actual, "예상 출력과 다릅니다.");
}

@Test
void testSolution2() {
int n = 5;
int[] lost = {2, 4};
int[] reserve = {3};
int expected = 4;
int actual = solution.solution(n, lost, reserve);
assertEquals(expected, actual, "예상 출력과 다릅니다.");
}

@Test
void testSolution3() {
int n = 3;
int[] lost = {3};
int[] reserve = {1};
int expected = 2;
int actual = solution.solution(n, lost, reserve);
assertEquals(expected, actual, "예상 출력과 다릅니다.");
}

@Test
void testSolution4() {
int n = 5;
int[] lost = {4, 5};
int[] reserve = {4};
int expected = 4;
int actual = solution.solution(n, lost, reserve);
assertEquals(expected, actual, "예상 출력과 다릅니다.");
}

@Test
void testSolution5() {
int n = 10;
int[] lost = {3, 9, 10};
int[] reserve = {3, 8, 9};
int expected = 9;
int actual = solution.solution(n, lost, reserve);
assertEquals(expected, actual, "예상 출력과 다릅니다.");
}
}
2 changes: 2 additions & 0 deletions 200204/honux/59035.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- 역순 정렬
SELECT NAME, DATETIME FROM ANIMAL_INS ORDER BY ANIMAL_ID DESC;
56 changes: 56 additions & 0 deletions 200204/honux/60057-Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//programmers 60057 카카오 공채 문자열 압축
//어렵진 않은데 시간이 오래 걸렸다.

import java.util.List;
import java.util.ArrayList;

class Solution {

private List<String> cutString(String origin, int size) {
List<String> ret = new ArrayList<>();
for (int i = 0; i < origin.length(); i += size) {
int e = (i + size) > origin.length() ? origin.length(): i + size;
String str = origin.substring(i, e);
ret.add(str);
}
return ret;
}

private String findCompressString(String str, int size) {
List<String> slist = cutString(str, size);

int count = 0;
StringBuffer newStr = new StringBuffer();

String prev = slist.get(0);
newStr.append(prev);
int repeat = 1;
for (int i = 1; i < slist.size(); i++) {
String curr = slist.get(i);
if(curr.equals(prev)) {
repeat++;
} else {
if (repeat != 1) {
newStr.append(Integer.toString(repeat));
repeat = 1;
}
newStr.append(curr);
prev = curr;
}
}

if (repeat != 1) {
newStr.append(Integer.toString(repeat));
}
return newStr.toString();
}

public int solution(String s) {
int ans = s.length();
for(int i = 1; i < s.length(); i++) {
ans = Math.min(ans, findCompressString(s, i).length());
}
return ans;
}
}

20 changes: 20 additions & 0 deletions 200204/ksundong/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 프로그래머스 2016년 - https://programmers.co.kr/learn/courses/30/lessons/12901
* - Test Case를 하나 만들었다.
* - 너무 쉬웠다. 역시 CodeSquad Java Playground!
* - https://www.inflearn.com/course/java-codesquad/dashboard
*/
public class Solution {
public String solution(int a, int b) {
String[] dayOfWeek = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int dateCount = 5;
int[] monthDayArray = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

for (int i = 0; i < a - 1; i++) {
dateCount += monthDayArray[i];
}
dateCount += b - 1;

return dayOfWeek[dateCount % 7];
}
}
31 changes: 31 additions & 0 deletions 200204/ksundong/SolutionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class SolutionTest {
Solution solution;

@BeforeEach
void setUp() {
solution = new Solution();
}

@Test
void testSolution1() {
int month = 5;
int date = 24;
String expected = "TUE";
String actual = solution.solution(month, date);
assertEquals(expected, actual, "원하는 요일명과 일치하지 않습니다.");
}

@Test
void testSolution2() {
int month = 1;
int date = 1;
String expected = "FRI";
String actual = solution.solution(month, date);
assertEquals(expected, actual, "원하는 요일명과 일치하지 않습니다.");
}
}
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# algorithm-practice
2019 코드스쿼드 백엔드 알고리즘 연습 저장소

2020 코드스쿼드 백엔드 알고리즘 연습 저장소

## 커밋하기

- 이 저장소를 포크한다.
- 문제를 풀고 커밋한다. 단 아래의 폴더구조를 따라 문제풀이를 작성한다.

날짜/GitHubId/문제풀이.확장자

예) 20200203/honux77/Runner.java

- 주석 등을 이용해 문제의 출처를 기입할 것

## 푸시 및 풀리퀘

- 충돌이 나지 않고 병합이 가능할 것
- 폴더 구조 규칙을 지킬 것
- 위 사항을 만족하면 풀리퀘는 리뷰 없이 머지된다.

## 통계보기

- 주기적으로 통계를 통해 자신의 커밋수를 확인하고 열심히 풀어보자