Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task Davy has buried pieces of his ancient artifacts underground. The artifacts are hidden in an area split into an NxN grid of square cells.

Task Davy has buried pieces of his ancient artifacts underground. The artifacts are hidden in an area split into an NxN grid of square cells. The rows are numbered from 1 to N. The columns are labeled with consecutive English upper-case letters (A, B, C, etc.). Each cell is identified by a string composed of its row number followed by its column number: for example, \"9C\" denotes the third cell in the 9th row, and \"150\" denotes the fourth cell in the 15th row. Jack was out looking for the artifact pieces in this area. He chose some map cells in which to search for artifact pieces. He is able to reconstruct an artifact if he found all of the pieces of an artifact. The goal is to count the number of artifacts for which he has found all of the pieces, as well the number of artifacts for which he's found some but not all of the pieces. Davy hid the pieces of each ar fact in adjacent cells of an area that is rectangular in shape and no larger than 4 cells in area, with at most one piece in each cell. The locations of the artifacts are given as a string artifacts, containing pairs of positions describing respectively the top-left and bottom-right corner cells where pieces of an artifact is buried. The artifacts locations are separated by a comma. For example, for the following input artifacts = \"1B 2C, 2D 4D\", N = 4, the artifact pieces are as shown below (labeled with 1s and 2s) Task 1 Python For example, for the following input artifacts = \"1B 2C, 2D 4D\", N 4, the artifact pieces are as shown below (labeled with 1s and 2s). A B C D +--- 1 | 1 | +-- 21 | 1 | 1 | 2 | + 3 | | 2 | 4 The coordinates where Jack searched are given as a string searched, containing positions describing the map cells where he searched: for the map in the example shown above and searched = \"2B 2D 3D 4D 4A\", he will have found artifact pieces in the cells marked with X and found nothing in the cells marked with o. A B C D + 2 | X 1 3 4101 Task 1 Python Artifacts in artifacts and locations in searched may appear in any order. Write a function: public int[] solution(int n, String artifacts, String that, given the size of the map N and two strings artifacts, searched that describe the positions of hidden artifacts and searched locations respectively, returns an integer array with two elements: the count of artifacts which can be reconstructed and the count of artifacts for which some but not all pieces were found. For instance, given N 4, artifacts = \"1B 2C, 2D 4D\", searched = \"2B 2D 3D 4D 4A\", your function should return [1,1] as explained above. . B + 1 1 21 2 3 Given N = 3, artifacts = \"1A 1B, 2C 2C\", searched = \"18\", your function should return [0,1], because he found a piece of one Task 1 Python count of artifacts for which some but not all pieces were found. For instance, given N = 4, artifacts = \"1B 2C, 2D 4D\", searched = \"2B 2D 3D 4D 4A\", your function should return [1,1 as explained above. A B C +---+ --+---+ 1 | 1 | XI. 1 2 | - | 21 3 | | +---+--- Given N = 3, artifacts = \"1A 1B, 2C 20\", searched = \"16\", your function should return [0,1], because he found a piece of one artifact but could not reconstruct any artifacts. Assume that: . Nis an integer within the range [1..26]; string artifacts contains the descriptions of rectangular areas where artifacts are buried, no greater than 4 cells in size; there can be at most one piece located on any map cell;. each map cell can appear in string searched at most once; string artifacts and string searched contains only valid positions given in specified format. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.

.

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

Venture capital and the finance of innovation

Authors: Andrew Metrick

2nd Edition

9781118137888, 470454709, 1118137884, 978-0470454701

More Books

Students also viewed these Programming questions