Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
def make_a_move(row_, col_, matrix): found_hazelnuts = 0 if not (0 <= row_ < len(matrix) and 0 <= col_ < len(matrix)): print("The squirrel is out of the field.") return if matrix[row_][col_] == 't': print("Unfortunately, the squirrel stepped on a trap...") return if matrix[row_][col_] == 'h': found_hazelnuts += 1 matrix[row_][col_] = '*' return found_hazelnuts, matrix rows = int(input()) commands = input().split(", ") field = [] hazelnuts = 0 die = False for _ in range(rows): field.append(list(input())) squirrel_position = [] for row in range(rows): for col in range(rows): if field[row][col] == 's': squirrel_position = [row, col] field[squirrel_position[0]][squirrel_position[1]] = "*" for command in commands: if command == 'left': squirrel_position[1] -= 1 elif command == 'right': squirrel_position[1] += 1 elif command == 'down': squirrel_position[0] += 1 elif command == 'up': squirrel_position[0] -= 1 result = make_a_move(squirrel_position[0], squirrel_position[1], field) if not result: die = True break count_hazelnuts, field = result[0], result[1] hazelnuts += count_hazelnuts if hazelnuts == 3: print("Good job! You have collected all hazelnuts!") break if not die and hazelnuts < 3: print("There are more hazelnuts to collect.") print(f"Hazelnuts collected: {hazelnuts}")
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)