반응형

분류 전체보기 723

[TS] TypeScript Exercises 5 해석 및 풀이

Intro Filtering requirements have grown. We need to be able to filter any kind of Persons. 필터링 요구사항이 늘었습니다. 이제 Person의 모든 종류를 구분해야합니다. Exercise Fix typing for the filterPersons so that it can filter users and return User[] when personType='user' and return Admin[] when personType='admin'. Also filterPersons should accept partial User/Admin type according to the personType. `criteria` argument sh..

[DreamHack] 드림핵 웹해킹 : file-download-1

https://dreamhack.io/wargame/challenges/37/ file-download-1 File Download 취약점이 존재하는 웹 서비스입니다. flag.py를 다운로드 받으면 플래그를 획득할 수 있습니다. Reference Introduction of Webhacking dreamhack.io 문제 File Download 취약점이 존재하는 웹 서비스입니다. flag.py를 다운로드 받으면 플래그를 획득할 수 있습니다. 문제파일 더보기 #!/usr/bin/env python3 import os import shutil from flask import Flask, request, render_template, redirect from flag import FLAG APP = Fla..

[TS] type-challenges: 43. Exclude

문제 T에서 U에 할당할 수 있는 타입을 제외하는 내장 제네릭 Exclude를 이를 사용하지 않고 구현하세요. type Result = MyExclude // 'b' | 'c' 풀이 타입이 아닌 단순 문제였다고 생각해보자 function MyExclude(T, U) { if(T === U) return; else return T; } 이런 느낌이다. T에 해당하는 타입들중 U와 같은 타입이 있다면 그건 반환하지 않고, 같지 않다면 반환하는 로직이다. 타입스크립트에서 ===에 해당하는 부분은 extends로 대체 가능하고 아무것도 반환하지 않는 경우는 never 이라는 타입으로 쓸 수 있겠다. type MyExclude = T extends U ? never : T; 출처 https://github.com..

[TS] TypeScript Exercises 5 해석 및 풀이

Intro Time to filter the data! In order to be flexible we filter users using a number of criteria and return only those matching all of the criteria. We don't need Admins yet, we only filter Users. 데이터를 선별할 차례입니다! 보다 유연해지기 위해 우리는 기준을 표시하는 숫자를 이용하여 유저들을 필터링하고, 오직 이 모든 기준에 맞는 유저들만 리턴해야합니다. 아직 Admin들은 필요하지 않고 User들만 필터링하면 됩니다. Exercise Without duplicating type structures, modify filterUsers functio..

[프로그래머스][JS / Javascript] 땅따먹기

https://school.programmers.co.kr/learn/courses/30/lessons/12913 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 백준 9465번 스티커 문제와 상당히 유사하다 두 줄 짜리 스티커가 네 줄 짜리 땅으로 바뀌었을 뿐.. [💠 Class를 밀어보자/Class 4] - [BOJ][C++] 백준 9465번: 스티커 동적계획법(Dynamic Programming, DP)를 이용한다. dp[i][j] 는 i행 j열까지 뛰었을 때 얻을 수 있는 최대 점수를 의미한다 바로 직전 줄에서 자신과 같은 열을 제외한 모든(3개) ..

[BOJ][C++] 백준 14888번: 연산자 끼워넣기

https://www.acmicpc.net/problem/14888 14888번: 연산자 끼워넣기 첫째 줄에 수의 개수 N(2 ≤ N ≤ 11)가 주어진다. 둘째 줄에는 A1, A2, ..., AN이 주어진다. (1 ≤ Ai ≤ 100) 셋째 줄에는 합이 N-1인 4개의 정수가 주어지는데, 차례대로 덧셈(+)의 개수, 뺄셈(-)의 개수, 곱 www.acmicpc.net 문제 N개의 수로 이루어진 수열 A1, A2, ..., AN이 주어진다. 또, 수와 수 사이에 끼워넣을 수 있는 N-1개의 연산자가 주어진다. 연산자는 덧셈(+), 뺄셈(-), 곱셈(×), 나눗셈(÷)으로만 이루어져 있다. 우리는 수와 수 사이에 연산자를 하나씩 넣어서, 수식을 하나 만들 수 있다. 이때, 주어진 수의 순서를 바꾸면 안 된..

[DreamHack] 드림핵 웹해킹: command-injection-1

https://dreamhack.io/wargame/challenges/44/ command-injection-1 특정 Host에 ping 패킷을 보내는 서비스입니다. Command Injection을 통해 플래그를 획득하세요. 플래그는 flag.py에 있습니다. Reference Introduction of Webhacking dreamhack.io 문제 특정 Host에 ping 패킷을 보내는 서비스입니다. Command Injection을 통해 플래그를 획득하세요. 플래그는 flag.py에 있습니다. 문제파일 더보기 #!/usr/bin/env python3 import subprocess from flask import Flask, request, render_template, redirect fro..

[프로그래머스][SQL] 그룹별 조건에 맞는 식당 목록 출력하기

https://school.programmers.co.kr/learn/courses/30/lessons/131124 MEMBER_PROFILE와 REST_REVIEW 테이블에서 리뷰를 가장 많이 작성한 회원의 리뷰들을 조회하는 SQL문을 작성해주세요. 회원 이름, 리뷰 텍스트, 리뷰 작성일이 출력되도록 작성해주시고, 결과는 리뷰 작성일을 기준으로 오름차순, 리뷰 작성일이 같다면 리뷰 텍스트를 기준으로 오름차순 정렬해주세요. 풀이 먼저 가장 많은 리뷰수를 작성한 사람을 알아내자 select member_id from rest_review group by member_id order by count(review_id) desc limit 1 이제 이 멤버가 작성한 리뷰들을 골라낸다 limit 연산이 들어간 ..

[TS] type-challenges: 18. Length of Tuple

문제 배열(튜플)을 받아 길이를 반환하는 제네릭 Length를 구현하세요. type tesla = ['tesla', 'model 3', 'model X', 'model Y'] type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT'] type teslaLength = Length // expected 4 type spaceXLength = Length // expected 5 풀이 type Length = T['length']; 간단하게 이렇게 표현했더니 Type 'readonly ["tesla", "model 3", "model X", "model Y"]' does not satisfy the constrai..

[TS] TypeScript Exercises 4 해석 및 풀이

Intro As we introduced "type" to both User and Admin it's now easier to distinguish between them. Once object type checking logic was extracted into separate functions isUser and isAdmin - logPerson function got new type errors. 유저와 어드민에 대해 type을 소개했듯이, 이제 이 둘을 구분하는건 쉬워졌습니다. 로직을 검사하는 객체 타입을 추출해서 isUser과 isAdmin 함수에 분리해서 넣었더니 logPerson 함수에 새로운 타입에러가 생겼습니다 Exercise Figure out how to help TypeScrip..

반응형