문제풀이/Exercism
-
Exercism - Diamond(with.Kotlin)문제풀이/Exercism 2019. 8. 27. 09:48
[Instructions] The diamond kata takes as its input a letter, and outputs it in a diamond shape. Given a letter, it prints a diamond starting with 'A', with the supplied letter at the widest point. Requirements The first row contains one 'A'. The last row contains one 'A'. All rows, except the first and last, have exactly two identical letters. All rows have as many trailing spaces as leading spa..
-
Exercism - Largest Series Product (With.Kotlin)문제풀이/Exercism 2019. 8. 21. 20:51
[Instructions] Given a string of digits, calculate the largest product for a contiguous substring of digits of length n. For example, for the input '1027839564', the largest product for a series of 3 digits is 270 (9 * 5 * 6), and the largest product for a series of 5 digits is 7560 (7 * 8 * 3 * 9 * 5). Note that these series are only required to occupy adjacent positions in the input; the digit..
-
Exercism - Luhn(with.Kotlin)문제풀이/Exercism 2019. 8. 19. 14:34
[Instructions] Given a number determine whether or not it is valid per the Luhn formula. The Luhn algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers. The task is to check if a given string is valid. Validating a Number Strings of length 1 or less are not valid. Spaces are allowed in the in..
-
Exercism - Acronym(with.Kotlin)문제풀이/Exercism 2019. 8. 19. 00:37
[문제] Convert a phrase to its acronym. Techies love their TLA (Three Letter Acronyms)! Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). [Solution1] object Acronym { fun generate(phrase : String) : String{ val strList = phrase.replace("-", " ").split(" ").filter { it.isNotEmpty() } val expected = CharArray(strList.size) s..
-
Exercism - Perfect Numbers(with.Kotlin)문제풀이/Exercism 2019. 8. 17. 00:03
[문제] Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for natural numbers. The Greek mathematician Nicomachus devised a classification scheme for natural numbers, identifying each as belonging uniquely to the categories of perfect, abundant, or deficient based on their aliquot sum. The aliquot sum is defined as the sum of the facto..
-
Exercism - Difference Of Squares(with.Kotlin)문제풀이/Exercism 2019. 8. 6. 12:31
[문제] Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. The square of the sum of the first ten natural numbers is (1 + 2 + ... + 10)² = 55² = 3025. The sum of the squares of the first ten natural numbers is 1² + 2² + ... + 10² = 385. Hence the difference between the square of the sum of the first ten natural numbers and the sum of the squ..
-
Exercism - Scrabble Score (With.Kotlin)문제풀이/Exercism 2019. 7. 30. 14:35
[문제] Given a word, compute the scrabble score for that word. Letter Values You'll need these: Letter : Value A, E, I, O, U, L, N, R, S, T : 1 D, G : 2 B, C, M, P : 3 F, H, V, W, Y : 4 K : 5 J, X : 8 Q, Z : 10 Examples "cabbage" should be scored as worth 14 points: 3 points for C 1 point for A, twice 3 points for B, twice 2 points for G 1 point for E And to total: 3 + 2*1 + 2*3 + 2 + 1 = 3 + 2 + ..
-
Exercism - Space Age (With.Kotlin)문제풀이/Exercism 2019. 7. 26. 14:08
[문제] Given an age in seconds, calculate how old someone would be on: Earth: orbital period 365.25 Earth days, or 31557600 seconds Mercury: orbital period 0.2408467 Earth years Venus: orbital period 0.61519726 Earth years Mars: orbital period 1.8808158 Earth years Jupiter: orbital period 11.862615 Earth years Saturn: orbital period 29.447498 Earth years Uranus: orbital period 84.016846 Earth year..
-
Exercism - Gigasecond(With.Kotlin)문제풀이/Exercism 2019. 7. 23. 14:29
[문제] Given a moment, determine the moment that would be after a gigasecond has passed. A gigasecond is 10^9 (1,000,000,000) seconds. [Solution1] import java.time.LocalDate import java.time.LocalDateTime import java.time.LocalTime import java.time.temporal.ChronoUnit class Gigasecond { private val gigaSeconds = 1_000_000_000L val date: LocalDateTime constructor(localDate: LocalDate){ date = Local..
-
Exercism - Leap(With.Kotlin)문제풀이/Exercism 2019. 7. 22. 12:24
[문제] Given a year, report if it is a leap year. The tricky thing here is that a leap year in the Gregorian calendar occurs: on every year that is evenly divisible by 4 except every year that is evenly divisible by 100 unless the year is also evenly divisible by 400 For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap year, but 2000 is. Notes Though our exercise adopts some very ..