1. 오늘 한 일
알고리즘 시험(6/6)
react localstorage 이용해서 다크모드 상태 저장하기.
기술매니저님 미팅
랜선 술자리
2. 토요일까지 할일
토요일 9시 리엑트 스터디 -> 페이지네이션
3. 일요일까지 할일
시간포멧 라이브러리
firebase -> 로그인 기능
json server API DB
변수명 정리
라우터 -> 상세정보
useEffect, useState 정리
오늘 푼 문제 답안
function solution(n) {
let array = n.toString().split('').reverse(); //문자열화->배열화->뒤집기
const sum = array.reduce((acc, curr) => acc + Number(curr), 0); //합계 계산
return array.join('+').concat('=').concat(sum); //뒤집은 배열사이에 +넣고 문자열화, 뒤에 =, sum 붙이기
}
console.log(`"${solution(718253)}"`)
function solution(star) {
const space = ' ';
const starletter = '*';
let num = 1; //별 처음 갯수 1개 선언
for (let i = 0; i < star; i++) {
const spaces = space.repeat(star - 1 - i); //공백 갯수 선언
const stars = starletter.repeat(num); //별 갯수 선언
console.log(spaces + stars + spaces); //출력
num += 2; //별 갯수 +2
}
}
let star = 9;
solution(star)
function solution(arr1) {
for (let i = 0; i < arr1.length; i++) {
console.log(search(arr1, i, arr1.length)); //한줄씩 함수로 계산해서 반환값 출력
}
function search(a, i, line) {
let tempAnswer = [];
for (let j = 0; j < line; j++) {
let compare = 0;
if (i > 0) { //첫줄이 아닐때만
if (a[i - 1][j] > compare) compare = a[i - 1][j];
}
if (j > 0) { //첫글자가 아닐때만
if (a[i][j - 1] > compare) compare = a[i][j - 1];
}
if (i < line - 1) { //마지막줄이 아닐때만
if (a[i + 1][j] > compare) compare = a[i + 1][j];
}
if (j < line - 1) { //마지막글자가 아닐때만
if (a[i][j + 1] > compare) compare = a[i][j + 1];
}
if (a[i][j] > compare) { //숫자가 더 크면 * temp에 push
tempAnswer.push('*');
} else { //아니면 그대로 temp에 push
tempAnswer.push(a[i][j]);
}
}
return tempAnswer.join(' '); //한줄 완료되면 길이1의 공백을 끼워 합쳐서 반환
}
}
let arr1 = [[7, 4, 6, 5, 9], [6, 1, 3, 4, 5], [4, 8, 5, 6, 9], [1, 3, 0, 6, 4], [6, 4, 8, 1, 7]];
solution(arr1)