Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programing public static int game_recursion(int[][] board) { } The game involves two players (my kid and myself). The game is played in a 5-row

Java programing

public static int game_recursion(int[][] board) { }

The game involves two players (my kid and myself).

The game is played in a 5-row equilateral triangle game board containing 15 holes (5 holes per side of the triangle).

At the beginning of the game, there is one open hole and 14 holes occupied by Lego pieces. My kid has assigned a numerical value to each piece depending on the size of the Lego piece.

Since I am very bad in the game, my kid always allows me start the game (I will always do the first move). After, we alternate turns.

A valid move consist of picking up a Lego piece to jump it over an adjacent Lego piece, landing on an empty hole adjacent to the jumped piece. The Lego piece that is jumped over is removed from the board. Jumps must be in straight lines (horizontally or diagonally).

The score of a move is the product of the two Lego pieces involved in the jump. The total score of a player is the sum of the scores of their jumps.

The game ends when a player has no possible jumps to make.

Test cases 1: Input:

0

1 1

1 1 1

1 1 1 1

1 1 1 1 1

output: 0

Test cases 2: Input:

1

1 1

1 1 1

1 1 1 1

1 1 0 100 1

Output: 99

Test cases 3: Input:

55

99 24

77 93 19

27 26 5 53

9 90 48 44 0

Output: 3381

Test cases 4: Input:

56

12 56

56 16 51

34 56 56 0

56 22 56 43 56

Output: 2806

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago