2nd commit
This commit is contained in:
parent
8bda4fa726
commit
abc35536e4
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,6 +14,7 @@ project/local-plugins.sbt
|
|||||||
.ensime_cache/
|
.ensime_cache/
|
||||||
.sbt-scripted/
|
.sbt-scripted/
|
||||||
local.sbt
|
local.sbt
|
||||||
|
inputs
|
||||||
|
|
||||||
# Bloop
|
# Bloop
|
||||||
.bsp
|
.bsp
|
||||||
|
6
src/main/scala/Day01.scala
Normal file
6
src/main/scala/Day01.scala
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
object Day01 extends Solution:
|
||||||
|
override def part_01() =
|
||||||
|
"part 1 :D"
|
||||||
|
|
||||||
|
override def part_02() =
|
||||||
|
"part 2 :O"
|
@ -3,27 +3,7 @@ import scala.util.Random
|
|||||||
|
|
||||||
// Number guessing game
|
// Number guessing game
|
||||||
@main def hello: Unit =
|
@main def hello: Unit =
|
||||||
val right_answer = Random().nextInt(101)
|
println("Advent of code 2022 with Scala")
|
||||||
var attempts = 0
|
println(Day01.part_01())
|
||||||
|
|
||||||
println(s"Hello, you have <unlimited> attempts")
|
|
||||||
|
|
||||||
while true do
|
|
||||||
attempts += 1
|
|
||||||
print("Enter a number: ")
|
|
||||||
readLine().toIntOption match
|
|
||||||
case Some(n) if n == right_answer =>
|
|
||||||
println(s"yeh, the number was $n. you win. you took $attempts attempts")
|
|
||||||
return
|
|
||||||
case Some(n) if n > right_answer =>
|
|
||||||
println("you too high mah man")
|
|
||||||
case Some(n) if n < right_answer =>
|
|
||||||
println("a litte too low mate")
|
|
||||||
case Some(_) =>
|
|
||||||
println("??? why are you even seeing this message???")
|
|
||||||
case None =>
|
|
||||||
println("that ain't a numbah. you wasted an attempt!")
|
|
||||||
|
|
||||||
println(s"you outta attemps. you lost. the numbah was $right_answer btw")
|
|
||||||
println("kthxbye")
|
|
||||||
|
|
||||||
|
4
src/main/scala/Solution.scala
Normal file
4
src/main/scala/Solution.scala
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
trait Solution:
|
||||||
|
def part_01(): String
|
||||||
|
def part_02(): String
|
||||||
|
|
Loading…
Reference in New Issue
Block a user