SlideShare a Scribd company logo
1 of 8
Note that colors from C can be used more than once and that not all colors in C must be used. An
example of a solid cube over the set of colors C = {Red, Green, Blue} is:
Top - Green Front - Green Right - Blue
Back - Green Left - Blue Bottom - Green
Notice that the color Red is not used in this example. Also assume that, before painting, each
face of the cube is indistinguishable from each of the other five faces (e.g. ignore the wood-grain
on the cube faces in the above image). Since what which cube faces we call Top, Front, Right,
Back, Left, and Bottom above is arbitrary, notice that another representation of the same cube is:
Top - Green Front - Blue Right - Green
Back - Blue Left - Green Bottom - Green
Furthermore, we will define two cubes to be equal if, and only if, one cube can be physically
reoriented so that the two cubes look identical to a human observer. So, there is only one solid
cube over the set of colors C = {Red, Blue} with exactly one Blue face, namely:
Top - Red Front - Red Right - Red
Back - Blue Left - Red Bottom - Red
All other cubes with one Blue face are equivalent to this one since, given a cube with exactly one
Blue face, we can reorient this cube so that the Back face is Blue
You are to write code which, given a set of colors C, will compute the set of pairwise distinct
(i.e., non-equal) solid cubes over the set C. In particular, write a method with the following
signature:
public static Set<Cube> getDistinctSolidCubes(Set<Color> colors);
Please, use all the files provided to write and fix the code that works, thanks!
Here is the interface:
package model;
import java.util.Set;
public interface Cube {
public Set<CubeNet> getAllPossibleCubeNets();
}
Here is the CubeImpl file, please, fix and complete it:
package model;
import java.util.HashSet;
import java.util.Set;
public class CubeImpl implements Cube
{
private CubeNet representativeNet;
public CubeImpl (CubeNet cubeNetRepresentative)
{
assert cubeNetRepresentative != null : "cubeNetRepresentative is null!";
this.representativeNet = cubeNetRepresentative;
}
@Override
public Set<CubeNet> getAllPossibleCubeNets()
{
Set<CubeNet> allNets = new HashSet<CubeNet>();
allNets.add(this.representativeNet);
// Here you can generate all the possible nets for the cube by
// rotating the representative net along its different axes and
// adding each resulting net to the set of all nets.
// You can use the different methods available in the CubeNet class
// to perform the rotations and generate the new nets.
return allNets;
}
}
package model;
another interface:
import java.awt.Color;
public interface CubeNet {
public Color getTop();
public Color getFront();
public Color getRight();
public Color getBack();
public Color getLeft();
public Color getBottom();
}
package model;
import java.awt.Color;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class CubeNetImpl implements CubeNet
{
private Color top;
private Color front;
private Color right;
private Color left;
private Color bottom;
private Color back;
private Set<Map<Face, Color>> allPossibleMaps = null;
private Integer hashCode = null;
private static int numberCallsToEqual = 0;
private static int numberCallsToAdd = 0;
private static int numberCallsToHashCode = 0;
private static long timeSpentEqual = 0;
private static long timeSpentHashCode = 0;
private static long timeSpentInSetAddMillis = 0;
private static boolean CALCULATE_POSSIBLE_MAPS_ONE_TIME = false;
private static boolean CALCULATE_HASHCODE_ONE_TIME = false;
private static int HASHCODE_LEVEL = 1;
public CubeNetImpl (Map<Face, Color> faceToColorMap)
{
assert faceToColorMap != null : "faceToColorMap is null!";
top = faceToColorMap.get(Face.TOP);
front = faceToColorMap.get(Face.FRONT);
right = faceToColorMap.get(Face.RIGHT);
left = faceToColorMap.get(Face.LEFT);
bottom = faceToColorMap.get(Face.BOTTOM);
if (CALCULATE_POSSIBLE_MAPS_ONE_TIME) {
long startTime = System.currentTimeMillis();
allPossibleMaps = generateAllPossibleMaps();
long endTime = System.currentTimeMillis();
timeSpentInSetAddMillis += endTime - startTime;
CALCULATE_POSSIBLE_MAPS_ONE_TIME = false;
}
if (CALCULATE_HASHCODE_ONE_TIME) {
long startTime = System.currentTimeMillis();
hashCode(HASHCODE_LEVEL);
long endTime = System.currentTimeMillis();
timeSpentHashCode += endTime - startTime;
CALCULATE_HASHCODE_ONE_TIME = false;
}
}
@Override
public Color getTop()
{
return top;
}
@Override
public Color getFront()
{
return front;
}
@Override
public Color getRight()
{
return right;
}
@Override
public Color getBack()
{
return back;
}
@Override
public Color getLeft()
{
return left;
}
@Override
public Color getBottom()
{
return bottom;
}
public int getDistinctColorCount() {
Set<Color> distinctColors = new HashSet<Color>();
distinctColors.add(top);
distinctColors.add(front);
distinctColors.add(right);
distinctColors.add(left);
distinctColors.add(bottom);
return distinctColors.size();
}
private Set<Map<Face, Color>> generateAllPossibleMaps() {
Set<Map<Face, Color>> maps = new HashSet<>();
for (Color c1 : Face.colorList) {
for (Color c2 : Face.colorList) {
for (Color c3 : Face.colorList) {
for (Color c4 : Face.colorList) {
for (Color c5 : Face.colorList) {
for (Color c6 : Face.colorList) {
Map<Face, Color> map = new HashMap<>();
map.put(Face.TOP, c1);
map.put(Face.FRONT, c2);
map.put(Face.RIGHT, c3);
map.put(Face.LEFT, c4);
map.put(Face.BOTTOM, c5);
map.put(Face.BACK, c6);
maps.add(map);
}
}
}
}
}
}
return maps;
}
// @Override
// public int hashCode() {
// if (hashCode != null) {
// return hashCode;
// }
// }
//Improving on the inherited hashCode() is mandatory
//to get improved performance
//Also, whenever you change hashCode() you probably
//need to change equals() to ensure that the "equals()/hashCode()
//contract" is satisfied
public int hashCode(int level)
{
int hashCode = 0;
if(this.hashCode != null) {
hashCode = this.hashCode();
}
else if (level == 0) {
hashCode = 0;
}
else if (level == 1) {
hashCode = (top.getRGB() + bottom.getRGB() + left.getRGB() + front.getRGB() +
back.getRGB() + right.getRGB());
}
else if(level == 2) {
hashCode = getDistinctColorCount();
}
else
{
assert level == 0 : "level = " + level + "is uniterpretable";
}
return hashCode;
}
//Improving on the inherited equals() is mandatory
//to get improved performance
//Also, whenever you change equals() you probably
//need to change hashCode() to ensure that the "equals()/hashCode()
//contract" is satisfied
public boolean equals(Object obj)
{
throw new RuntimeException("NOT IMPLEMENTED YET!");
}
//Implement a decent toString() for yourself during development
@Override
public String toString() {
return "CubeNetImpl {" +
"top=" + top +
", front=" + front +
", right=" + right +
", back=" + back +
", left=" + left +
", bottom=" + bottom +
'}';
}
Another class:
package model;
import java.awt.Color;
import java.util.Set;
public class CubeSolver_Opinca
{
private CubeSolver_Opinca()
{
assert false : "DO NOT INSTANTIATE!";
}
public static Set<Cube> getDistinctSolidCubes(Set<Color> colors)
{
throw new RuntimeException("NOT IMPLEMENTED YET!");
}
}
the enum:
package model;
public enum Face {
TOP , FRONT , RIGHT , BACK , LEFT , BOTTOM ;
}//DON'T CHANGE THE INTERFACE

More Related Content

Similar to Note that colors from C can be used more than once and that not all co.docx

Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfcontact41
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfellanorfelicityri239
 
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfgopalk44
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6m0bz
 
Need help with questions 2-4. Write assembly code to find absolute v.pdf
Need help with questions 2-4. Write assembly code to find absolute v.pdfNeed help with questions 2-4. Write assembly code to find absolute v.pdf
Need help with questions 2-4. Write assembly code to find absolute v.pdffeelinggifts
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfConint29
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfRAJATCHUGH12
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat SheetHortonworks
 
ch03g-graphics.ppt
ch03g-graphics.pptch03g-graphics.ppt
ch03g-graphics.pptMahyuddin8
 
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdf
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdfCSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdf
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdfmarketing413921
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfShaiAlmog1
 
Im having trouble figuring out how to code these sections for an a.pdf
Im having trouble figuring out how to code these sections for an a.pdfIm having trouble figuring out how to code these sections for an a.pdf
Im having trouble figuring out how to code these sections for an a.pdfrishteygallery
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages VictorSzoltysek
 
Creating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfCreating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfShaiAlmog1
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 

Similar to Note that colors from C can be used more than once and that not all co.docx (20)

Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdf
 
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6
 
Need help with questions 2-4. Write assembly code to find absolute v.pdf
Need help with questions 2-4. Write assembly code to find absolute v.pdfNeed help with questions 2-4. Write assembly code to find absolute v.pdf
Need help with questions 2-4. Write assembly code to find absolute v.pdf
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
 
Ejer
EjerEjer
Ejer
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 
ch03g-graphics.ppt
ch03g-graphics.pptch03g-graphics.ppt
ch03g-graphics.ppt
 
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdf
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdfCSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdf
CSC-1106 Homework 09 (Class and static methods) Due Tuesday, Novembe.pdf
 
Sneaking inside Kotlin features
Sneaking inside Kotlin featuresSneaking inside Kotlin features
Sneaking inside Kotlin features
 
Excel formulas
Excel formulasExcel formulas
Excel formulas
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdf
 
rubik_solve
rubik_solverubik_solve
rubik_solve
 
Im having trouble figuring out how to code these sections for an a.pdf
Im having trouble figuring out how to code these sections for an a.pdfIm having trouble figuring out how to code these sections for an a.pdf
Im having trouble figuring out how to code these sections for an a.pdf
 
Functional optics
Functional opticsFunctional optics
Functional optics
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Creating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdfCreating an Uber Clone - Part XXII - Transcript.pdf
Creating an Uber Clone - Part XXII - Transcript.pdf
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 

More from VictorzH8Bondx

A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxA large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxVictorzH8Bondx
 
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxPassengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxVictorzH8Bondx
 
Pattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxPattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxVictorzH8Bondx
 
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docxPathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docxVictorzH8Bondx
 
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxPareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxVictorzH8Bondx
 
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxPart  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxVictorzH8Bondx
 
P90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxP90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxVictorzH8Bondx
 
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxp2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxVictorzH8Bondx
 
P(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxP(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxVictorzH8Bondx
 
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxP(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxVictorzH8Bondx
 
Over the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxOver the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxVictorzH8Bondx
 
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxOVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxVictorzH8Bondx
 
Out of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxOut of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxVictorzH8Bondx
 
Output of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxOutput of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxVictorzH8Bondx
 
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxOverview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxVictorzH8Bondx
 
out of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxout of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxVictorzH8Bondx
 
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxOtosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxVictorzH8Bondx
 
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxOriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxVictorzH8Bondx
 
Oriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxOriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxVictorzH8Bondx
 
Organizations use corporate strategy to select target domains- O.docx
Organizations use corporate strategy to select target domains-      O.docxOrganizations use corporate strategy to select target domains-      O.docx
Organizations use corporate strategy to select target domains- O.docxVictorzH8Bondx
 

More from VictorzH8Bondx (20)

A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxA large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
 
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxPassengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
 
Pattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxPattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docx
 
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docxPathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
 
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxPareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
 
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxPart  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
 
P90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxP90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docx
 
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxp2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
 
P(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxP(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docx
 
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxP(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
 
Over the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxOver the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docx
 
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxOVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
 
Out of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxOut of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docx
 
Output of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxOutput of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docx
 
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxOverview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
 
out of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxout of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docx
 
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxOtosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
 
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxOriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
 
Oriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxOriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docx
 
Organizations use corporate strategy to select target domains- O.docx
Organizations use corporate strategy to select target domains-      O.docxOrganizations use corporate strategy to select target domains-      O.docx
Organizations use corporate strategy to select target domains- O.docx
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 

Note that colors from C can be used more than once and that not all co.docx

  • 1. Note that colors from C can be used more than once and that not all colors in C must be used. An example of a solid cube over the set of colors C = {Red, Green, Blue} is: Top - Green Front - Green Right - Blue Back - Green Left - Blue Bottom - Green Notice that the color Red is not used in this example. Also assume that, before painting, each face of the cube is indistinguishable from each of the other five faces (e.g. ignore the wood-grain on the cube faces in the above image). Since what which cube faces we call Top, Front, Right, Back, Left, and Bottom above is arbitrary, notice that another representation of the same cube is: Top - Green Front - Blue Right - Green Back - Blue Left - Green Bottom - Green Furthermore, we will define two cubes to be equal if, and only if, one cube can be physically reoriented so that the two cubes look identical to a human observer. So, there is only one solid cube over the set of colors C = {Red, Blue} with exactly one Blue face, namely: Top - Red Front - Red Right - Red Back - Blue Left - Red Bottom - Red All other cubes with one Blue face are equivalent to this one since, given a cube with exactly one Blue face, we can reorient this cube so that the Back face is Blue You are to write code which, given a set of colors C, will compute the set of pairwise distinct (i.e., non-equal) solid cubes over the set C. In particular, write a method with the following signature: public static Set<Cube> getDistinctSolidCubes(Set<Color> colors); Please, use all the files provided to write and fix the code that works, thanks! Here is the interface: package model; import java.util.Set; public interface Cube { public Set<CubeNet> getAllPossibleCubeNets(); } Here is the CubeImpl file, please, fix and complete it: package model; import java.util.HashSet; import java.util.Set; public class CubeImpl implements Cube
  • 2. { private CubeNet representativeNet; public CubeImpl (CubeNet cubeNetRepresentative) { assert cubeNetRepresentative != null : "cubeNetRepresentative is null!"; this.representativeNet = cubeNetRepresentative; } @Override public Set<CubeNet> getAllPossibleCubeNets() { Set<CubeNet> allNets = new HashSet<CubeNet>(); allNets.add(this.representativeNet); // Here you can generate all the possible nets for the cube by // rotating the representative net along its different axes and // adding each resulting net to the set of all nets. // You can use the different methods available in the CubeNet class // to perform the rotations and generate the new nets. return allNets; } } package model; another interface: import java.awt.Color;
  • 3. public interface CubeNet { public Color getTop(); public Color getFront(); public Color getRight(); public Color getBack(); public Color getLeft(); public Color getBottom(); } package model; import java.awt.Color; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class CubeNetImpl implements CubeNet { private Color top; private Color front; private Color right; private Color left; private Color bottom; private Color back; private Set<Map<Face, Color>> allPossibleMaps = null; private Integer hashCode = null; private static int numberCallsToEqual = 0; private static int numberCallsToAdd = 0; private static int numberCallsToHashCode = 0; private static long timeSpentEqual = 0; private static long timeSpentHashCode = 0; private static long timeSpentInSetAddMillis = 0; private static boolean CALCULATE_POSSIBLE_MAPS_ONE_TIME = false; private static boolean CALCULATE_HASHCODE_ONE_TIME = false;
  • 4. private static int HASHCODE_LEVEL = 1; public CubeNetImpl (Map<Face, Color> faceToColorMap) { assert faceToColorMap != null : "faceToColorMap is null!"; top = faceToColorMap.get(Face.TOP); front = faceToColorMap.get(Face.FRONT); right = faceToColorMap.get(Face.RIGHT); left = faceToColorMap.get(Face.LEFT); bottom = faceToColorMap.get(Face.BOTTOM); if (CALCULATE_POSSIBLE_MAPS_ONE_TIME) { long startTime = System.currentTimeMillis(); allPossibleMaps = generateAllPossibleMaps(); long endTime = System.currentTimeMillis(); timeSpentInSetAddMillis += endTime - startTime; CALCULATE_POSSIBLE_MAPS_ONE_TIME = false; } if (CALCULATE_HASHCODE_ONE_TIME) { long startTime = System.currentTimeMillis(); hashCode(HASHCODE_LEVEL); long endTime = System.currentTimeMillis(); timeSpentHashCode += endTime - startTime; CALCULATE_HASHCODE_ONE_TIME = false; } } @Override public Color getTop() { return top; } @Override public Color getFront() { return front; } @Override public Color getRight() { return right; }
  • 5. @Override public Color getBack() { return back; } @Override public Color getLeft() { return left; } @Override public Color getBottom() { return bottom; } public int getDistinctColorCount() { Set<Color> distinctColors = new HashSet<Color>(); distinctColors.add(top); distinctColors.add(front); distinctColors.add(right); distinctColors.add(left); distinctColors.add(bottom); return distinctColors.size(); } private Set<Map<Face, Color>> generateAllPossibleMaps() { Set<Map<Face, Color>> maps = new HashSet<>(); for (Color c1 : Face.colorList) { for (Color c2 : Face.colorList) { for (Color c3 : Face.colorList) { for (Color c4 : Face.colorList) { for (Color c5 : Face.colorList) { for (Color c6 : Face.colorList) { Map<Face, Color> map = new HashMap<>(); map.put(Face.TOP, c1); map.put(Face.FRONT, c2); map.put(Face.RIGHT, c3); map.put(Face.LEFT, c4); map.put(Face.BOTTOM, c5); map.put(Face.BACK, c6); maps.add(map); } }
  • 6. } } } } return maps; } // @Override // public int hashCode() { // if (hashCode != null) { // return hashCode; // } // } //Improving on the inherited hashCode() is mandatory //to get improved performance //Also, whenever you change hashCode() you probably //need to change equals() to ensure that the "equals()/hashCode() //contract" is satisfied public int hashCode(int level) { int hashCode = 0; if(this.hashCode != null) { hashCode = this.hashCode(); } else if (level == 0) { hashCode = 0; } else if (level == 1) { hashCode = (top.getRGB() + bottom.getRGB() + left.getRGB() + front.getRGB() + back.getRGB() + right.getRGB()); } else if(level == 2) { hashCode = getDistinctColorCount(); } else { assert level == 0 : "level = " + level + "is uniterpretable"; } return hashCode; } //Improving on the inherited equals() is mandatory //to get improved performance //Also, whenever you change equals() you probably
  • 7. //need to change hashCode() to ensure that the "equals()/hashCode() //contract" is satisfied public boolean equals(Object obj) { throw new RuntimeException("NOT IMPLEMENTED YET!"); } //Implement a decent toString() for yourself during development @Override public String toString() { return "CubeNetImpl {" + "top=" + top + ", front=" + front + ", right=" + right + ", back=" + back + ", left=" + left + ", bottom=" + bottom + '}'; } Another class: package model; import java.awt.Color; import java.util.Set; public class CubeSolver_Opinca { private CubeSolver_Opinca() { assert false : "DO NOT INSTANTIATE!"; } public static Set<Cube> getDistinctSolidCubes(Set<Color> colors) { throw new RuntimeException("NOT IMPLEMENTED YET!"); } } the enum: package model; public enum Face {
  • 8. TOP , FRONT , RIGHT , BACK , LEFT , BOTTOM ; }//DON'T CHANGE THE INTERFACE