-
Code def field_to_coordinate(field): x,y = field[0], field[1:] return (ord(x) - 97, int(y) - 1)
Test Cases test.assert_equals(field_to_coordinate('c1'), (2, 0)) test.assert_equals(field_to_coordinate('d2'), (3, 1)) test.assert_equals(field_to_coordinate('f5'), (5, 4))
Output:
-
Code import re- def field_to_coordinate(field):
# Compute a coordinate which represents specified `field`,# i.e. if field = 'd2' returned value should be [3, 1]x, y = re.search(r"([^\d])(\d+)", field).groups()- x,y = field[0], field[1:]
- return (ord(x) - 97, int(y) - 1)
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}