Posts by radarek
Ruby, 62 bytes require'prime';f=->n,k=0{n.prime?&&k.prime?? [n,k]:f[n-1,k+1]} Attempt This Online!
Ruby, 44 bytes ->p,n{n*=I while I=p.find{_1*n%1==0};n.to_i} Attempt This Online!
Ruby, 50 bytes ->n{n.times{puts (' '*(n-_1)+'_/'+'##'*_1)[3..]}} Attempt This Online!
Ruby, 57 bytes ->a,b,c{%w[+ - * / % **].select{c==a.send(_1,b)rescue p}} Attempt This Online!
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, 35 bytes ->m{require'matrix';Matrix[*m].det} 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, 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, 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!
Ruby, 36 bytes Infinite version: n=1;0while n+=p(n).digits.minmax.sum Try this online! (program is interrupted after it reaches the 128KiB limit of output)
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, 25 bytes ->e{e.to_c*e[/ .*/].to_c} Try this online!
Ruby, 31 bytes ->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 vers...