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 moving(row, col, direction): if direction == "up": return row - 1, col if direction == "down": return row + 1, col if direction == "left": return row, col - 1 if direction == "right": return row, col + 1 size = int(input()) directions = input().split(', ') matrix = [] s_row = 0 s_col = 0 for row in range(size): row_elements = list(input()) for col in range(size): if row_elements[col] == "s": s_row = row s_col = col matrix.append(row_elements) hazelnuts = 0 while True: matrix[s_row][s_col] = "*" for direction in directions: next_row, next_col = moving(s_row, s_col, direction) if next_row < 0 or next_col < 0 or next_row >= size or next_col >= size: print(f'The squirrel is out of the field.') break s_row, s_col = next_row, next_col if matrix[s_row][s_col] == "t": print(f'Unfortunately, the squirrel stepped on a trap...') break if matrix[s_row][s_col] == "h": hazelnuts += 1 if hazelnuts == 3: print(f'Good job! You have collected all hazelnuts!') break 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)