Last active
August 29, 2015 14:04
-
-
Save jackliusr/3b0294f27e9957cc6ba9 to your computer and use it in GitHub Desktop.
Hackerrank Utopian Tree in scala
This file contains 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 Solution { | |
def main(args: Array[String]) { | |
val lines = io.Source.stdin.getLines().filter(_.length > 0).drop(1) | |
val nums = lines.map(_.toInt) | |
nums.foreach( n => println( (0 to n).fold(0)( (acc, n) => if(n %2 == 0) acc +1 else acc *2 )) ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment