scalamatsuri / 2022.open-mic-conference

2 stars 0 forks source link

✅ 15:15 〜 第2回 ひどいコード選手権 #19

Open takezoux2 opened 2 years ago

takezoux2 commented 2 years ago

第2回 ひどいScalaコード選手権

これはひどい!となるコードを書きましょう

前回: https://github.com/scalamatsuri/2020.unconference/issues/16

kzmake commented 2 years ago

第一回: https://youtu.be/GwONLLoKZTo

taketora26 commented 2 years ago

DIscordでやりたい人を募集して、午後にひどいコードの投票と表彰式を行う。

omiend commented 2 years ago

ひどいコードができたら、Discord の「#第2回-ひどいコード選手権」まで!

https://discord.com/channels/934288800560054292/954919131860320306

takezoux2 commented 2 years ago

omiendさん 無駄なパターンマッチ https://scastie.scala-lang.org/uTTeeLWnTmmisEEZ4iFZyg

takezoux2 commented 2 years ago

takezoux2 仕様不明 https://gist.github.com/takezoux2/9a7dcef0e51294c7462e37275200bae7#file-cant_decide_spec-scala

takezoux2 commented 2 years ago

takezoux2 例外握りつぶし https://gist.github.com/takezoux2/9a7dcef0e51294c7462e37275200bae7#file-destroy_exception-scala

takezoux2 commented 2 years ago

aoinoさん ひどいWordle resolver https://github.com/aoiroaoino/scalamatsuri2022-hidoi-wordle-solver

takezoux2 commented 2 years ago

omiendさん yieldの中でmap https://scastie.scala-lang.org/JBA02QeDTgCXlekXudJoLw

takezoux2 commented 2 years ago

taketoraさん よく書くretry https://scastie.scala-lang.org/GUWSenaKQs2dWk3lwmXFWA

takezoux2 commented 2 years ago

Alyさん https://scastie.scala-lang.org/RnJMJ0ZsSo2XicsoS6PsSw

takezoux2 commented 2 years ago

優勝はAlyさん 正規表現で素因数分解 保全のため、コピペ

val composites = "^(#{2,}?)\\1+$".r

def factors(i: Int): List[Int] = {
  "#".repeat(i) match {
    case composites(factor) =>
      factor.length :: factors(i / factor.length)
    case _ =>
      i :: Nil
  }
}

(2 to 100).foreach { n =>
  println(s"$n = ${factors(n).mkString(" × ")}")
}