Search
JavaScript (Node.js), 27 22 bytes -5 bytes thanks to Hakerh400 Direct computation f=n=>(n+(n*n+4)**.5)/2 $$\frac{n+\sqrt{n^2+4}}{2}$$ Try it online!
Haskell, 110 bytes f a=s>>=(#)$a++reverse a c@(a:b)!f=f c:b!f _!_=[] f#n=n!((n!).f) s(p:q)(d:e)(b:c)|e==c||e==[]=b|q==c=d|0<1=' ' Try it online!
V (vim), 23 bytes æw|PòlÄxòjVLkîyllv$r $Ð Try it online! Hexdump: 00000000: e677 7c50 f26c c478 f26a 564c 6bee 796c .w|P.l.x.jVLk.yl 00000010: 6c76 2472 2024 d0 lv$r ...
Currently, the only purpose a link to a SE account serves is to associate imported content with your CD account. Since Code Golf doesn't have any imported content from SE, there's no option to link...
Scala, 9 bytes _.reverse Try it in Scastie! Explanation: _.reverse _ //The function argument . //Call a method reverse //Reverse the string
Scala, 99 bytes s=>{val x=s+s.reverse s(0)+"\n"+x.tail.init.zipWithIndex.map{case(c,i)=>c+" "*i+c+"\n"}.mkString+x} Try it in Scastie!
PowerShell, 43 bytes param($s)(($s=$s|% t*y)|%{$s[--$q]})-join'' Try it online!
Jelly, 4 bytes ¹Ƥċ" Try it online! " For each element of the input, ċ how many times does it occur in ¹Ƥ " the corresponding prefix of the input?
APL (Dyalog Unicode), 11 bytes (SBCS) 1 1∘⍉+\∘.=⍨ Try it online! This was a fun APL exercise. Working on figuring out how to get it down to 7 bytes.
Exploiting layout Make it thin Newlines and indentation are expensive, so remove them when possible. Some examples: &v factorial v< > >:1-:| v* < >$>\:| ...
Jq, -rn 18 bytes "|@json+."|@json+. "|@json+." # the string | # through the filter @json # json encoded + # concatenated with ...
BQN, 5 bytes 1+⊒ Try it here! 3 characters, but, as there's no SBCS codepage for BQN, it must be counted as UTF-8. Two of the three characters are just adding one to the built-in that almost ...
Scala 3, 80 bytes @main def m={val s="@main def m={val s=%c%s%1$c;printf(s,34,s)}";printf(s,34,s)} Try it in Scastie! The printf replaces %c and %1$c in string s with the quote character (34 i...
Jelly, 9 bytes ŒHß¹Ḋ?€ZẎ Try it online! How it works ŒHß¹Ḋ?€ZẎ - Main link f(S). Takes a string S on the left ŒH - Split S into two halves € - Over each half H: ? - ...
Solutions by ngn https://chat.stackexchange.com/transcript/message/57690032#57690032 APL 17: {⍵[⍋⍋⍉⊖2⊥⍣¯1⍳≢⍵]} ngn/k 13: {x@<<+|2\!#x} These are too good not to post.
Define a cool number as a number whose proper divisors (all except for the number itself) have an integral mean. Define a really cool number as a number whose divisors (including itself) are all co...
BQN, 25 bytesSBCS ⌊⊸≡(/0=↕⊸|){(+´÷≠)∘𝔽¨«⟜𝔽} Run online! This expression has a complicated structure. This link uses BQN's explain feature to show the order in which everything is applied. It's...
Haskell, 51 31 bytes Saved 20 bytes thanks to Hakerh400! data S=S[S] f i=S$map f[0..i-1] Try it online! S is a recursive data structure, because sets of varying element types can't be repr...
Python 3, 76 71 bytes Saved 5 bytes thanks to user def f(p,n):l=[n*p//q for(p,q)in p if n%q<1];return f(p,l[0])if l else n Try it online! This code assumes that the fractions are given a...
APL (Dyalog Unicode), 15 bytesSBCS With many thanks to Marshall Lochbaum and dzaima for their help debugging and golfing this answer {⍵∪⌊⍵*2|⍵+.5}⍣≡ {⍵∪⌊⍵*2|⍵+.5}⍣≡ ⍝ ⍵ is our input of eith...
JavaScript (Node.js), 73 66 bytes This returns a Generator, which calculates the sequence on the fly when you use it! function*f(a){while(a>1){yield a a=~~(a%2?a**1.5:a**0.5)} yield a} Or...
Scala, 45 bytes _./:(Seq[Int]())((a,x)=>a:+x dropRight-x*2+2) Try it in Scastie! I couldn't find a way to use underscores in the inner function :(. Explanation on its way. _ //The inp...
Jelly, 6 bytes ṣ0Ṗ;¥/ Try it online! How it works ṣ0Ṗ;¥/ - Main link. Takes a list on the left ṣ0 - Split at zeroes ¥/ - Reduce by: Ṗ - Remove the last element ; - C...
Turing Machine.io, 363 bytes 0 0 0 0 -1 8 0 0 8 4 0 1 9 0 0 9 -1 0 0 1 0 0 1 0 0 1 9 0 1 1 1 0 1 9 0 2 1 2 0 1 9 0 3 1 0 0 -1 2 0 2 2 2 0 -1 3 0 0 3 0 0 -1 3 0 1 3 1 0 -1 3 0 2 3 2 0 1 4...
Jelly, 13 bytes ØAUƤz⁶ZUŒBŒḄY Try it online! How it works ØAUƤz⁶ZUŒBŒḄY - Main link. Takes no arguments ØA - Yield the uppercase alphabet Ƥ - Over each prefix: U ...