I felt my code is not exactly right, but I don't know what's wrong : <p>The question is:
Simulate a function to roll a dice. Note that a dice turns up with numbers 1, 2, 3, 4, 5 or 6. The function should do the following: you roll the dice twice, and if both the numbers are the same then return ‘You Win’ otherwise return ‘You Lose’ (hint: use sample())
my code is:</p>

<pre><code>s &lt;- function(x)
{
    x = 1:6
    s1 &lt;- sample(x, size = 1, replace = TRUE)
    s2 &lt;- sample(x, size = 1, replace = TRUE)
    result &lt;- ifelse(s1 == s2, "You Win", "You Lose")
    return(result)
}
s(5)
</code></pre>

<p>Even if the code is right, is there a more effective way to write it? I think it's a little bit tedious.</p>
