
문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 중복 제거를 위해 집합의 성질을 활용하면 쉽게 풀 수 있다. const solution = (input) => new Set(input.map((s) => +s % 42)).size; const input = []; require('readline') .createInterface({ input: process.stdin }) .on('line', (line) => input.push(line)) .on('close', (_) => { console.log(solution(input)); process.exit(0); }); 전체 코드 https://github.com/bluemiv/Algorithm/blo..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 입력받은 숫자의 곱을 구하고, 각 숫자가 몇개씩 들어갔는지 출력하는 문제이다. 대부분 곱을 구한뒤에 문자열로 치환해서 이터레이션 돌면서 값을 구할거 같다는 생각이 들어서(아님 말고), 본 글에서는 나눗셈과 나머지 연산을 사용하여 문제를 풀었다. const solution = (input) => { let rs = input.reduce((acc, s) => acc * +s, 1); const numTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; while (rs > 0) { numTable[rs % 10]++; rs = parseInt(rs / 10); } return numTable..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 단순히 최댓값을 구하는 문제라면, Math.max() 함수를 사용하면 좋겠지만, 몇번째 숫자인지도 구해야하기 때문에, 이터레이션을 통해 문제를 풀었다. const solution = (input) => input .map((s) => +s) .reduce( (rs, n, idx) => { if (rs[0] < n) { rs[0] = n; rs[1] = idx + 1; } return rs; }, [-Infinity, -1] ) .join('\n'); const input = []; require('readline') .createInterface({ input: process.stdin }) .on('lin..

간단하게 만든다면 InkWell과 Container로 만들 수 있다. Gradient Button 쉽게 구현 코드 구현 import 'dart:developer'; import 'package:flutter/material.dart'; class GradientButton extends StatelessWidget { const GradientButton({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: () { log("Gradient button clicked!"); }, child: Container( padding: const EdgeInsets.all(20), dec..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 두 자리수를 십의 자리와 일의 자리로 나눠서 덧셈을 하는 문제이다. 나눗셈과 나머지 연산을 이용하여, 자릿수를 잘 조작할 수 있는지 확인 하는 문제 같다. const solution = (input) => { const n = +input; if (n === 0) return 1; let cnt = 0; let nn = n; while (true) { cnt++; const a = parseInt(nn / 10); const b = nn % 10; const c = (a + b) % 10; nn = b * 10 + c; if (n === nn) break; } return cnt; }; const print..

다양한 방법으로 CircleAvatar를 사용하면, 원형의 이미지를 만들 수 있다. 인스타 그램을 보면 아바타 겉에 그라데이션 border 효과가 들어가 있다. (아래 사진 참고) 구현 방법 우선 CircleAvatar를 사용하여, 원형의 아바타를 만든다. import 'package:flutter/material.dart'; class GradientBorderCircleAvatar extends StatelessWidget { const GradientBorderCircleAvatar({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return CircleAvatar( radius: 250, background..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 단순히 입력 받아서 두 수를 더한 값을 출력해주면 되는 간단한 문제이다. const solution = (input) => input .map((l) => { const [a, b] = l.split(' ').map((s) => +s); return a + b; }) .join('\n'); const input = []; require('readline') .createInterface({ input: process.stdin }) .on('line', (line) => input.push(line)) .on('close', (_) => { console.log(solution(input)); process..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 const solution = (input) => { let findZero = false; const nums = input.reduce((acc, l) => { if (findZero) return acc; if (l === '0 0') { findZero = true; } else { acc.push(l.split(' ').map((s) => +s)); } return acc; }, []); return nums .slice(0, nums.length) .map((n) => n[0] + n[1]) .join('\n'); }; const input = []; require('readline') .crea..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 첫째 줄과 두번째 줄을 입력받고 미리 정수형으로 파싱하고 문제를 풀었다. 리스트의 filter 함수를 이용하여, X보다 작은 수를 필터링했다. const solution = (input) => { const [l1, l2] = input.map((l) => l.split(' ').map((s) => +s)); return l2 .slice(0, l1[0] + 1) .filter((n) => n < l1[1]) .join(' '); }; const input = []; require('readline') .createInterface({ input: process.stdin }) .on('line', (lin..

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 앞에 여백과 * 를 합쳐주면 되는 간단한 문제이다. repeat() 함수를 이용하면 좀 더 깔끔하게 풀 수 있다. const solution = (input) => [...Array(+input).keys()] .reduce((acc, n) => { acc.push([' '.repeat(+input - n - 1), '*'.repeat(n + 1)].join('')); return acc; }, []) .join('\n'); const print = (input) => console.log(solution(input + '')); process.stdin.on('data', print); 전체 코드 http..