Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Youre on a treasure hunt through a series of caves deep in the jungle. You are equipped with a certain number of flashlights, capable of

Youre on a treasure hunt through a series of caves deep in the jungle. You are equipped with a certain number of flashlights, capable of finding specific treasures depending on the flashlights integer value.

How this works:

1.Create a random series of caves (integer array). There must be between 1 and 10 caves.

2.Fill each cave with a treasure (an integer between 1 and 9).

3.Randomly decide how many flashlights to take(integer array). You will take between 1 and 4 flashlights.

4.Randomly choose which flashlights to take. Flashlights will be represented by an integer value between 1 and 1,000,000.

Can this flashlight find that treasure?:

A caves treasure, represented by an integer value between 1 and 9 can only be discovered by a flashlight whose values recursive sum of its digits make up the caves value.

Example:

Flashlight value = 1174 so 1+1+7+4 = 13 and 1+3 = 4.

Therefore, any cave with a value of 4 can have its treasure found by this flashlight

Create two methods, treasureHunt and searchCave. These methods will work together, treasureHunt will call searchCave. treasureHunt will be written iteratively and searchCave will be written recursively.Please note example below for formatting and further clues/help:

Main method link;

https://ibb.co/DpHp6nF

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

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

Carry out an interview and review its success.

Answered: 1 week ago