Skip to main content
deleted 73 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Brain-Flak, 122 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>){<>({}<>)}{}

Try it online!

Works with all integers, 142138 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))[({}[{}]{})]<<{({}[()]<<><<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>)<>([]){({}[()]<({}<>)<>>)}<>

Try it online!Try it online!

The difference here is that while the first uses

{<>({}<>)}{}

To pull all the items from the off stack onto the on stack this one has to use

<>({}){({}[()]<({}<>)<>>)}<>

The first one pulls until it hits a zero and then stops, so this will fail to produce the correct result when there is a zero before the first swapped value. The second checks the height and pulls that many times, thus it will work for any list.

Brain-Flak, 122 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>){<>({}<>)}{}

Try it online!

Works with all integers, 142 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))[({}[{}])]<{({}[()]<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>)<>([]){({}[()]<({}<>)<>>)}<>

Try it online!

Brain-Flak, 122 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>){<>({}<>)}{}

Try it online!

Works with all integers, 138 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>)<>([]){({}[()]<({}<>)<>>)}<>

Try it online!

The difference here is that while the first uses

{<>({}<>)}{}

To pull all the items from the off stack onto the on stack this one has to use

<>({}){({}[()]<({}<>)<>>)}<>

The first one pulls until it hits a zero and then stops, so this will fail to produce the correct result when there is a zero before the first swapped value. The second checks the height and pulls that many times, thus it will work for any list.

Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Brain-Flak, 122 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))([{}]{})<{({}()<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>){<>({}<>)}{}

Try it online!

Works with all integers, 142 bytes

(([{}]{()<({}[()]<({}<>)<>>)>}{})<(({}({}))[({}[{}])]<{({}[()]<<>({}<>)>)}{}>)>())<>({}<<>{({}[()]<({}<>)<>>)}{}>)<>([]){({}[()]<({}<>)<>>)}<>

Try it online!