Skip to content

Instantly share code, notes, and snippets.

@wcharczuk
Created December 8, 2019 06:00
Show Gist options
  • Save wcharczuk/4212d65fdeccfbca1883ca10af21edde to your computer and use it in GitHub Desktop.
Save wcharczuk/4212d65fdeccfbca1883ca10af21edde to your computer and use it in GitHub Desktop.
A small intcode example; takes a user input, and returns -1 if its < 8, 0 if its == 8, and 1 otherwise
.limit
.userInput
.temp
add 0 8 .limit
input .userInput
equals &.userInput &.limit .temp
jump-if-false &.temp pc(6)
print 0
jump-if-false 0 sym(-1)
less-than &.userInput &.limit .temp
jump-if-false &.temp pc(6)
print -1
jump-if-false 0 sym(-1)
print 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment