Skip to content

Instantly share code, notes, and snippets.

@myeesan
Created November 6, 2015 13:17
Show Gist options
  • Save myeesan/e9069e5d6029370a61a0 to your computer and use it in GitHub Desktop.
Save myeesan/e9069e5d6029370a61a0 to your computer and use it in GitHub Desktop.
import scala.io.Source
object HelloScala {
case class TestCase() {
def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
val (g1, g2, g3) = (4, 4, 3) //기어 비의 갯수
val gear = List(3713, 140, 1475, 9721)
val extra = List(5665, 8611, 8762, 7400)
val tires = List(5166, 3739, 853)
val ac = gear.map(x => tires.map(a => (x, a))).flatten.toSet
val bs = extra.combinations(2).toList.toSet
val ss = ac.map(x => bs.map(a => (x, (a(0), a(1))))).flatten.toList.toSet.toList
val r = List((31972643, 21181435),
(30751629, 21365175),
(1930185, 878195),
(63612376, 38865596),
(85175402, 4832245),
(32533306, 44484426),
(85175402, 32196529),
(1205540, 27668600),
(14248777, 5783074),
(22392234, 57411354))
val targetRatio = r.map { r =>
val gcdfactor = gcd(r._1, r._2)
((r._1 / gcdfactor), (r._2 / gcdfactor))
}
}
val in = Source.fromFile("B-small-practice.in").getLines
def gears(line: String) = line.split(' ').toList.map(_.toInt)
def main(param: Array[String]): Unit = {
val tc = TestCase()
val xs = tc.ss.map { case ((x: (Int, Int), y: (Int, Int))) => (x._1 / x._2) * (y._1 / y._2) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment