# Tag Info

0

Julia, 7 bytes ndigits Try it online!

0

Julia, 7 bytes ndigits Try it online!

1

PowerShell Core, 20 bytes $args|% *m '-'|% Le* Try it online! 0 Arn -s, 2 bytes .| Try it! Take absolute value, -s takes size. Implicit casting. 3 Haskell, 34 bytes signum.minimum.(zipWith(-)<*>tail) Try it online! Outputs 1,0,-1 for strictly monotonic, non-increasing, and otherwise, respectively. Takes the sign of the minimum of the differences between adjacent pairs. (zipWith(-)<*>tail applied to l computes l - tail l elementwise). This is competitive with the existing Haskell answers ... 0 Python 3, 230 bytes def f(n): s="1" while 2>1: if int(s)%n==0: return s if "0" in s: for j in range(0,len(s)): if s[j]=="0": q=j t=s[:q] for k in range(q,len(s)): t=t+str(1-int(s[k])) s=t else: s=str(10**len(s)) 0 Whispers v2, 39 bytes > Input >> |1| >> "2" >> #3 >> Output 4 Try it online! Boring answer. Get input, absolute value, convert to string, return length. 2 V (vim), 20 bytes :s/- C<C-r>=strlen(<C-r>") <esc> Try it online! Remove minuses(if any), cut the line, and get its length. Not sure if I need the <esc> at the end. 0 R, 38 bytes f=function(x)if(x^2<100,1,1+f(x/10)) Try it online! Unusually for R, a recursive function seems to be shorter here than the previous answer using built-in functions (although this is mostly gained simply because we can skip abs(x) by using x^2<100 as a condition instead)... 2 Japt, 12 bytes Based off Etheryte's solution, posted with permission. _øB ªU´}f¤ÔÄ Try it 3 Husk, 9 7 bytes ḟoΛεd∫∞ Try it online! -2 bytes from Leo. 1 PowerShell, 41 bytes for(;++$n%"$args"-or$n-match'[2-9]'){} $n Try it online! PowerShell, 41 bytes for(;++$n%"$args"-or$n-replace'0|1'){} $n Try it online! 1 PowerShell, 74 bytes param($x)for(){$n=iex ([convert]::tostring(++$i,2));if(!($n%$x)){$n;exit}} Try it online! 0 Husk, 9 bytes #ṗuṁS:Lgp Try it online! Slight improvement over Mr. XCoder's answer. 0 APL(Dyalog Extended), 13 bytes SBCS +/×/¨0j1×⊆⍨⊤⎕ Try it on APLgolf! A tradfn submission which takes a decimal number. 1 Ruby, 112 ... 102 bytes ->m{1until m==[:min,:max].map{|x|m=m.transpose|[];m-=m.combination(2).map{|a,b|a.zip(b).map &x}}[1];m} Try it online! 2 jq (74 bytes) Since shortness is the goal ... def f:def i:.,i|([0]+.,[1]+.);nth(.-1;[1]|i|select(index([1,1])|not))+[1]; Example: 65|f #=> [0,1,0,0,1,0,0,0,1,1] Try it online 1 Charcoal, 40 bytes Ｆ⊗Ｌ⁺θ§θ⁰≔Ｅ§θ⁰±ＥΦθ⬤θ⎇⁼μξ¬›νπ⊙μ‹ρ§ξς§μλθＩθ Try it online! Link is to verbose version of code. Outputs using Charcoal's default format (each cell on its own line with rows double-spaced from each other). Explanation: Ｆ⊗Ｌ⁺θ§θ⁰ Loop a large enough number of times (twice the number of rows and columns; probably overkill, so 4 bytes could be ... 2 Husk, 14 12 bytes Edit: -2 bytes thanks to Leo ↔:1!fo¬V&mḋN Try it online! Based on Etheryte's approach: upvote that! 5 J, 43 41 40 39 bytes f=.(#~1=1#.]*/ .>:|:)@~. f&.:-&.|:@f^:_ Try it online! tldr how Create a function f to filter out dominated rows. Apply plain f, followed by f "under" a negative transpose, until we reach a fixed point. 4 Jelly, 22 21 bytes Qµ>Ạ€TLʋ€’ỊTịNZ Ç⁺$ƬṪ Try it online! Or see the test-suite. How? Ç⁺$ƬṪ - Link: matrix Ƭ - collect up inputs to this until no change:$ - last two links as a monad: Ç - call Link 1 (see below) ⁺ - repeat that Ṫ - tail Qµ>Ạ€TLʋ€’ỊTịNZ - Link 1: matrix Q - de-duplicate (since one of any ...

3

Haskell, 106 101 100 bytes -5 bytes thanks to kops. until=<<((==)<*>)$g.g g m=transpose.map(map(0-))$nub m\\(m>>=tail.mapM(\i->[i..9])) import Data.List Try it online! The relevant function is until=<<((==)<*>)$g.g, which takes as input a matrix in the format described in the statement (not transposed and without flipped ... 2 Python 3, 15 bytes (Courtesy of @Makonede) print(*input()) Try it online! Python 3, 24 bytes (~0.03s) print(' '.join(input())) Try it online! Should be compact and fast PowerShell, 23 bytes ("$args"|% t*y)-join' ' Try it online! This dosen't deserve seperate answer

1

Stax, 16 bytes è}╘⌐ƒw┴L≤⌂IÑ═eαü Run and debug it

3

Factor, 52 bytes { 1/2 } [ dup stack. dup 1 v+n append 2 v/n t ] loop Try it online! Prints each fraction on its own line forever. Keeps track of the array of all terms with equal denominator. { 1/2 } ! Push the initial array [ ... t ] loop ! Loop forever: dup stack. ! Print all fractions separated by a newline dup 1 v+n ! Copy and ...

1

Mini-Flak (BrainHack), 104 bytes ([{}]((()))){({}(())({{}[()](({}({}))){(()[{}]){(({}{}[()]))}}{}}{}(())){[({})]({}[()](()[()]))}{}{})}{} Try it online! Starts at 11 and iteratively computes the encoding of the next number n-1 times. # Create 11 while computing 1-n. ([{}]((()))) # Repeat { # Add 1 to counter (going up to zero) and allow loop to start (...

0

R, 21 bytes, no builtin x=scan();x/abs(x^!!x) Try it online! Takis input from STDIN. Avoids the builtin sign. This comes out 4 bytes shorter than JAD's solution with if. We cannot use directly x/abs(x) since we would divide by 0 when x=0. After coercion to integer, !!x will be equal to 1 for all input except 0 (when it is equal to 0). Since 0^0=1, this ...

0

Python 3.9, 20 bytes import math math.lcm Now Python 3.9 has a builtin in math module to calculate LCM of two or more integers.

4

Python 3.8 (pre-release), 51 bytes Another based on Etheryte's Japt answer f=lambda n,k=0:-n*f'1{k-1:b}'or f(n-(k&k//2<1),k+1) Try it online!

2

Red, 135 124 bytes func[n][i: k: 0 until[i: i + 1 unless find do b:[enbase/base to#{01}i 2]"11"[k: k + 1]n = k]reverse rejoin["1"find do b"1"]] Try it online! Uses @Etheryte's method As an excercise - the step by step method: Red, 153 bytes func[n][c: charset 1 until[k: 0 a: 0 b: 1 until[k: k + 1 t: a a: b b: t + b b > n]c/(...

2

JavaScript (Node.js), 43 bytes n=>(g=p=>n<p||2*g(p+q,q=p)+(n>(n%=p)))(q=1) Try it online! It returns an integer whose binary form is reversed Fibonacci Encoding. // I have a code for base 2 convention n=>(g=p=>n<p 2*g( )+(n>(n%=p)))( ) // I have a code for Fibonacci sequence n=>(g=p=> g(p+q,q=p) )(q=1) ...

8

C (gcc), 51 50 bytes k;f(n){for(k=0;n-=!(++k&k/2););n=log2(k);k+=2<<n;} Try it online! Uses the formula from Etheryte's Japt answer. Returns the Fibonacci code word for input $n$ in reversed binary. Explanation k;f(n){ // function taking an integer n > 0 for(k=0; ;); // loop over values of ...

1

Charcoal, 38 bytes ＮθＦ²⊞υ⊕ιＷ‹⌈υθ⊞υΣ…⮌υ²←1ＦΦ⮌υκ«←Ｉ¬›ιθ≧﹪ιθ Try it online! Link is to verbose version of code. Explanation: Outputs digits in reverse order, but this is the least of Charcoal's problems because it can simply print them backwards. Ｎθ Input n. Ｆ²⊞υ⊕ι Start with 1 and 2 from the Fibonacci sequence. Ｗ‹⌈υθ⊞υΣ…⮌υ² Keep pushing terms until one ...

2

05AB1E, 14 bytes ∞ʒb11å>}s<èb1ì Try it online! ∞ʒb11å>}s<èb1ì # full program <è # push the... s # implicit input... <è # -th... ∞ # natural number... ʒ } # which... > # does not... å # contain... 11 # literal... b # ...

1

Retina 0.8.2, 63 bytes .+ $* (\G1|(?>\2?)(\1))*1$#1$*01¶ +`^(.*).(.*¶)(\1.)¶$3$2 ¶ 1 Try it online! Link includes test cases. Explanation: .+$* Convert to unary. (\G1|(?>\2?)(\1))*1 Use a tweaked version of @MartinEnder's answer to Am I a Fibonacci Number? to match Fibonacci numbers that sum to the input. $#1$*01¶ For each match, generate the ...

3

Scala, 69 bytes Based on Etheryte's amazing answer "1"+Stream.from(0).map(_.toBinaryString).filter(!_.contains("11"))(_) Try it online! Outputs a String (reversed) Original answer, 123 bytes n=>(f.takeWhile(n>=_):\(n,1::Nil)){case(x,n->c)=>if(x>n)(n,0::c)else(n-x,1::c)}._2 def f:Stream[Int]=1#::f.scanLeft(2)(_+_) Try it ...

18

Japt, 13 bytes @!X¤øB}iU ¤ÔÄ Explanation: @!X¤øB}iU @ }iU // Get the U-th (input) number ! // which doesn't have øB // "11" in its X¤ // binary representation ¤ÔÄ ¤ // Take that number's binary representation, Ô // reverse it Ä // and add one to the end. Try it here.

3

Stax, 16 bytes âî}g♥▼«zΩ╥;QbB]╔ Run and debug it Based on Etheryte's observation, which shaved a off a ton of bytes. Check out their answer! Explanation Z{|B.11#!}{ge|B'1s+ Z push 0 under the input(counter) ge generator: find the first n elements, return the last { empty block: get the next element by ...

6

Haskell, 76 bytes 1#2 (u#v)x|x<v=["11"|x==u]|z<-u+v=map('0':)(v#z$x)++map("10"++)(z#(z+v)$x-u) Try it online! Outputs a string of 0's and 1's wrapped in a singleton list (e.g. ["001011"]). How? (u#v)x: we want this function to return a list of all the possible Fibonacci encodings for x using only Fibonacci numbers ...

2

Haskell (GHC), 118 104 bytes x@(_:v)=1:scanl(+)1x f n=snd(foldr(\v(x,l)->if v<=x then(x-v,1:l)else(x,0:l))(n,[])$fst$span(<=n)v)++[1] Try it online! Original: Outputs a list of reversed bits. import Data.List x@(_:v)=1:scanl(+)1x f n=1:snd(mapAccumL(\a b->if b<=a then(a-b,1)else(a,0))n$reverse$fst$span(<=n)v) Try it online! 2 Wolfram Language (Mathematica), 127 bytes (f@n_:=(k=1;While[(F=Fibonacci)[++k]<=n];k-1);s=Table[0,f[t=#]];(s[[#]]=1)&/@(f/@NestWhileList[#-F@f@#&,t,#>0&]);RotateLeft@s)& Try it online! 5 JavaScript (ES6), 46 44 bytes Based on @Etheryte's insight. Returns a string of bits in reverse order. f=(n,k)=>k&k/2||n--?f(n,-~k):1+k.toString(2) Try it online! Commented f = ( // f is a recursive function taking: n, // n = input k // k = counter, initially undefined (coerced ) => // ... 6 Jelly, 21 12 bytes Using Etheryte's observation from their Japt answer is much terser and more efficient to boot (it may be possible in even less, let's see...) 1BSƝỊẠƲ#ṪB1; A monadic Link accepting a positive integer that yields a list of 1s and 0s (in reversed order as allowed in the rules). Try it online! A faster 12 byter: 1Ḥ^:3ƲƑ#ṪB1; Try it online!... 0 Python 3, 172 bytes def z(n): if n==0:return [0] y=[2,1] while y[0]<n:y[0:0]=[sum(y[:2])] d=[] for f in y: if f<=n:d,n=d+[1],n-f else:d+=[0] return ''.join(map(str,d[::-1]))[:-1]+'1' Try it online! 2 Factor, 68 66 bytes Saved 2 bytes thanks to @chunes [ 1 2 [ 2dup / . [ 2 + ] dip 2dup > [ 2 * 1 swap ] when t ] loop ] Try it online! Outputs the sequence infinitely. [ 1 2 ! First numerator and denominator [ ! Loop body 2dup / ! Divide to get next element of sequence . !... 1 Factor + math.unicode, 30 29 24 bytes Saved 1 byte thanks to @Bubbler Saved 5 bytes thanks to @chunes! [ 1 rot neg <range> Π ] Try it online! Takes k (which -th factorial) and then n. First we push an n onto the stack, then rot makes the stack look like n 1 k. neg negates k, which will act as the step for a range from n to 1 (made using <range>... 2 BRASCA, 8 bytes ,'/-1$%n Try it online! Explanation , - Reverse the stack to take the first character from input '/- - Subtract it by 47 1\$% - 1 % that value n - And output it

0

x86_64 machine code - 26 24 bytes This is callable function, input in r8 output in rax. -3 bytes using cbw instruction is 2 bytes instead of movzx rax, al is 4 bytes. 0000000000400080 <output_the_sign>: 400080: 48 31 c0 xor rax,rax 400083: 4d 85 c0 test r8,r8 400086: 74 11 je 400099 &...

2

BRASCA, 15 bytes Ci,:::SSL{+,SS= Try it online! Explanation Ci - Set implicit output to output numbers, and turn "0-9" into 0-9 , - Reverse stack :::SSL{+ - First digit of input, concatenated to itself twice, + 12 ,SS= - Concatenate the digits of the original, then check if both numbers are ...

3

Jelly, 11 bytes Obligatory Jelly answer. ḃØ⁵ịØJ⁾“»jV Try it online! How? ḃØ⁵ịØJ⁾“»jV - Link: integer, n ḃ - convert (n) to bijective base: Ø⁵ - 250 ị - index into: ØJ - Jelly's code-page ⁾“» - list of characters = "“»" j - join -> "“...»" V - evaluate as Jelly code

Top 50 recent answers are included