전체 글
-
항해 99 5기 TIL_10항해 99 2022. 1. 19. 14:34
▶ Today I Learned [하샤드 수] https://programmers.co.kr/learn/courses/30/lessons/12947 소요시간: 14분 13초 내가 짠 코드 function solution(x) { let arr = x.toString().split('') let divisionNum = arr.reduce((acc, cur) => acc/1 + cur/1) return x % divisionNum == 0 ? true : false } 변수명도 잘 썼고 비교적 간단하게 구현한 것 같다. 이렇게하면 양의 정수가 몇이 나오던 상관없이 알맞은 답을 구할 수 있다. 이것보다도 효율적인 코드가 있을까? 예를 들어 숫자를 문자열로 바꾸어 연산하는 것이 없다던가..? 프로그래머스 답안..
-
항해 99 5기 TIL_9항해 99 2022. 1. 18. 22:04
▶ Today I Learned [컴퓨터와 인간의 소통] 우리는 말 소리로도 이야기를 나눌 수 있지만 컴퓨터는 오직 문자로 소통해야한다. 컴퓨터에게도 문자가 있고 인간에게도 문자가 있다. 하지만 둘은 문자는 통하지 않기에 인간이 컴퓨터 언어를 배워 소통해야 한다. 그렇다면 언어를 담을 곳이 필요하고 컴퓨터에서는 그게 비트가 된다. 비트에는 0이나 1과 같은 값이 담기지만 사실 기호가 무엇이 되었든 간에 1) Yes or No가 확실히 나뉠 것, 2) 문맥상 의미가 통할 것 이 두 가지가 잘 지켜진다면 소통에는 지장이 없을 것이다. [드모르간 법칙] 드모르간 법칙은 A and B 와 Not(Not A or Not B)가 서로 같다는 것이다. 예를 들어, 철수는 방학이고 겨울이면 스키를 타러간다. 는 명제가..
-
항해 99 5기 TIL_8항해 99 2022. 1. 18. 02:05
▶ Today I Learned [문자열 내 p와 y의 개수] https://programmers.co.kr/learn/courses/30/lessons/12916 소요시간: 18분 42초 처음 짰던 코드 function solution(s){ let upperS= s.toUpperCase() let i = 0 let countP = 0 let countY = 0 var arr = [...upperS] // 이렇게하면 문자열이 하나씩 나눠지는 배열이 된다. // 물론 반복문을 써서 하나하나 집어넣어도 되고 Array.from이라는 방법도 있다. //여기서 사용한 방법은 확산연산자이다. for (i ; i < arr.length ; i++) { arr[i] == 'P' ? countP++ : arr[i] ..
-
항해 99 5기 WIL_1항해 99 2022. 1. 16. 17:15
▶ Weekly I Learned (회고) 미니 프로젝트 (메인페이지 위주 담당) : 4일간의 짧고 굵은 프로젝트였다. 처음 기획한 와이어 프레임에는 미치지 못하는 사이트를 구현해냈다. 비록 힘들기도 했고 자괴감도 들었지만 즐거웠다. 내가 고민하고 생각해서 기능과 틀을 짜고 그것을 실제로 사용할 수 있다니.. 이전에는 겪어보지 못한 새로운 경험이었다. 좋았던 것은 스스로의 개발실력 부족과 협업 능력 부족을 인지했다. 이후 프로젝트에는 내 업무를 어느정도 하면서도 팀원들의 업무에도 좀 더 관심을 갖고 도움을 줄 수 있도록 노력할 것이다. 또 상대가 말할 때는 좀 더 귀 기울여 듣고 전체적인 흐름이 어떻게 되는지를 고려해야겠다. 또한 소통을 명확히 하여야겠다. 구현할 때 무언가를 이렇게 하자고 말은 했지만 ..
-
항해 99 5기 TIL_7항해 99 2022. 1. 16. 15:10
▶ Today I Learned 일주일 간 배웠던 내용들을 짚어보고 다시 한 번 정리하였다. 상세한 내용이 궁금하다면 WIL_1을 보면 된다. [x만큼 간격이 있는 n개의 숫자] https://programmers.co.kr/learn/courses/30/lessons/12954 소요시간: 12분 53초 처음 작성한 코드 function solution(x, n) { let i = 0; let adding = 0; var answer = [] for (i; i < n ; i++) { adding = adding + x answer[i] = adding } return (answer) } 매우 많이 쓰이는 패턴이고 깔끔하다. 더 효율적인 방법은 없을까?? reduce 구문이 바로 생각났다. 그런데 지난번 ..
-
항해 99 5기 TIL_6항해 99 2022. 1. 15. 12:37
▶ Today I Learned [음양 더하기] https://programmers.co.kr/learn/courses/30/lessons/76501 소요시간: 1시간 1분 function solution(absolutes, signs) { let totalValue = '' let answer = 0 // 배열의 값들을 어떻게 다루는 건 기본적으로 반복문을 사용함 for (let i = 0; i < signs.length; i++) { let sign = (signs[i] === true ? '+' : '-') // 부호를 어떻게 대입하지?? 부호는 일단 Number타입인듯 // 하지만 삼항 연산자에는 곧바로 쓸 수 없음, 일단 문자열로 전환 totalValue = sign + absolutes[i]...
-
항해 99 5기 TIL_5항해 99 2022. 1. 14. 14:46
▶ Today I Learned https://programmers.co.kr/learn/courses/30/lessons/12903?language=javascript [가운데 글자 가져오기] 단어의 가운데 글자를 반환하는 함수, solution을 만들어 보세요. 단어의 길이가 짝수라면 가운데 두글자를 반환하면 됩니다. let word = "123456789" // 출력할 임의의 문자열 // 문자열의 길이를 구한 후 이를 2로 나누어 나머지가 없으면 짝수, 있다면 홀수 if (word.length%2 == 0) { let start_index = word.length/2 //문자열의 길이를 2로 나누면 문자열에서 중간정도 위치 값을 구할 수 있음 위 숫자를 substring()에 대입 substring..
-
항해 99 5기 TIL_4항해 99 2022. 1. 14. 02:20
▶ Today I Learned 프로젝트 시 메인 페이지 하단에 카드들을 배치하려 했다. 이를 깔끔히 정렬하기 위해 아래와 같이 코드를 작성하였다. .posting-card { width: 350px; height: 600px; border-radius: 1rem; } .post-box { /* 쇼핑몰 상세페이지 처럼 글의 일부만 보이는 css, 그라데이션 효과 삽입*/ display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-gap: 20px; margin: auto; align-items: start; } grid라는 말 답게 격자 형태로 담겨졌다. 문제는 보기에 깔끔하긴 하지만 카드들이 사이트를 기준으로 중앙 정렬이 되진 않았다는 것이다. 이를 구현..