Skip to content

Instantly share code, notes, and snippets.

View emayom's full-sized avatar
👋

emayom emayom

👋
View GitHub Profile
@emayom
emayom / ternary_01.js
Last active August 17, 2021 04:33
[프로그래머스] 3진법 뒤집기
// solution 1.
function solution(n) {
let tern = [];
let dec = 0;
do {
tern.push(n%3);
n = Math.floor(n/3);
} while(n>2)
@emayom
emayom / matrix_multiplication_01.js
Created August 20, 2021 03:13
[프로그래머스] 행렬의 곱셈
function solution(arr1, arr2) {
const m = arr1.length;
const k = arr1[0].length;
const n = arr2[0].length;
let answer = [];
for(let i = 0; i < m; i++){
let temp = [];
@emayom
emayom / click_event.js
Last active August 23, 2021 08:52
JS event callback()
//onclick() 작성 시
window.onclick = function(event) {
alert("Hello!");
}
//addEventListener() 작성 시
window.addEventListener("click", (event) => {
alert("Hello!");
});
@emayom
emayom / correct_ parentheses_01.js
Created August 22, 2021 06:37
[프로그래머스] 올바른 괄호
function solution(s){
s = s.split('()').join('');
const x = s.length;
if(s[0] == ")" || s[x-1] == "("){
return false;
} else {
let cnt = 0;
s = s.split('');
@emayom
emayom / max_min_01.js
Created August 22, 2021 07:03
[프로그래머스] 최댓값과 최솟값
function solution(s) {
s = s.split(' ').sort((a,b) => a-b);
let answer = [(s[0]), s[s.length-1]];
return answer.join(' ');
}
@emayom
emayom / stack_solution_01.js
Created August 22, 2021 07:47
[프로그래머스] 기능개발
function solution(progresses, speeds) {
let answer = progresses.map((el, index) => Math.ceil((100 - el) / speeds[index]));
const LENGTH = answer.length;
let temp = [];
let cnt = 1;
let max = answer[0];
for(let i = 1; i < LENGTH; i++){
if(max >= answer[i]){
@emayom
emayom / next_01.js
Last active August 23, 2021 05:55
[프로그래머스] 다음 큰 숫자
//solution 01
function solution(n) {
function cnt(number) {
return number.toString(2)
.match(/1/g)
.length;
}
const n_cnt = cnt(n);
let start = n;
@emayom
emayom / arry_from.html
Last active August 24, 2021 00:49
[ES6] Array.from() NodeList -> object Array
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>apple</li>
<li>orange</li>
@emayom
emayom / brute_force_search_01.js
Last active August 24, 2021 05:01
[프로그래머스] 모의고사
// solution 1
function solution(answers) {
const submit = ["12345", "21232425", "3311224455"];
function cnt(submit) {
const A_LENGTH = answers.length;
const S_LENGTH = submit.length;
if(A_LENGTH > S_LENGTH){
@emayom
emayom / weekly_field_01.js
Last active August 25, 2021 02:35
[프로그래머스] 위클리챌린지 직업군 추천하기
function solution(table, languages, preference) {
const FIELD = ["SI", "CONTENTS", "HARDWARE", "PORTAL", "GAME"];
const separate = [];
const count = [];
let answer = [];
for(let i of table){
let temp = i.split(' ');
separate.push(temp.slice(1));