일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- split
- Sorted
- or
- LOWER
- 위코드
- len
- Algorithm
- map
- and
- FOR
- If
- 파이썬
- STR
- sum
- range
- Python
- MAX
- enumerate
- decorator
- js
- slice
- DART
- WECODE
- list
- count
- join
- iNT
- SQL
- lambda
- index
- Today
- Total
목록FOR (78)
코드로 우주평화
Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are the Even numbers and Boys are the odd!alt!alt Task Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from the boys!alt!alt Notes Return an array/list where Even numbers come first then odds Since , Men are stronger than Boys , Then Even numbers in ascen..
Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [True, True, True, False, True, True, True, True , True, False, True, False, True, False, False, True , True, True, True, True , False, False, True, True] The correct answer would be 17. Hint: Don't forget to ..
I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 and 50. Example n = 3, so I expect a 3x3 square back just like below as a string: +++ +++ +++ Solution: def generate_shape(n: int) -> str: return "\n".join("+" * n for i in range(n))
altERnaTIng cAsE ALTerNAtiNG CaSe Define String.prototype.toAlternatingCase (or a similar function/method such as to_alternating_case/toAlternatingCase/ToAlternatingCase in your selected language; see the initial solution for details) such that each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. For example: "hello world".toAlternatingCase() === "HELLO WORLD" "HE..
Create a function that accepts a list/array and a number n, and returns a list/array of the first n elements from the list/array. Solution: def take(arr, n): result = [] arrs = [arr[i-1:i] for i in range(1, n+1)] for arr in arrs: result += arr return result
Write a function partlist that gives all the ways to divide a list (an array) of at least two elements into two non-empty parts. Each two non empty parts will be in a pair (or an array for languages without tuples or a structin C - C: see Examples test Cases - ) Each part will be in a string Elements of a pair must be in the same order as in the original array. Examples of returns in different l..
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
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; }
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;
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 = [..