Posts by radarek
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!
Ruby, 25 bytes ->e{e.to_c*e[/ .*/].to_c} Try this online!
Ruby, 27 bytes ->n{(2..n).all?{n%_1**2>0}} Try it online
Ruby, 50 bytes ->n{n.times{puts (' '*(n-_1)+'_/'+'##'*_1)[3..]}} Attempt This Online!
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 ...
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]...
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...
Ruby, 57 bytes ->a,b,c{%w[+ - * / % **].select{c==a.send(_1,b)rescue p}} Attempt This Online!
Ruby, 52 51 bytes 13.times{puts:YWUSQOMKIGECABDFHJLNPRTVXZ[12-_1,14]} Attempt This Online!
Ruby, 70 bytes ->s{s+=s.reverse;s[..-2].gsub(/./){t=$&+' '*$.+$/;t[-2]=$&;$.+=1;t}+s} Try this online!
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!
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...
Ruby, 44 bytes ->p,n{n*=I while I=p.find{_1*n%1==0};n.to_i} Attempt This Online!
Ruby, 62 bytes require'prime';f=->n,k=0{n.prime?&&k.prime?? [n,k]:f[n-1,k+1]} Attempt This Online!
Ruby, 56 bytes ->n{require'prime';Prime.each_cons(2).find{_2-_1>=n}[0]} Attempt This Online!
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\...
Ruby, 25 bytes puts"p #{gets}+gets.to_i" P1 - Try this online! P2 - Try this online!
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!
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...
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_...
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!
Ruby, 48 bytes ->a{[a.split,b=a.chars-[$/],b-[' ']].map &:size} Try this online!