import random as r len_map = int(input('Введите ширину карты: ')) map = [] for y in range(len_map): map.append([]) for x in range(len_map): map[y].append(r.randint(1, 100)) print(map[y]) score = 0 position = { 'x': 0, 'y': 0 } score = map[position['y']][position['x']] while position['x'] + 1 != len_map or position['y'] + 1 != len_map: if position['x'] + 1 < len_map: if position['y'] + 1 < len_map: if map[position['y']][position['x'] + 1] >= map[position['y'] + 1][position['x']]: position['x'] += 1 score += map[position['y']][position['x']] continue else: position['y'] += 1 score += map[position['y']][position['x']] continue else: position['x'] += 1 score += map[position['y']][position['x']] continue position['y'] += 1 score += map[position['y']][position['x']] print(f'максимум очков: {score}') position['x'] = 0 position['y'] = 0 score = map[position['y']][position['x']] while position['x'] + 1 != len_map or position['y'] + 1 != len_map: if position['x'] + 1 < len_map: if position['y'] + 1 < len_map: if map[position['y']][position['x'] + 1] <= map[position['y'] + 1][position['x']]: position['x'] += 1 score += map[position['y']][position['x']] continue else: position['y'] += 1 score += map[position['y']][position['x']] continue else: position['x'] += 1 score += map[position['y']][position['x']] continue position['y'] += 1 score += map[position['y']][position['x']] print(f'минимум очков: {score}')