Post History
Ruby, 27 24 bytes ->n,m{eval'-~rand(m)'*n} Attempt This Online! If we change the order of n, m parameters to m, n then following 23 bytes version work, but only in ruby 2.7 (it does not work ...
Answer
#3: Post edited
- # [Ruby](https://www.ruby-lang.org/), <del>27</del> 24 bytes
- <pre><code class="lang-ruby">->n,m{eval'-~rand(m)'*n}</code></pre>
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY7dO3ydHKrU8sSc9R164oS81I0cjXVtfJqIdKrC0pLihXSok11zGIhIgsWQGgA)
If we change the order of `n, m` parameters to `m, n` then following 23 bytes version work, but only in ruby 2.7:- ```ruby
- ->{eval'-~rand(_1)'*_2}
- ```
- # [Ruby](https://www.ruby-lang.org/), <del>27</del> 24 bytes
- <pre><code class="lang-ruby">->n,m{eval'-~rand(m)'*n}</code></pre>
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY7dO3ydHKrU8sSc9R164oS81I0cjXVtfJqIdKrC0pLihXSok11zGIhIgsWQGgA)
- If we change the order of `n, m` parameters to `m, n` then following 23 bytes version work, but only in ruby 2.7 (it does not work in 3.x - bug or feature?):
- ```ruby
- ->{eval'-~rand(_1)'*_2}
- ```
#2: Post edited
# [Ruby](https://ruby-lang.org/), 27 bytes```ruby->n,m{n+(1..n).sum{rand m}}```**[Try it online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuha7de3ydHKr87Q1DPX08jT1iktzq4sS81IUcmtrISpWF5SWFCukRZvqmMVCRBYsgNAA)**
- # [Ruby](https://www.ruby-lang.org/), <del>27</del> 24 bytes
- <pre><code class="lang-ruby">->n,m{eval'-~rand(m)'*n}</code></pre>
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGiNNulpSVpuhY7dO3ydHKrU8sSc9R164oS81I0cjXVtfJqIdKrC0pLihXSok11zGIhIgsWQGgA)
- If we change the order of `n, m` parameters to `m, n` then following 23 bytes version work, but only in ruby 2.7:
- ```ruby
- ->{eval'-~rand(_1)'*_2}
- ```