From 54d85c86077844b60d349513c3710b3839645664 Mon Sep 17 00:00:00 2001 From: flaviut Date: Thu, 17 Jul 2014 11:46:49 -0400 Subject: [PATCH] Better randomness --- content/if_else_while.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content/if_else_while.md b/content/if_else_while.md index 6c0b544..43161d6 100644 --- a/content/if_else_while.md +++ b/content/if_else_while.md @@ -11,10 +11,9 @@ When inside a loop, `continue` can be used to skip the rest of the loop body and Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops. ``` nimrod -import strutils +import strutils, math -let answer = 4 # Chosen by a fair dice roll, - # guaranteed to be random +let answer = random(10) + 1 while true: echo "I have a number from 1 to 10, what is it? " let guess = parseInt(stdin.readLine)