Skip to content

Commit

Permalink
Use the minimum tape size when generating the machine.
Browse files Browse the repository at this point in the history
  • Loading branch information
ealter committed Aug 3, 2017
1 parent 344478f commit abd0ecf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 0 additions & 4 deletions vim_turing_machine/vim_constants.py
Expand Up @@ -10,10 +10,6 @@

VIM_TAPE_WRAP_POSITION = 40

VIM_TAPE_NUM_ROWS = 4

VIM_TAPE_MAX_LENGTH = VIM_TAPE_WRAP_POSITION * VIM_TAPE_NUM_ROWS

VIM_LOG_TAPE_AND_STATE = '`ly$@"'

VIM_TEMPLATE = """0/_v1\rnf-ly$@"
Expand Down
6 changes: 2 additions & 4 deletions vim_turing_machine/vim_machine.py
Expand Up @@ -8,16 +8,14 @@
from vim_turing_machine.vim_constants import VIM_MOVE_TAPE_FORWARDS
from vim_turing_machine.vim_constants import VIM_NEXT_STATE
from vim_turing_machine.vim_constants import VIM_RUN_REGISTER
from vim_turing_machine.vim_constants import VIM_TAPE_MAX_LENGTH
from vim_turing_machine.vim_constants import VIM_TAPE_WRAP_POSITION
from vim_turing_machine.vim_constants import VIM_TEMPLATE


def create_initial_tape(input_tape):
"""Generates the initial tape by padding the input and wrapping"""
padding_length = VIM_TAPE_MAX_LENGTH - len(input_tape)
if padding_length > 0:
input_tape += padding_length * [BLANK_CHARACTER]
padding_length = VIM_TAPE_WRAP_POSITION - len(input_tape) % VIM_TAPE_WRAP_POSITION
input_tape += padding_length * [BLANK_CHARACTER]

initial_tape = []
for index, value in enumerate(input_tape):
Expand Down

0 comments on commit abd0ecf

Please sign in to comment.