본문 바로가기

All Posts107

[2019.02.26] The Hurdle Race Problem Dan is playing a video game in which his character competes in a hurdle race. Hurdles are of varying heights, and Dan has a maximum height he can jump. There is a magic potion he can take that will increase his maximum height by unit for each dose. How many doses of the potion must he take to be able to jump all of the hurdles.Given an array of hurdle heights , and an initial maximum hei.. 2019. 2. 26.
[2019.02.25] Climbing the Leaderboard Problem Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking. The game uses Dense Ranking, so its leaderboard works like this:The player with the highest score is ranked number on the leaderboard.Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number.For exam.. 2019. 2. 25.
[2019.02.22] Picking Numbers Problem Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to . For example, if your array is , you can create two subarrays meeting the criterion: and . The maximum length subarray has elements.Function DescriptionComplete the pickingNumbers functio.. 2019. 2. 22.
[2019.02.20] Forming a Magic Square Problem We define a magic square to be an matrix of distinct positive integers from to where the sum of any row, column, or diagonal of length is always equal to the same number: the magic constant.You will be given a matrix of integers in the inclusive range . We can convert any digit to any other digit in the range at cost of . Given , convert it into a magic square at minimal cost. Print this.. 2019. 2. 20.
[2019.02.19] Cats and a Mouse Problem Two cats and a mouse are at various positions on a line. You will be given their starting positions. Your task is to determine which cat will reach the mouse first, assuming the mouse doesn't move and the cats travel at equal speed. If the cats arrive at the same time, the mouse will be allowed to move and it will escape while they fight.You are given queries in the form of , , and repre.. 2019. 2. 19.
[JavaScript공부 - 11] 조건 연산자 : if, '?' 가끔 코드를 짤 때, 다른 조건 마다 다른 동작이 나타나게 수행하도록 하고 싶은 경우가 있음! 이러한 동작을 시켜주기 위해서, 코드에서는 if 구문과 3항연산자인 물음표처럼 생긴 ? 기호로 쓰이는 조건 연산자를 사용할 수 있음. "if" 구문 if 구문은 조건을 적용한 다음 그 조건의 결과가 true이면 if 구문 안의 코드를 실행 시킴. 12345let year = prompt('In whtch year was ECMAScript-2015 specification published?'); if (year == 2015) { alert('You are right!');}Colored by Color Scriptercs 위의 예시로 보면 prompt에서 가져온 값이 2015와 같으면 You are righ.. 2019. 2. 18.
[2019.02.18] Electronics Shop Problem Monica wants to buy a keyboard and a USB drive from her favorite electronics store. The store has several models of each. Monica wants to spend as much as possible for the items, given her budget.Given the price lists for the store's keyboards and USB drives, and Monica's budget, find and print the amount of money Monica will spend. If she doesn't have enough money to both a keyboard and.. 2019. 2. 18.
[2019.02.15] Drawing Book Problem Brie’s Drawing teacher asks her class to open their books to a page number. Brie can either start turning pages from the front of the book or from the back of the book. She always turns pages one at a time. When she opens the book, page is always on the right side:When she flips page , she sees pages and . Each page except the last page will always be printed on both sides. The last page.. 2019. 2. 15.
[2019.02.14] Bon Appetit Problem Anna and Brian are sharing a meal at a restuarant and they agree to split the bill equally. Brian wants to order something that Anna is allergic to though, and they agree that Anna won't pay for that item. Brian gets the check and calculates Anna's portion. You must determine if his calculation is correct.For example, assume the bill has the following prices: . Anna declines to eat item .. 2019. 2. 14.