Skip to main content
deleted 60 characters in body
Source Link
Joao-3
  • 2.1k
  • 7
  • 22

Python 3.11, 92 86 85 8562 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i==p[p[i]];f(p,(i+3, p[i+2])[p[k]<1])

Attempt This Online!Attempt This Online!

Takes in a program as a list, mutates the original list with an error (you need a variable and try/except to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=f(p,(i+3,p[i+2])[p[k]<1])

If B is less than 1, then setrecursively call with i toas C, otherwise add 3.

Python 3.11, 92 86 85 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i=(i+3, p[i+2])[p[k]<1]

Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=(i+3,p[i+2])[p[k]<1]

If B is less than 1, then set i to C, otherwise add 3.

Python 3.11, 92 86 85 62 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 p[k:=p[i+1]]-=p[p[i]];f(p,(i+3,p[i+2])[p[k]<1])

Attempt This Online!

Takes in a program as a list, mutates the original list with an error (you need a variable and try/except to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

f(p,(i+3,p[i+2])[p[k]<1])

If B is less than 1, then recursively call with i as C, otherwise add 3.

deleted 85 characters in body
Source Link
Joao-3
  • 2.1k
  • 7
  • 22

Python 3.11, 92 86 8685 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i=p[k]<1and p[i+2]or =p[p[i]];i=(i+3, p[i+2])[p[k]<1]

Attempt This Online!Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=p[k]<1and p[i+2]or i=(i+3,p[i+2])[p[k]<1]

If B is less than 1, then set i to C, otherwise add 3. Due to how Python works, ... and ... or ... is shorter than ... if ... else ....

Python 3.11, 92 86 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i=p[k]<1and p[i+2]or i+3

Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=p[k]<1and p[i+2]or i+3

If B is less than 1, then set i to C, otherwise add 3. Due to how Python works, ... and ... or ... is shorter than ... if ... else ....

Python 3.11, 92 86 85 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i=(i+3, p[i+2])[p[k]<1]

Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=(i+3,p[i+2])[p[k]<1]

If B is less than 1, then set i to C, otherwise add 3.

deleted 31 characters in body
Source Link
Joao-3
  • 2.1k
  • 7
  • 22

Python 3.11, 9292 86 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 i=0
 while i in range(len(p)):
  p[k:=p[i+1]]-=p[p[i]]
  i=p[k]<1and=p[p[i]];i=p[k]<1and p[i+2]or i+3

Attempt This Online!Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran.

 i=0

Initialize and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

  p[k:=p[i+1]]-=p[p[i]]=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

  i=p[k]<1and p[i+2]or i+3

If B is less than 1, then set i to C, otherwise add 3. Due to how Python works, ... and ... or ... is shorter than ... if ... else ....

Python 3.11, 92 bytes

This is my answer, so don't suggest copying from other answers.

def f(p):
 i=0
 while i in range(len(p)):
  p[k:=p[i+1]]-=p[p[i]]
  i=p[k]<1and p[i+2]or i+3

Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p):

Define the main function, p is the program to be ran.

 i=0

Initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

  p[k:=p[i+1]]-=p[p[i]]

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

  i=p[k]<1and p[i+2]or i+3

If B is less than 1, then set i to C, otherwise add 3. Due to how Python works, ... and ... or ... is shorter than ... if ... else ....

Python 3.11, 92 86 bytes

This is my answer, so don't suggest copying from other answers.

def f(p,i=0):
 while i in range(len(p)):p[k:=p[i+1]]-=p[p[i]];i=p[k]<1and p[i+2]or i+3

Attempt This Online!

Takes in a program as a list, mutates the original list (you need a variable to access the results).

Explanation:

def f(p,i=0):

Define the main function, p is the program to be ran and initialize the instruction pointer as i.

 while i in range(len(p)):

Loop until i is outside the list.

p[k:=p[i+1]]-=p[p[i]];

Subtract A from B and store in B. Also assigns B as k to shave off bytes.

i=p[k]<1and p[i+2]or i+3

If B is less than 1, then set i to C, otherwise add 3. Due to how Python works, ... and ... or ... is shorter than ... if ... else ....

Source Link
Joao-3
  • 2.1k
  • 7
  • 22
Loading