Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- jdbc
- 파이썬
- n^2 배열 자르기
- 이진 변환 반복하기
- javascript
- 입출력
- 코딩
- 프로그래밍
- 개발자
- js
- 셀레니움
- java
- 메모장
- 크롤링
- 개발
- 유튜브
- 세션
- 자바스크립트
- 파일 저장
- 모바일
- Programmers
- android
- MySQL
- 데이터베이스
- 함수형 인터페이스
- Python
- 형태소 분석기
- jsp
- 자바
- 프로그래머스
Archives
- Today
- Total
개인용 복습공간
프로그래머스 - 이진 변환 반복하기 본문
toString으로 이진 변환
function solution(s) {
let delemination = 0, trans = 0, cnt = 0;
while(s != 1){
delemination += s.replace(/1/g, '').length;
trans = s.replace(/0/g, '').length;
s = trans.toString(2);
cnt++;
}
return [cnt, delemination];
}
'programmers' 카테고리의 다른 글
프로그래머스 - n^2 배열 자르기 (0) | 2023.10.25 |
---|---|
프로그래머스 - 크레인 인형뽑기 게임 (0) | 2023.10.25 |
프로그래머스 - 키패드 누르기 (0) | 2023.10.12 |
프로그래머스 - H-Index (JavaScript, js) (0) | 2023.10.12 |
Comments