Skip to content

Commit

Permalink
remove fizzbuzz const in kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ythirion committed Jan 5, 2024
1 parent 158a566 commit ee82360
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 54 deletions.
9 changes: 3 additions & 6 deletions exercise/kotlin/day06/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String {
Expand All @@ -14,9 +11,9 @@ object FizzBuzz {

private fun convertSafely(input: Int): String {
return when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}
}
Expand Down
9 changes: 3 additions & 6 deletions exercise/kotlin/day10/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String {
Expand All @@ -14,9 +11,9 @@ object FizzBuzz {

private fun convertSafely(input: Int): String {
return when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}
}
Expand Down
9 changes: 3 additions & 6 deletions exercise/kotlin/day14/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String {
Expand All @@ -14,9 +11,9 @@ object FizzBuzz {

private fun convertSafely(input: Int): String {
return when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}
}
Expand Down
9 changes: 3 additions & 6 deletions exercise/kotlin/day17/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import arrow.core.Some

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): Option<String> = when {
Expand All @@ -17,9 +14,9 @@ object FizzBuzz {
}

private fun convertSafely(input: Int): String = when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}

Expand Down
9 changes: 3 additions & 6 deletions solution/kotlin/day02/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String {
Expand All @@ -14,9 +11,9 @@ object FizzBuzz {

private fun convertSafely(input: Int): String {
return when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}
}
Expand Down
9 changes: 3 additions & 6 deletions solution/kotlin/day06/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String = when {
isOutOfRange(input) -> throw OutOfRangeException()
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}

Expand Down
9 changes: 3 additions & 6 deletions solution/kotlin/day10/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package games

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): String = when {
isOutOfRange(input) -> throw OutOfRangeException()
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}

Expand Down
9 changes: 3 additions & 6 deletions solution/kotlin/day14/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import arrow.core.Some

private const val MIN = 0
private const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): Option<String> = when {
Expand All @@ -17,9 +14,9 @@ object FizzBuzz {
}

private fun convertSafely(input: Int): String = when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}

Expand Down
9 changes: 3 additions & 6 deletions solution/kotlin/day17/src/main/kotlin/games/FizzBuzz.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import arrow.core.Some

const val MIN = 1
const val MAX = 100
private const val FIZZBUZZ = 15
private const val FIZZ = 3
private const val BUZZ = 5

object FizzBuzz {
fun convert(input: Int): Option<String> = when {
Expand All @@ -17,9 +14,9 @@ object FizzBuzz {
}

private fun convertSafely(input: Int): String = when {
`is`(FIZZBUZZ, input) -> "FizzBuzz"
`is`(FIZZ, input) -> "Fizz"
`is`(BUZZ, input) -> "Buzz"
`is`(15, input) -> "FizzBuzz"
`is`(3, input) -> "Fizz"
`is`(5, input) -> "Buzz"
else -> input.toString()
}

Expand Down

0 comments on commit ee82360

Please sign in to comment.