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 »

Posts by radarek‭

31 posts
71%
+3 −0
Challenges Make $2 + 2 = 5$

Ruby, 20 bytes ->a,b{4[a]*4[b]+a+b} Attempt This Online!

posted 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Given the preorder and the inorder of a tree, output the postorder

Ruby, 75 72 bytes f=->((e,*r),n){(i=n.index e)?f[r[0,i],n[...i]]+f[r[i..],n[i+1..]]+[e]:n} Attempt This Online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Multiply complex numbers.

Ruby, 25 bytes ->e{e.to_c*e[/ .*/].to_c} Try this online!

posted 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Determine whether an integer is square-free

Ruby, 27 bytes ->n{(2..n).all?{n%_1**2>0}} Try it online

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Stairs? Stairs! Stairs.

Ruby, 50 bytes ->n{n.times{puts (' '*(n-_1)+'_/'+'##'*_1)[3..]}} Attempt This Online!

posted 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Roll n fair dice

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 ...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Weave Strings Together

Ruby, 48 45 bytes ->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: ->w{([p]...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Are All Elements Equal?

Ruby, 14 bytes ->{_1|[]in[_]} Alternative solution: ->a{!(a|a)[1]} Try this online! Couple of other solutions I developed: ->a{!a.uniq[1]} # 15 bytes ->{!(_1|[])[1]} # 15...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Operation "Find The Operator"

Ruby, 57 bytes ->a,b,c{%w[+ - * / % **].select{c==a.send(_1,b)rescue p}} Attempt This Online!

posted 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Small integer swapping

Ruby, 24 bytes gets=~/ /;puts$`,$'*2+$` Try this online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Diagonalized alphabet

Ruby, 52 51 bytes 13.times{puts:YWUSQOMKIGECABDFHJLNPRTVXZ[12-_1,14]} Attempt This Online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Word Set Square

Ruby, 70 bytes ->s{s+=s.reverse;s[..-2].gsub(/./){t=$&+' '*$.+$/;t[-2]=$&;$.+=1;t}+s} Try this online!

posted 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Reduce over the range [1..n]

Ruby, 22 bytes ->{(1.._2).reduce &_1} Try this online! Without using reduce (28 bytes): f=->g,n{n<2?n:g[n,f[g,n-1]]} Try this online!

posted 3y ago by radarek‭

Answer
60%
+1 −0
Challenges Golf golf challenge

Ruby, 100 96 bytes According to the rules, trailing white spaces and line feed are allowed and my program uses that: ->p,s{"Par Bogey Double bogey Triple bogey Hole in one Albatross Eagl...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Golf a FRACTRAN interpreter

Ruby, 44 bytes ->p,n{n*=I while I=p.find{_1*n%1==0};n.to_i} Attempt This Online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Solve Goldbach's Conjecture

Ruby, 62 bytes require'prime';f=->n,k=0{n.prime?&&k.prime?? [n,k]:f[n-1,k+1]} Attempt This Online!

posted 2y ago by radarek‭

Answer
50%
+0 −0
Challenges Prime Difference

Ruby, 56 bytes ->n{require'prime';Prime.each_cons(2).find{_2-_1>=n}[0]} Attempt This Online!

posted 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Merge two strings

Ruby, 40 bytes 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\...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges A number adder, not a death adder

Ruby, 25 bytes puts"p #{gets}+gets.to_i" P1 - Try this online! P2 - Try this online!

posted 3y ago by radarek‭

Answer
50%
+0 −0
Challenges 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: p gets.to_i&1 Try this online!

posted 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Make my number a set

Ruby, 23 bytes ->n,*x{eval'x<<x*1;'*n} Try this online! There is also 22 bytes version, but it uses special $* global variables (so it can be run only once in single process): ->n...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges 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) "->l{l.sort_...

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Repeat the characters

Ruby, 23 bytes ->{_1.gsub /./,'\0'*_2} Try this online!

posted 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Write a Deadfish Interpreter

Ruby, 70 67 66 bytes ->c{a=0;c.bytes{|b|a,=[b<106?a+b/3-34:b<112?p(a):a*a,0]-[-1,256]}} Test this online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
50%
+0 −0
Challenges Word Count Tool

Ruby, 48 bytes ->a{[a.split,b=a.chars-[$/],b-[' ']].map &:size} Try this online!

posted 3y ago by radarek‭

Answer