Search
Ruby, 62 bytes require'prime';f=->n,k=0{n.prime?&&k.prime?? [n,k]:f[n-1,k+1]} Attempt This Online!
MATL, 4 bytes tPX= Try it online! tPX= t - duplicate with implicit input P - fliplr in MATLAB, reverses top of stack X= - isequal
MATL, 19 bytes XH:YqtZ*!tsH=f1Z)Z) Try it online! I'm still a novice at MATL, so I am all ears to any improvements. XH:YqtZ*!tsH=f1Z)Z) XH - copy implicit input to H clipboa...
SOS, 155 Bytes !+!-!!+!-!!!!+!!-!!+!-!+!-!+!!-!+!!-!!!+!!-!+!!-!!!+!!-!+!!!!-!!+!-!+!!-!!!!+!-!!!!!!+!-!+!-!+!!!-!+!!-!+!!!!-!+!!!-!!+!-!!+!!-!+!!-!!!+!!-!!+!-!!+!-!!!!+! Explanation: Each ! o...
SOS, 76 bytes +>+>?<+>?<+>?<+>?<+>?<+>?<+>?<+>?<<)<<-(>{>!<{>!<{>!<{>!<{>!<{>!<{>!<{>!&l...
JavaScript (V8), 78 bytes f=s=>s.map(c=>(_==256||_<0?_=0:0)||c=='i'?_++:c=='d'?_--:c=='s'?_*=_:v+=_+' ') Try it online!
Lua 5.4.4, 51 bytes function f(n)return n<2 and n or f(n-1)*2+f(n-2)end Try it online!
C (gcc), 35 bytes f(n){return n<2?n:f(n-1)*2+f(n-2);} Try it online!
Respect both sides We should consider how an approach would affect the poster of the incorrect answer, and how it would affect the posters of correct answers. Correct answers In general, allowin...
Haskell + hgl, 10 bytes mpn$ce~<gj Attempt This Online! Explanation mpn map across all non-empty prefixes of the input ... ce count the number of elements in each prefix equal to ... g...
Ruby, 128 bytes ->x,y{g=->c{c.chars.join" ?"} !x[y]&&(x.match?(/.+#{g[y]}.+/)||(0...(y.size-1)).any?{x[/^#{g[y[0.._1]]}.+#{g[y[(_1+1)..]]}$/]})} Attempt This Online! bookends ar...
Charcoal, 88 bytes ≔⪪η λFLθ«¿¬⁼θ⁰«≔…θ⁺ι¹π¿№λπ«≔πω§≔λ⌕λω⁰»«¿Σ⭆λ⁼…κ⁺ι¹π«≔§Φλ⁼…κ⁺ι¹π⁰ω§≔λ⌕λω⁰»«θ≔⁰θ»»»»¿¬⁼θ⁰«ω Try it online!
When answering a code-golf challenge, what types of answer are acceptable by default? Can an answer be a complete program, a function, an anonymous function, a snippet of code? Please add one type...
Complete program A code golf answer can be a complete program. This means that the code can be interpreted or compiled (as appropriate) without any additional source code.
Function Score is the bytes of the function A code golf answer can be a function. Only the bytes required to define the function are included in the score. Score includes imports and definitions...
Anonymous function A code golf answer can be an anonymous function[1]. That is, a function that can be defined without giving it a name (in programming languages that allow this). If an anonymous...
A snippet is not a valid answer A code golf answer must in general be able to take input[1] and give output. A snippet of code that is not contained in a function or program cannot take input[2], ...