Use `foreach` instead of `for`. The former is faster.

~~~
ans.foreach { r => 
...
}
~~~