Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for radarekā€­

Type On... Excerpt Status Date
Answer A: Solve Goldbach's Conjecture
Ruby, 62 bytes require&#39;prime&#39;;f=-&gt;n,k=0{n.prime?&amp;&amp;k.prime?? [n,k]:f[n-1,k+1]} Attempt This Online!
(more)
about 2 years ago
Answer A: Golf a FRACTRAN interpreter
Ruby, 44 bytes -&gt;p,n{n=I while I=p.find{1n%1==0};n.toi} Attempt This Online!
(more)
about 2 years ago
Answer A: Stairs? Stairs! Stairs.
Ruby, 50 bytes -&gt;n{n.times{puts (&#39; &#39;(n-1)+&#39;/&#39;+&#39;##&#39;1)[3..]}} Attempt This Online!
(more)
about 2 years ago
Answer A: Operation "Find The Operator"
Ruby, 57 bytes -&gt;a,b,c{%w[+ - / % ].select{c==a.send(1,b)rescue p}} Attempt This Online!
(more)
about 2 years ago
Answer A: Make $2 + 2 = 5$
Ruby, 20 bytes -&gt;a,b{4[a]4[b]+a+b} Attempt This Online!
(more)
about 2 years ago
Answer A: Given the preorder and the inorder of a tree, output the postorder
Ruby, 75 72 bytes f=-&gt;((e,r),n){(i=n.index e)?f[r[0,i],n[...i]]+f[r[i..],n[i+1..]]+[e]:n} Attempt This Online!
(more)
over 2 years ago
Answer A: Compute the determinant
Ruby, 35 bytes -&gt;m{require&#39;matrix&#39;;Matrix[m].det} Attempt This Online!
(more)
over 2 years ago
Answer A: Prime Difference
Ruby, 56 bytes ```ruby ->n{require'prime';Prime.eachcons(2).find{2-1>=n}[0]} ``` Attempt This Online!
(more)
over 2 years ago
Answer A: Merge two strings
Ruby, 40 bytes ```ruby f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]} ``` Attempt This Online! If we could assume that string contains only letters and numbers (or to be more specific, no characters like `\t\n\v\f\r \#$()+-.?[\\]^{|}`) then it could be improved to 36 bytes: ```ruby f=->a,b{b...
(more)
over 2 years ago
Answer A: A number adder, not a death adder
Ruby, 25 bytes ```ruby puts"p #{gets}+gets.toi" ``` P1 - Try this online! P2 - Try this online!
(more)
over 2 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)
over 2 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)
over 2 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)
over 2 years ago
Answer A: Make my number a set
Ruby, 23 bytes ```ruby ->n,x{eval'xn{eval'$<<$1;'n} ``` Try this online!
(more)
over 2 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)
over 2 years ago
Answer A: Repeat the characters
Ruby, 23 bytes ```ruby ->{1.gsub /./,'\0'2} ``` Try this online!
(more)
over 2 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)
over 2 years ago
Answer A: Small integer swapping
Ruby, 24 bytes ```ruby gets=/ /;puts$`,$'2+$` ``` Try this online!
(more)
over 2 years ago
Answer A: Word Count Tool
Ruby, 48 bytes ```ruby ->a{[a.split,b=a.chars-[$/],b-[' ']].map &:size} ``` Try this online!
(more)
over 2 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)
over 2 years ago
Answer A: Diagonalized alphabet
Ruby, 52 51 bytes 13.times{puts:YWUSQOMKIGECABDFHJLNPRTVXZ[12-1,14]} Attempt This Online!
(more)
over 2 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)
over 2 years ago
Answer A: Multiply complex numbers.
Ruby, 25 bytes ```ruby ->e{e.toce[/ ./].toc} ``` Try this online!
(more)
over 2 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)
over 2 years ago
Answer A: Bytes to Segfault
Ruby, 14 bytes ```ruby `kill -11 #$$` ``` Try this online!
(more)
over 2 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)
over 2 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)
over 2 years ago
Answer A: Golf golf challenge
Ruby, 100 96 bytes According to the rules, trailing white spaces and line feed are allowed and my program uses that: ```ruby ->p,s{"Par Bogey Double bogey Triple bogey Hole in one Albatross Eagle Birdie".lines[s<2?4:s-p]} ``` Try this online!
(more)
over 2 years ago
Answer A: Roll n fair dice
Ruby, 27 24 bytes -&gt;n,m{eval&#39;-rand(m)&#39;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 in 3.x - bug or feature?): ```ruby ->{eval'-rand(1)'2} ```
(more)
over 2 years ago
Answer A: Evaluate a single variable polynomial equation
Ruby, 29 bytes ```ruby ->l,x{a,b=l;a ?a+xf[b,x]:0} ``` Try it online
(more)
over 2 years ago
Answer A: Determine whether an integer is square-free
Ruby, 27 bytes ```ruby ->n{(2..n).all?{n%12>0}} ``` Try it online
(more)
over 2 years ago