Minecraft is a popular video game where players explore their 3D block-made world in search of materials. Throughout the player's adventure, they may encounter various mobs, including cows, pigs, zombies, and creepers (here, each mob is an individual entity). Players are encouraged to create their own home base out of whatever blocks they choose.
It is not necessary to have played Minecraft to understand or complete this assignment, but it is a fun game.
Because of quarantine, you and your friends virtually spend time together by playing Minecraft with each other. You and your friends decide to create your main base in a lovely, spacious beach biome and plan to build your home on the ocean cliff. Your friend creates a rectangular floor plan out of various Minecraft blocks. However, the living room faces south, but you were hoping to be able to see the sunset from the living room. If the floor plan were rotated 90 degrees clockwise, the living room would face west where the sun sets. Figure out what the floor plan would look like if it were rotated 90 degrees clockwise so you can propose this change to your friend.
TODO: Method to Implement for Rotating
public class Minecraft {
...
public static int[][] rotateFloorPlan(int[][] originalFloorPlan);
...
}
Provided an n x m two-dimensional integer array representing the original floor plan, write a method that rotates the original floor plan clockwise by 90 degrees and returns the new, m x n rotated floor plan.
Figure: see image.
public static int[][] rotateFloorPlan(int[][] originalFloorPlan)
Example 1: see image.
Input
originalFloorPlan = {
{1,1,1,2,2},
{1,1,1,2,2},
{5,5,3,2,2},
{5,5,3,3,3}
}
Output
{
{5,5,1,1},
{5,5,1,1},
{3,3,1,1},
{3,2,2,2},
{3,2,2,2}
}
Example 2: see image.
Input
originalFloorPlan = {
{1,1,2},
{1,1,1},
{2,2,2}
}
Output
{
{2,1,1},
{2,1,1},
{2,1,2}
}
Example 3: see image.
Input
originalFloorPlan = {
{4,1},
{4,1},
{4,1},
{4,8},
{7,7}
}
Output
{
{7, 4, 4, 4, 4},
{7, 8, 1, 1, 1}
}
While exploring for diamonds in Minecraft, you come across a rather eventful village. There you find a bunch of mobs partying and breaking social distancing rules. Suddenly, a mob announces that they are currently infected with the virus, causing widespread panic. You quickly become the hero of the village, volunteering to determine which mobs should get tested.
TODO: Method to Implement for Contact Tracing
public class Minecraft {
...
public static ArrayList< String> getMobsToTest(String[][] groups, String infected);
...
}
Given the name of the infected mob and a 2D array of String s, with each inner array representing a different group of mobs that was formed throughout the party, return an ArrayList of String s of all the mobs that should be tested (the String s can be in any order in the list). A mob should be tested if they were in direct contact with the infected mob (they will only have been in direct contact if they were ever in the same group). The returned list should not contain any duplicates and should not contain the original infected mob.
NOTE: You are NOT allowed to use any data structure other than (2D) arrays and ArrayLists in this method.
public static ArrayList< String> getMobsToTest(String[][] groups, String infected)
Example 1
groups = {
{"Cow", "Squid", "Horse"},
{"Sheep", "Cow", "Horse", ""},
{"Sheep", "Bat"}
}
infected = "Cow"
expected output: any permutation of ["Squid", "Horse", "Sheep", ""] // Note that the output should be an ArrayList
In this example, we see that Cow is our infected mob. We also see that in the first two arrays, Cow interacted with Squid, Horse, and Sheep. We do not include Bat because Bat did not directly interact with Cow. We also only include Horse once since we do not want to include duplicates in our outputted ArrayList.
Example 2
groups = {
{"Zombie", "Cow", "Creeper", "Guardian", null, "Slime"},
{"Sheep", "Iron Golem", "Cow"},
{"Sheep"},
{"Cow", "Pufferfish", "Squid", "Sheep"}
}
infected = "Sheep"
expected output: any permutation of ["Cow", "Pufferfish", "Squid", "Iron Golem"] // Note that the output should be an ArrayList
The same logic applies in this case. Sheep interacted with Iron Golem and Cow on one occasion and Cow, Pufferfish, and Squid on another. Thus, our outputted ArrayList should have Cow, Pufferfish, Squid, and Iron Golem.