Skip to main content
added 93 characters in body
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Keg + Reg, 17-ir, 16 bytes

"(!;2/|';½|':"=['_"|_

Try it online!

I know it isnt the nicest looking answer, but it beats Brachylog, so I'm happy with that.Try it online!

Explained:

  1. Takes the implicit input and right shifts the accumulators value to the bottom

  2. Repeat the following (length of stack - 1 divided by 2) times

2.1. Shift the accumulator back to the top

2.2. Compare for equality with the first part of the command

2.2.1. If true, replace the accumulator, otherwise pop the replacement

Input is taken as the initial acc value concatenated with the source. E.g.

010011000
  • First char is acc value
  • Rest is program

Keg + Reg, 17 bytes

"(!;2/|':"=['_"|_

Try it online!

I know it isnt the nicest looking answer, but it beats Brachylog, so I'm happy with that.

Explained:

  1. Takes the implicit input and right shifts the accumulators value to the bottom

  2. Repeat the following (length of stack - 1 divided by 2) times

2.1. Shift the accumulator back to the top

2.2. Compare for equality with the first part of the command

2.2.1. If true, replace the accumulator, otherwise pop the replacement

Input is taken as the initial acc value concatenated with the source. E.g.

010011000
  • First char is acc value
  • Rest is program

Keg, -ir, 16 bytes

"(!;½|':"=['_"|_

Try it online!

Explained:

  1. Takes the implicit input and right shifts the accumulators value to the bottom

  2. Repeat the following (length of stack - 1 divided by 2) times

2.1. Shift the accumulator back to the top

2.2. Compare for equality with the first part of the command

2.2.1. If true, replace the accumulator, otherwise pop the replacement

Input is taken as the initial acc value concatenated with the source. E.g.

010011000
  • First char is acc value
  • Rest is program
Source Link
lyxal
  • 34.3k
  • 2
  • 64
  • 141

Keg + Reg, 17 bytes

"(!;2/|':"=['_"|_

Try it online!

I know it isnt the nicest looking answer, but it beats Brachylog, so I'm happy with that.

Explained:

  1. Takes the implicit input and right shifts the accumulators value to the bottom

  2. Repeat the following (length of stack - 1 divided by 2) times

2.1. Shift the accumulator back to the top

2.2. Compare for equality with the first part of the command

2.2.1. If true, replace the accumulator, otherwise pop the replacement

Input is taken as the initial acc value concatenated with the source. E.g.

010011000
  • First char is acc value
  • Rest is program