Пример #1
0
def main():
  """Compute the answer for the given grid and food amounts."""

  food = random.randrange(MAX_FOOD + 1)
  print('Food: {0}.'.format(food))

  grid_size = random.randrange(1, MAX_GRID_SIZE + 1)
  print('Grid size: {0}.'.format(grid_size))

  grid = create_grid(grid_size)

  print('\nThe Grid...\n')
  print_grid(grid)
  print()

  least_left, steps = walk_grid.answer_and_steps(grid, food)

  print('\nResult: {0} with steps {1}.'.format(least_left, steps))
Пример #2
0
def main():
  """Compute the answer for the given grid and food amounts."""

  opts = get_args()

  if opts.food > MAX_FOOD:
    print('WARNING, you have exceeded the MAX FOOD size: {0}'.format(MAX_FOOD))
  if opts.grid_size > MAX_GRID_SIZE:
    print('WARNING, you have exceeded the MAX GRID SIZE: {0}'.format(
        MAX_GRID_SIZE))

  print('Food: {0}.'.format(opts.food))
  print('Grid size: {0}.'.format(opts.grid_size))

  grid = create_grid(opts.grid_size)
  print('\nThe Grid...\n')
  print_grid(grid)
  print()

  least_left, steps = walk_grid.answer_and_steps(grid, opts.food)

  print('\nResult: {0} with steps {1}.'.format(least_left, steps))