MCPcopy Create free account
hub / github.com/careercup/ctci / convertBoardToInt

Method convertBoardToInt

java/Chapter 17/Question17_2/Question.java:5–21  ·  view source on GitHub ↗
(char[][] board)

Source from the content-addressed store, hash-verified

3public class Question {
4
5 public static int convertBoardToInt(char[][] board) {
6 int factor = 1;
7 int sum = 0;
8 for (int i = 0; i < board.length; i++) {
9 for (int j = 0; j < board[i].length; j++) {
10 int v = 0;
11 if (board[i][j] == 'x') {
12 v = 1;
13 } else if (board[i][j] == 'o') {
14 v = 2;
15 }
16 sum += v * factor;
17 factor *= 3;
18 }
19 }
20 return sum;
21 }
22
23 public static void main(String[] args) {
24 char[][] board = {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected