Back
Close

Toads and Frogs

Statement
In the Frog Jumping Game, we have [[n]] red frogs (in the left hand side) and [[n]] blue frogs (in the right hand side) and we want to move the left hand side frog first to the right hand side. At start, there is only one space (in the middle of the line) which separates the two sets of frogs. For further information, see: https://nzmaths.co.nz/leap-frogs NB: Starting to move reds or blues at first will lead to the same result. Example: for n=4, we have: Starting positions: R R R R _ B B B B Ending positions: B B B B _ R R R R Rules: -The left set of frogs can only move right, the right set of frogs can only move left. -frogs can move forward one space, or move two spaces by jumping over another frogs. -The puzzle is solved when the two sets of frogs have switched positions Your job is to find the least number of steps that we need to solve the puzzle by following the rules.

Input description
[[n]] : number of frogs on each side

Output description
The least number of steps that we need to solve the puzzle by following the rules.

Constraints
0<[[n]]<550

Game modes

Test cases
Test 1 Test
Input
2
Output
8

Validator 1 Validator
Input
5
Output
35

Test 2 Test
Input
10
Output
120

Validator 2 Validator
Input
100
Output
10200

Test 3 Test
Input
11
Output
143

Validator 3 Validator
Input
111
Output
12543

Test 4 Test
Input
500
Output
251000

Validator 4 Validator
Input
501
Output
252003

Solution language

Solution

Stub generator input