3 ms·
The obvious scala implementation is 160 chars and works locally, but the site claims I score 0 for it: object Solution {def main(args: Array[String])=1 to
by lmm 14y ago
The obvious scala implementation is 160 chars and works locally, but the site claims I score 0 for it:
object Solution {def main(args: Array[String])=1 to 100 map {x=>System.out.print(if(x%3>0&&x%5>0)x else if(x%5>0)"Buzz" else if(x%3>0)"Fizz" else "FizzBuzz")}}
- idlecool 14y agoyou are missing out new line characters after each output. `System.out.println` should work.
- deleted 14y ago[deleted]
- patman_h 14y agoWhen I tried out the site, it gave me a score of 0 for submissions that compiled but produced the wrong output. I've never written scala before but it looks like your logic is wrong. Edit: I tweaked your code and got a score of 34 object Solution {def main(args: Array[String])=1 to 100 map {x=>System.out.println(if(x%3==0&&x%5==0)"FizzBuzz" else if(x%5==0)"Buzz" else if(x%3==0)"Fizz" else x)}}