본문 바로가기

FOR78

1228. Kata Example Twist This is an easy twist to the example kata (provided by Codewars when learning how to create your own kata). Add the value "codewars" to the array websites/Websites 1,000 times. Solution: websites = ["codewars" for _ in range(1000)] websites = ["codewars"] * 1000 2022. 12. 28.
1205. Sum of Cubes Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum. Assume that the input n will always be a positive integer. Examples: (Input --> output) 2 --> 9 (sum of the cubes of 1 and 2 is 1 + 8) 3 --> 36 (sum of the cubes of 1, 2, and 3 is 1 + 8 + 27) Solution: int sumCubes(int n) { int result = 0; for (int i=1; i i * i * i); return l.sum; } 2022. 12. 5.
1203. String repeat Write a function that accepts an integer n and a string s as parameters, and returns a string of s repeated exactly n times. Examples (input -> output) 6, "I" -> "IIIIII" 5, "Hello" -> "HelloHelloHelloHelloHello" Solution: String repeatString(int n, String s) { String result = ''; for (int i=0; i s * n; 2022. 12. 4.
1202. Count by X Create a function with two arguments that will return an array of the first n multiples of x. Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array or list ( depending on language ). Examples countBy(1,10) === [1,2,3,4,5,6,7,8,9,10] countBy(2,5) === [2,4,6,8,10] Solution: List countBy(int x, int n) { List results = [.. 2022. 12. 2.
1201. Is the string uppercase? Is the string uppercase? Task Create a method to see whether the string is ALL CAPS. Examples (input -> output) "c" -> False "C" -> True "hello I AM DONALD" -> False "HELLO I AM DONALD" -> True "ACSKLDFJSgSKLDFJSKLDFJ" -> False "ACSKLDFJSGSKLDFJSKLDFJ" -> True In this Kata, a string is said to be in ALL CAPS whenever it does not contain any lowercase letter so any string containing no letters at.. 2022. 12. 1.
1122. Grasshopper - Messi goals function Messi goals function Messi is a soccer player with goals in three leagues: LaLiga Copa del Rey Champions Complete the function to return his total number of goals in all three leagues. Note: the input will always be valid. For example: 5, 10, 2 --> 17 Solution: int goals(int laLigaGoals, int copaDelReyGoals, int championsLeagueGoals) { return add_nums([laLigaGoals, copaDelReyGoals, championsLeag.. 2022. 11. 22.