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

Rust is cool and all but I feel like the code examples would have been a bit more didactic in e.g. Julia since there's less distracting complexity in those types of languages. Here's a somewhat equivalent translation of the first snippet:

  rolls = 1_000_000
  n_sides = 6
  sevens = 0
  
  for _ in 1:rolls
      if rand(1:n_sides) + rand(1:n_sides) == 7
          sevens += 1
      end
  end
  println(sevens/rolls * 100)


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

Search: