Statistics

Problem Statement for "Chessboard"

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

  1. "1"

    Returns: "a1"

  2. "2"

    Returns: "b1"

  3. "3"

    Returns: "c1"

  4. "4"

    Returns: "d1"

  5. "5"

    Returns: "e1"

  6. "6"

    Returns: "f1"

  7. "7"

    Returns: "g1"

  8. "8"

    Returns: "h1"

  9. "9"

    Returns: "a2"

  10. "10"

    Returns: "b2"

  11. "11"

    Returns: "c2"

  12. "12"

    Returns: "d2"

  13. "13"

    Returns: "e2"

  14. "14"

    Returns: "f2"

  15. "15"

    Returns: "g2"

  16. "16"

    Returns: "h2"

  17. "17"

    Returns: "a3"

  18. "18"

    Returns: "b3"

  19. "19"

    Returns: "c3"

  20. "20"

    Returns: "d3"

  21. "21"

    Returns: "e3"

  22. "22"

    Returns: "f3"

  23. "23"

    Returns: "g3"

  24. "24"

    Returns: "h3"

  25. "25"

    Returns: "a4"

  26. "26"

    Returns: "b4"

  27. "27"

    Returns: "c4"

  28. "28"

    Returns: "d4"

  29. "29"

    Returns: "e4"

  30. "30"

    Returns: "f4"

  31. "31"

    Returns: "g4"

  32. "32"

    Returns: "h4"

  33. "33"

    Returns: "a5"

  34. "34"

    Returns: "b5"

  35. "35"

    Returns: "c5"

  36. "36"

    Returns: "d5"

  37. "37"

    Returns: "e5"

  38. "38"

    Returns: "f5"

  39. "39"

    Returns: "g5"

  40. "40"

    Returns: "h5"

  41. "41"

    Returns: "a6"

  42. "42"

    Returns: "b6"

  43. "43"

    Returns: "c6"

  44. "44"

    Returns: "d6"

  45. "45"

    Returns: "e6"

  46. "46"

    Returns: "f6"

  47. "47"

    Returns: "g6"

  48. "48"

    Returns: "h6"

  49. "49"

    Returns: "a7"

  50. "50"

    Returns: "b7"

  51. "51"

    Returns: "c7"

  52. "52"

    Returns: "d7"

  53. "53"

    Returns: "e7"

  54. "54"

    Returns: "f7"

  55. "55"

    Returns: "g7"

  56. "56"

    Returns: "h7"

  57. "57"

    Returns: "a8"

  58. "58"

    Returns: "b8"

  59. "59"

    Returns: "c8"

  60. "60"

    Returns: "d8"

  61. "61"

    Returns: "e8"

  62. "62"

    Returns: "f8"

  63. "63"

    Returns: "g8"

  64. "64"

    Returns: "h8"

  65. "a1"

    Returns: "1"

  66. "b1"

    Returns: "2"

  67. "c1"

    Returns: "3"

  68. "d1"

    Returns: "4"

  69. "e1"

    Returns: "5"

  70. "f1"

    Returns: "6"

  71. "g1"

    Returns: "7"

  72. "h1"

    Returns: "8"

  73. "a2"

    Returns: "9"

  74. "b2"

    Returns: "10"

  75. "c2"

    Returns: "11"

  76. "d2"

    Returns: "12"

  77. "e2"

    Returns: "13"

  78. "f2"

    Returns: "14"

  79. "g2"

    Returns: "15"

  80. "h2"

    Returns: "16"

  81. "a3"

    Returns: "17"

  82. "b3"

    Returns: "18"

  83. "c3"

    Returns: "19"

  84. "d3"

    Returns: "20"

  85. "e3"

    Returns: "21"

  86. "f3"

    Returns: "22"

  87. "g3"

    Returns: "23"

  88. "h3"

    Returns: "24"

  89. "a4"

    Returns: "25"

  90. "b4"

    Returns: "26"

  91. "c4"

    Returns: "27"

  92. "d4"

    Returns: "28"

  93. "e4"

    Returns: "29"

  94. "f4"

    Returns: "30"

  95. "g4"

    Returns: "31"

  96. "h4"

    Returns: "32"

  97. "a5"

    Returns: "33"

  98. "b5"

    Returns: "34"

  99. "c5"

    Returns: "35"

  100. "d5"

    Returns: "36"

  101. "e5"

    Returns: "37"

  102. "f5"

    Returns: "38"

  103. "g5"

    Returns: "39"

  104. "h5"

    Returns: "40"

  105. "a6"

    Returns: "41"

  106. "b6"

    Returns: "42"

  107. "c6"

    Returns: "43"

  108. "d6"

    Returns: "44"

  109. "e6"

    Returns: "45"

  110. "f6"

    Returns: "46"

  111. "g6"

    Returns: "47"

  112. "h6"

    Returns: "48"

  113. "a7"

    Returns: "49"

  114. "b7"

    Returns: "50"

  115. "c7"

    Returns: "51"

  116. "d7"

    Returns: "52"

  117. "e7"

    Returns: "53"

  118. "f7"

    Returns: "54"

  119. "g7"

    Returns: "55"

  120. "h7"

    Returns: "56"

  121. "a8"

    Returns: "57"

  122. "b8"

    Returns: "58"

  123. "c8"

    Returns: "59"

  124. "d8"

    Returns: "60"

  125. "e8"

    Returns: "61"

  126. "f8"

    Returns: "62"

  127. "g8"

    Returns: "63"

  128. "h8"

    Returns: "64"

  129. "64"

    Returns: "h8"

  130. "8"

    Returns: "h1"

  131. "40"

    Returns: "h5"

  132. "12"

    Returns: "d2"

  133. "10"

    Returns: "b2"

  134. "16"

    Returns: "h2"

  135. "29"

    Returns: "e4"

  136. "24"

    Returns: "h3"

  137. "9"

    Returns: "a2"

  138. "h7"

    Returns: "56"

  139. "2"

    Returns: "b1"

  140. "1"

    Returns: "a1"

  141. "46"

    Returns: "f6"

  142. "c5"

    Returns: "35"

  143. "a2"

    Returns: "9"

  144. "3"

    Returns: "c1"

  145. "60"

    Returns: "d8"

  146. "56"

    Returns: "h7"

  147. "25"

    Returns: "a4"

  148. "b4"

    Returns: "26"

  149. "45"

    Returns: "e6"

  150. "h8"

    Returns: "64"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: