Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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")}}


When 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)}}


you are missing out new line characters after each output. `System.out.println` should work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: