• Othello Moves Over Stepping Stones, Decorators and Environments!

Hello, checkiomates🐱‍👤!

I want to tell you, that Python was first released by Guido Van Rossum on February 20th, 1991, and this week marked its 32nd anniversary!

CheckiO is generally a fun and playing with code. But the missions may be dedicated to the games itself as well. In today's news we offer you to get familiar with well-known game Reversi and a new puzzle about placing numbered stones. There is also an easear about extracting a number from a string of characters.

The offered articles are about dictionary dispatch pattern, decorators and using virtual environments in Python. So, let's start!

🏁 MISSIONS:

Reveal the Number by freeman_lex - You are given a string of different characters (letters, digits and other symbols). The goal is to "extract" the number from the string: concatenate only digits, number sign and "." (if present) and return the result in number format.

```reveal_num("F0(t}") == 0
reveal_num("Utc&g") == None

Reversi: Othello Moves by freeman_lex - Reversi is a strategy board game for two players, played on an 8×8 uncheckered board. It was invented in 1883. Othello, a variant with a fixed initial setup of the board, was patented in 1971. For the purposes of this mission you need to write a move generator to find all moves available for Othello against Desdemona on the given board.

```othello_moves([(3, 3), (4, 4)], [(3, 4), (4, 3), (2, 3)]) == [
(1, 3, 1),
(2, 4, 1),
(3, 5, 1),
(4, 2, 1),
(5, 3, 1),
]
othello_moves([(3, 3), (4, 4), (2, 3), (2, 5)], [(3, 4), (4, 3), (2, 4)]) == [
(1, 4, 2),
(5, 2, 2),
(1, 5, 1),
(3, 5, 1),
(4, 2, 1),
(4, 5, 1),
(5, 3, 1),
]```

Stepping Stones Puzzle by freeman_lex - You have got a certain number of 🟤 stones (1 point each) anywhere on the board. Now you add ⚪ stones with increasing points value (2, 3, 4 ...) on the board. The rule of placement is: you can only put down a ⚪ stone with value k if sum of values of it's eight neighbors (🟤 and/or ⚪) is k. Given the board size n and the initial coordinates of the 🟤 stones, your function should return the highest numbered stone in the longest sequence of stones that can be placed consecutively on the board within the rules of the puzzle.

```stepping_stones(4, [(0, 0), (3, 3)]) == 1
stepping_stones(5, [(0, 1), (1, 1), (2, 2)]) == 10
stepping_stones(6, [(2, 0), (5, 3), (1, 3), (0, 0)]) == 19```

Close look to the articles I've mentioned!

💡ARTICLES:

Python Virtual Environments: A Primer - Throughout the tutorial, you built a thorough understanding of what virtual environments are, why you need them, how they function internally, and how you can manage them on your system.

Unleashing the Power of Python Decorators - A decorator is a special type of function in Python that is used to modify or extend the behavior of other functions. Decorators allow you to easily add additional functionality to existing functions, classes, and methods, making it possible to reuse code, reduce code duplication, and improve overall code maintainability.

Dictionary Dispatch Pattern in Python - The whole idea of dictionary dispatch is that we run different functions based on the value of a variable, instead of using conditional statement for each of the values. With dictionary dispatch we can replace any block of conditionals with a simple lookup into Python's dict.

A bit of humour at the end!