Activity for radarekā
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #285631 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Evens or Odds - you know this one Ruby, 13 bytes According to the rules, programs should read from STDIN and output to the STDOUT. This is my solution: ```ruby p gets.toi&1 ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285630 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Weave Strings Together Ruby, 48 45 bytes ```ruby ->w{([p].w''=/$/).zip(w.map(&:chars))''} ``` Try this online! It could be improved to 32 bytes, if every string is represented as an array of characters: ```ruby ->w{([p].w''=/$/).zip(w)''} ``` Attempt This Online! (more) |
— | almost 3 years ago |
Edit | Post #285629 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Are All Elements Equal? Ruby, 14 bytes ```ruby ->{1|[]in[]} ``` Alternative solution: ```ruby ->a{!(a|a)[1]} ``` Try this online! Couple of other solutions I developed: ```ruby ->a{!a.uniq[1]} # 15 bytes ->{!(1|[])[1]} # 15 bytes ->a{(a|a).one?} # 15 bytes ``` (more) |
— | almost 3 years ago |
Edit | Post #285618 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285623 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285623 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285623 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Make my number a set Ruby, 23 bytes ```ruby ->n,x{eval'xn{eval'$<<$1;'n} ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285622 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Coat of Many Colours Ruby, 101 79 76 72 bytes This challenge was one of the funniest I have ever solved! 72 bytes solution (I show the solution as a Ruby string - because binary data is filtered out) ```ruby "->l{l.sortby{'d\v\x162\x82\r\x1D\nJ\"\x01T\x0E?\x8B.\x11\x05\x06G(\fM\x00 HyI'.index''<<1[2,4].sum%145}... (more) |
— | almost 3 years ago |
Edit | Post #285621 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Repeat the characters Ruby, 23 bytes ```ruby ->{1.gsub /./,'\0'2} ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285618 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Write a Deadfish Interpreter Ruby, 70 67 66 bytes ```ruby ->c{a=0;c.bytes{|b|a,=[b<106?a+b/3-34:b<112?p(a):aa,0]-[-1,256]}} ``` Test this online! (more) |
— | almost 3 years ago |
Edit | Post #285611 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285611 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285611 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285611 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Small integer swapping Ruby, 24 bytes ```ruby gets=/ /;puts$`,$'2+$` ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285610 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Word Count Tool Ruby, 48 bytes ```ruby ->a{[a.split,b=a.chars-[$/],b-[' ']].map &:size} ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285606 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285606 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285606 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Digit Sum Integer Sequence (working title) Ruby, 36 bytes Infinite version: ```ruby n=1;0while n+=p(n).digits.minmax.sum ``` Try this online! (program is interrupted after it reaches the 128KiB limit of output) (more) |
— | almost 3 years ago |
Edit | Post #285605 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Diagonalized alphabet Ruby, 52 51 bytes 13.times{puts:YWUSQOMKIGECABDFHJLNPRTVXZ[12-1,14]} Attempt This Online! (more) |
— | almost 3 years ago |
Edit | Post #285597 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Word Set Square Ruby, 70 bytes ```ruby ->s{s+=s.reverse;s[..-2].gsub(/./){t=$&+' '$.+$/;t[-2]=$&;$.+=1;t}+s} ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285592 |
Post edited: |
— | almost 3 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) |
— | almost 3 years ago |
Edit | Post #285592 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285593 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Multiply complex numbers. Ruby, 25 bytes ```ruby ->e{e.toce[/ ./].toc} ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285592 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285592 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Cumulative Counts Ruby, 31 bytes ```ruby ->a{a.map{$[1]=1.+$[1]||0}} ``` Try this online! `$` is a global variable, so calling this lambda multiple times (in a single process) would give wrong result. A 32 bytes version that does not rely on a global state: ```ruby ->a,c{a.map{c[1]=1.+c[1]||0}} ``` ... (more) |
— | almost 3 years ago |
Edit | Post #285588 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Bytes to Segfault Ruby, 14 bytes ```ruby `kill -11 #$$` ``` Try this online! (more) |
— | almost 3 years ago |
Edit | Post #285519 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Generalized Sort Ruby, 25 bytes Credits goes to @Shaggy and his JavaScript solution. ```ruby ->a,l{l.map{a.sort! &1}} ``` Try this online! The other solution which not mutate original array (more) |
— | almost 3 years ago |
Edit | Post #285512 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Reduce over the range [1..n] Ruby, 22 bytes ```ruby ->{(1..2).reduce &1} ``` Try this online! Without using `reduce` (28 bytes): ```ruby f=->g,n{n<2?n:g[n,f[g,n-1]]} ``` Try this online! (more) |
— | almost 3 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) |
— | almost 3 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) |
— | almost 3 years ago |
Edit | Post #285507 |
Post edited: |
— | almost 3 years ago |
Edit | Post #285507 | Initial revision | — | almost 3 years ago |
- ← Previous
- 1
- 2
- 3
- Next →