Skip to content

Commit c25cb5c

Browse files
committed
chore: more Scala 3 syntax
1 parent 0735034 commit c25cb5c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/main/scala/ru/org/codingteam/icfpc_2025/Æedificium.scala

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,32 @@ import upickle.ReadWriter
77
import java.nio.file.{Files, Path}
88
import scala.util.Using
99

10-
object Ædificium {
10+
object Ædificium:
1111

1212
private val baseUrl = "https://31pwr5t6ij.execute-api.eu-west-2.amazonaws.com"
1313

1414
private def backend = DefaultSyncBackend()
1515
private val id =
1616
val file = "api-secret.txt"
17-
if (Files.notExists(Path.of(file)))
17+
if Files.notExists(Path.of(file)) then
1818
throw new Exception(s"File $file not found. Please create it and put your API secret there.")
19-
Using.resource(scala.io.Source.fromFile(file)) { source =>
19+
Using.resource(scala.io.Source.fromFile(file)): source =>
2020
val secret = source.getLines().mkString("\n").trim
2121
secret
22-
}
2322

2423
private case class SelectRequest(id: String, problemName: String) derives ReadWriter
2524
private case class ExploreRequest(id: String, plans: Seq[String]) derives ReadWriter
2625
private case class ExploreResponse(results: Seq[Seq[Int]], queryCount: Int) derives ReadWriter
2726

28-
def select(problemName: String): Unit = {
27+
def select(problemName: String): Unit =
2928
val response = basicRequest
3029
.post(uri"$baseUrl/select")
3130
.body(asJson(SelectRequest(id, problemName)))
3231
.send(backend)
3332
assertSuccess(response)
34-
}
3533

36-
def explore(plans: Seq[Seq[Int]]): Seq[Seq[Int]] = {
37-
val request = ExploreRequest(id, plans.map { _.mkString("") })
34+
def explore(plans: Seq[Seq[Int]]): Seq[Seq[Int]] =
35+
val request = ExploreRequest(id, plans.map(_.mkString("")))
3836
println(s"Sending request: ${asJson(request)}")
3937

4038
val response = basicRequest
@@ -44,12 +42,9 @@ object Ædificium {
4442
.send(backend)
4543
assertSuccess(response)
4644
response.body.toOption.get.results
47-
}
4845

49-
private def assertSuccess(response: Response[?]): Unit = {
46+
private def assertSuccess(response: Response[?]): Unit =
5047
if response.code.code != 200 then
5148
throw RuntimeException(s"Request failed with status ${response.code.code}: ${response.body}")
52-
}
53-
}
5449

5550
val AEdificium = Ædificium // accessibility! yay!

0 commit comments

Comments
 (0)