Skip to main content
deleted 165 characters in body
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Alchemist, 205205 134 bytes

Big thanks to ASCII-only for rather clever merging of states, saving 71 bytes!!

_->b+In_e+p p+e->p+g+f p+0e->q>In_x+c+u q+gu+b->q+e>u+a+d q+0gu+0b->r>v r+dv+c->r+a+h>v+b+d r+0dv+0c->s>w s+e+hw+a+x->s>w+y s+0e+0hw+0a+0x->Out_"true">Out_"1" s+0e+hw+a+0x->Out_"false">Out_"0" s+e+0hw+0a+x+y->t>w+2x t+bw+0a+0y+d->t+d+c>w+c t+0bw+0d+0a->u u+a->u+b u+c->u+b u+0a+0c->v v+e->v v+0e->w w+f->w+e w+0f->p 

Try it online!Try it online or verify in batch!

Ungolfed

# Initializeread universeinput, b=1initialize and(c read= input1) _ -> bIn_x + In_inputc + s0 # Create copya,d of<- inputb s0 + inputb -> s0 + input_tmpa + input_copyd s0 + 0input0b -> s1   # b,d <- c s1 + input_tmpc -> s1 + inputb + d s1 + 0input_tmp0c -> s2 #s2 +  a <-+ b_tmp x -> (ins2 the+ firsty "round" a will become 0) s2 + b_tmp -> s2 + a# +y <- min(a,x) s2 + 0b_tmp0a + 0x -> s3 #Out_"1" Compare input and x s3 + input + x -> s3 # if x(a == inputx): it's awas Fibonacci number s3s2 + 0input a + 0x -> Out_"true" #Out_"0" if there are x left => we exceeded input & stop s3# +if 0input(a +> x): ->stop Out_"false" #(we Otherwiseexceeded continuetarget) s3s2 + 0a input+  x + 0x y -> s4 #s2 Create+ copy2x of b s4 + b -> s4# +if b_tmp(a +< b_copy s4 +x): 0bx ->+= s5 #a Compute(since by +== a) +/ b_copyrestore x s5s2 +  a0a + 0y + d -> s5s2 + b s5 c # once +that's done; b_copyc <-> s5 + bd s5s2 + 0a + 0b_copy -> s6 # restore input s6 + input -> s6 s6 + 0input 0d-> s7 s7>s0 + input_copy -> s7 + input s7 +# 0input_copyand ->finally s0loop 

Try it online!

Alchemist, 205 bytes

_->b+In_e+p p+e->p+g+f p+0e->q q+g->q+e q+0g->r r+d->r+a+h r+0d->s s+e+h->s s+0e+0h->Out_"true" s+0e+h->Out_"false" s+e+0h->t t+b->t+d+c t+0b->u u+a->u+b u+c->u+b u+0a+0c->v v+e->v v+0e->w w+f->w+e w+0f->p 

Try it online!

Ungolfed

# Initialize universe b=1 and read input _ -> b + In_input + s0 # Create copy of input s0 + input -> s0 + input_tmp + input_copy s0 + 0input -> s1 s1 + input_tmp -> s1 + input s1 + 0input_tmp -> s2 # a <- b_tmp (in the first "round" a will become 0) s2 + b_tmp -> s2 + a + x s2 + 0b_tmp -> s3 # Compare input and x s3 + input + x -> s3 # if x == input: it's a Fibonacci number s3 + 0input + 0x -> Out_"true" # if there are x left => we exceeded input & stop s3 + 0input + x -> Out_"false" # Otherwise continue s3 + input + 0x -> s4 # Create copy of b s4 + b -> s4 + b_tmp + b_copy s4 + 0b -> s5 # Compute b += a + b_copy s5 +  a -> s5 + b s5  + b_copy -> s5 + b s5 + 0a + 0b_copy -> s6 # restore input s6 + input -> s6 s6 + 0input -> s7 s7 + input_copy -> s7 + input s7 + 0input_copy -> s0 

Try it online!

Alchemist, 205 134 bytes

Big thanks to ASCII-only for rather clever merging of states, saving 71 bytes!!

_->In_x+c+u u+b->u+a+d u+0b->v v+c->v+b+d v+0c->w w+a+x->w+y w+0a+0x->Out_"1" w+a+0x->Out_"0" w+0a+x+y->w+2x w+0a+0y+d->w+c w+0d+0a->u 

Try it online or verify in batch!

Ungolfed

# read input, initialize (c = 1) _ -> In_x + c + s0 # a,d <- b s0 + b -> s0 + a + d s0 + 0b -> s1   # b,d <- c s1 + c -> s1 + b + d s1 + 0c -> s2 s2 +  a + x -> s2 + y # y <- min(a,x) s2 + 0a + 0x -> Out_"1" # if (a == x): was Fibonacci s2 +  a + 0x -> Out_"0" # if (a > x): stop (we exceeded target) s2 + 0a +  x + y -> s2 + 2x # if (a < x): x += a (since y = a) / restore x s2 + 0a + 0y + d -> s2 + c # once that's done; c <- d s2 + 0a + 0d->s0 # and finally loop 
Bounty Awarded with 100 reputation awarded by Deadcode
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Alchemist, 205 bytes

_->b+In_e+p p+e->p+g+f p+0e->q q+g->q+e q+0g->r r+d->r+a+h r+0d->s s+e+h->s s+0e+0h->Out_"true" s+0e+h->Out_"false" s+e+0h->t t+b->t+d+c t+0b->u u+a->u+b u+c->u+b u+0a+0c->v v+e->v v+0e->w w+f->w+e w+0f->p 

Try it online!

Ungolfed

# Initialize universe b=1 and read input _ -> b + In_input + s0 # Create copy of input s0 + input -> s0 + input_tmp + input_copy s0 + 0input -> s1 s1 + input_tmp -> s1 + input s1 + 0input_tmp -> s2 # a <- b_tmp (in the first "round" a will become 0) s2 + b_tmp -> s2 + a + x s2 + 0b_tmp -> s3 # Compare input and x s3 + input + x -> s3 # if x == input: it's a Fibonacci number s3 + 0input + 0x -> Out_"true" # if there are x left => we exceeded input & stop s3 + 0input + x -> Out_"false" # Otherwise continue s3 + input + 0x -> s4 # Create copy of b s4 + b -> s4 + b_tmp + b_copy s4 + 0b -> s5 # Compute b += a + b_copy s5 + a -> s5 + b s5 + b_copy -> s5 + b s5 + 0a + 0b_copy -> s6 # restore input s6 + input -> s6 s6 + 0input -> s7 s7 + input_copy -> s7 + input s7 + 0input_copy -> s0 

Try it online!