Activity for radarekā
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #285743 |
@#53310 Thanks for spotting it. Fixed. (more) |
— | about 2 years ago |
Comment | Post #285331 |
However, your code and mine suggestion don't work with input `*,0,*` (division by 0). The error must by properly handled. (more) |
— | about 2 years ago |
Comment | Post #285692 |
Unfortunately this does not work for input 0, 2 and 0, 2.
```
f=->a,b{a|b==2?5:a+b}
f[0, 2] # => 5
``` (more) |
— | about 2 years ago |
Comment | Post #283012 |
@#53607 Ok, make sense. (more) |
— | about 2 years ago |
Comment | Post #285618 |
@#55346 nice catch! Thanks. (more) |
— | about 2 years ago |
Comment | Post #281542 |
What characters can strings include? Only letters (like in examples)? New lines can be included? What about other characters? (more) |
— | about 2 years ago |
Comment | Post #283012 |
According to the description, input is a given as a string, not a array of strings (lines) as your solution is implemented. (more) |
— | over 2 years ago |
Comment | Post #283278 |
Also, the solution you provided does not follow problem description. The code does not reduce 1..n (n is a parameter). (more) |
— | over 2 years ago |
Comment | Post #283278 |
I don't think that first code is correct. If you want to pass proc/lambda as a block to `reduce` method, then `&` is needed.
```ruby
->{_2.reduce(&_1)}
```
To make it shorter, `()` can be omitted:
```ruby
->{_2.reduce &_1}
```
[Try this online](https://ato.pxeger.com/run?1=m72kqDSpcsH... (more) |
— | over 2 years ago |
Comment | Post #285404 |
@#53310 Good catch, thanks! (more) |
— | over 2 years ago |
Comment | Post #285331 |
```ruby
->a,b,c{%w[+ - * / % **].select{eval"a#{_1}b==c"}}
```
(more) |
— | over 2 years ago |
Comment | Post #285404 |
You can make it 1b shorter by using `$><<` to output value in P2:
```
puts"$><<#{gets}+gets.to_i"
```
(more) |
— | over 2 years ago |