TopCoder problem "Chessboard" used in SRM 344 (Division II Level One)



Problem Statement

    

A 8x8 chessboard is usually marked as follows: rows are marked by digits, 1 through 8, and columns are marked by letters, 'a' through 'h'. A cell is described by its column mark and then its row mark, like "e4".

While working on a chess program, you need to convert these descriptions into your internal cell numbers and back. Internally, cells are numbered row-by-row from 1 to 64 in your program, i.e., cell "a1" has number 1, cell "b1" has number 2, cell "c1" has number 3, ..., cell "h8" has number 64.

Given a String cell, describing either the cell mark or the cell number, change the notation (i.e., if you're given the mark you need to return the number, and vice versa).

 

Definition

    
Class:Chessboard
Method:changeNotation
Parameters:String
Returns:String
Method signature:String changeNotation(String cell)
(be sure your method is public)
    
 

Constraints

-cell will contain either a cell mark or a cell number.
-If cell contains a cell mark, it will contain exactly 2 characters: a lowercase letter between 'a' and 'h', inclusive, followed by a digit between '1' and '8', inclusive.
-If cell contains a cell number, it will be an integer between 1 and 64, inclusive, without leading zeros.
 

Examples

0)
    
"1"
Returns: "a1"
1)
    
"2"
Returns: "b1"
2)
    
"26"
Returns: "b4"
3)
    
"c1"
Returns: "3"
4)
    
"e4"
Returns: "29"
5)
    
"h8"
Returns: "64"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7576

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10668&pm=7576

Writer:

Petr

Testers:

PabloGilberto , brett1479 , Yarin , Olexiy

Problem categories:

Simple Math