Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala Code Golf #128

Open
hugoferreira opened this issue Jul 21, 2022 · 1 comment
Open

Scala Code Golf #128

hugoferreira opened this issue Jul 21, 2022 · 1 comment

Comments

@hugoferreira
Copy link
Contributor

object Main {
def solve(): Int = {
(0 to 999).filter((x) => ((x % 3) == 0 || (x % 5) == 0)).sum
}
def main(args: Array[String]): Unit = {
val result = solve()
println(result)
}
}

Can be rewritten as:

object P1 extends App {
  println((0 to 999).count(x => Seq(3, 5).exists(x % _ == 0)))
}
@yvern
Copy link
Collaborator

yvern commented Jul 21, 2022

code golf or boilerplate reduction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants