본문 바로가기

algorithm/codewars

(14)
[6kyu] multiples of 3 or 5 문제 설명 Description:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.Note: If the number is a multiple of both 3 and 5, only count it once. 나의풀이 function solution(number){ var sum = 0; for(var i = 1; i
[6kyu] TGI Friday !! 문제설명We all love fridays, and even better if it is the last day of the month!In this kata you should write a function that will receive 2 parameters. Both are years, and indicates a range.Your work is to return the number of times a month ends with a Friday.If there is only one year provided, return the number of times a month ends on Friday on that year. Range bounds are inclusive in every case!..
[8kyu] Century_From_Year !!!!!!!!!! 문제설명 Description:Given a year, return the century it is in.The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.Let's see some examples:centuryFromYear(1705) // returns 18 centuryFromYear(1900) // returns 19 centuryFromYear(1601) // returns 17 centuryFromYear(2000) // returns 20 Hope you enjoy it .. Awaitin..
[6kyu] Good vs Evil 문제설명 DescriptionMiddle Earth is about to go to war. The forces of good will have many battles with the forces of evil. Different races will certainly be involved. Each race has a certain worth when battling against others. On the side of good we have the following races, with their associated worth:Hobbits: 1Men: 2Elves: 3Dwarves: 3Eagles: 4Wizards: 10On the side of evil we have:Orcs: 1Men: 2War..
[8kyu] Array plus array 문제 설명 Description:I'm new to coding and now I want to get the sum of two arrays...actually the sum of all their elements. I'll appreciate for your help.P.S. Each array includes only integer numbers. Output is a number too. 나의 풀이 function arrayPlusArray(arr1, arr2) { return arr1.reduce(function (a,b){ return a+b; },0) + arr2.reduce(function (a,b){ return a+b; },0); //something went wrong } 다른사람의 ..
[7kyu] Sum of Triangular Numbers Description:Your task is to return the sum of Triangular Numbers up-to-and-including the nth Triangular Number.Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc."[01] 02 [03] 04 05 [06] 07 08 09 [10] 11 12 13 14 [15] 16 17 18 19 20 [21] e.g. If 4 is given: 1 + 3 + 6 + 10 = 20.Triangular Numbers canno..