This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.text._ | |
| object dateCheck extends App { | |
| def isDate(str: String): Boolean = { | |
| val d = new SimpleDateFormat("yyyyMMdd") | |
| d.setLenient(false) | |
| try { | |
| d.parse("2000"+str) | |
| true | |
| } catch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object legalTender extends App { | |
| val yenCoins = List(1 | |
| ,5 | |
| ,10 | |
| ,50 | |
| ,100 | |
| ,500) | |
| val yenMax = 20 | |
| def sumCoins(coins: List[Int], max: Int): Int = coins.map(_ * max).sum |