SlideShare une entreprise Scribd logo
1  sur  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 ;
}

Contenu connexe

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

ch03g-graphics.ppt
ch03g-graphics.pptch03g-graphics.ppt
ch03g-graphics.pptMahyuddin8
 
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdf
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdfSet up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdf
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdfxlynettalampleyxc
 
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
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6m0bz
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfShaiAlmog1
 
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
 
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
 
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
 
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
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
What is complex number
What is complex numberWhat is complex number
What is complex numberHamza Sajjad
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Philip Schwarz
 
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
 

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

ch03g-graphics.ppt
ch03g-graphics.pptch03g-graphics.ppt
ch03g-graphics.ppt
 
Introduction to Processing
Introduction to ProcessingIntroduction to Processing
Introduction to Processing
 
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdf
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdfSet up a JavaFX GUI-based program that shows a 10 times 10 grid of la.pdf
Set up a JavaFX GUI-based program that shows a 10 times 10 grid of la.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
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6
 
Maps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdfMaps - Part 3 - Transcript.pdf
Maps - Part 3 - Transcript.pdf
 
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
 
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
 
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
 
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
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Scala Higher Order Functions
Scala Higher Order FunctionsScala Higher Order Functions
Scala Higher Order Functions
 
What is complex number
What is complex numberWhat is complex number
What is complex number
 
Ejer
EjerEjer
Ejer
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
Functional optics
Functional opticsFunctional optics
Functional optics
 
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
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
OpenGL L06-Performance
OpenGL L06-PerformanceOpenGL L06-Performance
OpenGL L06-Performance
 

Plus de JulianQpDRossb

Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docx
Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docxOrganelle Function Draw it or Copy & Paste Image from Google Plasma Me.docx
Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docxJulianQpDRossb
 
On a bank's balance sheet- bank capital is considered A) an asset- B).docx
On a bank's balance sheet- bank capital is considered A) an asset- B).docxOn a bank's balance sheet- bank capital is considered A) an asset- B).docx
On a bank's balance sheet- bank capital is considered A) an asset- B).docxJulianQpDRossb
 
Once you have identified the purpose of your message- the next step is.docx
Once you have identified the purpose of your message- the next step is.docxOnce you have identified the purpose of your message- the next step is.docx
Once you have identified the purpose of your message- the next step is.docxJulianQpDRossb
 
Organizational culture is sustained as generations of leaders pass the.docx
Organizational culture is sustained as generations of leaders pass the.docxOrganizational culture is sustained as generations of leaders pass the.docx
Organizational culture is sustained as generations of leaders pass the.docxJulianQpDRossb
 
OP 18) Fone of thesen OOr.docx
OP 18) Fone of thesen OOr.docxOP 18) Fone of thesen OOr.docx
OP 18) Fone of thesen OOr.docxJulianQpDRossb
 
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docx
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docxOpenstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docx
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docxJulianQpDRossb
 
One of Mendel's F1 generation (the offspring of the mating of a true-.docx
One of Mendel's F1 generation  (the offspring of the mating of a true-.docxOne of Mendel's F1 generation  (the offspring of the mating of a true-.docx
One of Mendel's F1 generation (the offspring of the mating of a true-.docxJulianQpDRossb
 
One employee is in charge of the following activities at a bank's driv.docx
One employee is in charge of the following activities at a bank's driv.docxOne employee is in charge of the following activities at a bank's driv.docx
One employee is in charge of the following activities at a bank's driv.docxJulianQpDRossb
 
One aspect of the COVID-19 pandemic and its impact on our economy was.docx
One aspect of the COVID-19 pandemic and its impact on our economy was.docxOne aspect of the COVID-19 pandemic and its impact on our economy was.docx
One aspect of the COVID-19 pandemic and its impact on our economy was.docxJulianQpDRossb
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docx
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docxOn May 1- 2023- Romy and Vic formed a partnership contributing assets.docx
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docxJulianQpDRossb
 
On June 1- Linda Williams started Cullumber Designs Co- a company that.docx
On June 1- Linda Williams started Cullumber Designs Co- a company that.docxOn June 1- Linda Williams started Cullumber Designs Co- a company that.docx
On June 1- Linda Williams started Cullumber Designs Co- a company that.docxJulianQpDRossb
 
Observe in a health service area all environmental issues that may exi.docx
Observe in a health service area all environmental issues that may exi.docxObserve in a health service area all environmental issues that may exi.docx
Observe in a health service area all environmental issues that may exi.docxJulianQpDRossb
 
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docx
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docxObligate intracellular parasites- viruses- A-)undergo self-reproductio.docx
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docxJulianQpDRossb
 
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docx
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docxNOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docx
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docxJulianQpDRossb
 
Now you are in the Southern Hemisphere on April 4th- which statement i.docx
Now you are in the Southern Hemisphere on April 4th- which statement i.docxNow you are in the Southern Hemisphere on April 4th- which statement i.docx
Now you are in the Southern Hemisphere on April 4th- which statement i.docxJulianQpDRossb
 
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docx
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docxNot actual definitions- in own words!!!! Thanks 1) What is ESG investi.docx
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docxJulianQpDRossb
 
nits income statement for the year ended December 31-2025- Sandhill In.docx
nits income statement for the year ended December 31-2025- Sandhill In.docxnits income statement for the year ended December 31-2025- Sandhill In.docx
nits income statement for the year ended December 31-2025- Sandhill In.docxJulianQpDRossb
 
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docx
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docxNocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docx
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docxJulianQpDRossb
 
Normally- a corporation can do all of the following except- buy curren.docx
Normally- a corporation can do all of the following except- buy curren.docxNormally- a corporation can do all of the following except- buy curren.docx
Normally- a corporation can do all of the following except- buy curren.docxJulianQpDRossb
 
Pay for Performance Communities are frequently concerned about whether.docx
Pay for Performance Communities are frequently concerned about whether.docxPay for Performance Communities are frequently concerned about whether.docx
Pay for Performance Communities are frequently concerned about whether.docxJulianQpDRossb
 

Plus de JulianQpDRossb (20)

Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docx
Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docxOrganelle Function Draw it or Copy & Paste Image from Google Plasma Me.docx
Organelle Function Draw it or Copy & Paste Image from Google Plasma Me.docx
 
On a bank's balance sheet- bank capital is considered A) an asset- B).docx
On a bank's balance sheet- bank capital is considered A) an asset- B).docxOn a bank's balance sheet- bank capital is considered A) an asset- B).docx
On a bank's balance sheet- bank capital is considered A) an asset- B).docx
 
Once you have identified the purpose of your message- the next step is.docx
Once you have identified the purpose of your message- the next step is.docxOnce you have identified the purpose of your message- the next step is.docx
Once you have identified the purpose of your message- the next step is.docx
 
Organizational culture is sustained as generations of leaders pass the.docx
Organizational culture is sustained as generations of leaders pass the.docxOrganizational culture is sustained as generations of leaders pass the.docx
Organizational culture is sustained as generations of leaders pass the.docx
 
OP 18) Fone of thesen OOr.docx
OP 18) Fone of thesen OOr.docxOP 18) Fone of thesen OOr.docx
OP 18) Fone of thesen OOr.docx
 
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docx
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docxOpenstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docx
Openstax textbook - 19-2 Adjusting Nominal Values to Real Values- Make.docx
 
One of Mendel's F1 generation (the offspring of the mating of a true-.docx
One of Mendel's F1 generation  (the offspring of the mating of a true-.docxOne of Mendel's F1 generation  (the offspring of the mating of a true-.docx
One of Mendel's F1 generation (the offspring of the mating of a true-.docx
 
One employee is in charge of the following activities at a bank's driv.docx
One employee is in charge of the following activities at a bank's driv.docxOne employee is in charge of the following activities at a bank's driv.docx
One employee is in charge of the following activities at a bank's driv.docx
 
One aspect of the COVID-19 pandemic and its impact on our economy was.docx
One aspect of the COVID-19 pandemic and its impact on our economy was.docxOne aspect of the COVID-19 pandemic and its impact on our economy was.docx
One aspect of the COVID-19 pandemic and its impact on our economy was.docx
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docx
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docxOn May 1- 2023- Romy and Vic formed a partnership contributing assets.docx
On May 1- 2023- Romy and Vic formed a partnership contributing assets.docx
 
On June 1- Linda Williams started Cullumber Designs Co- a company that.docx
On June 1- Linda Williams started Cullumber Designs Co- a company that.docxOn June 1- Linda Williams started Cullumber Designs Co- a company that.docx
On June 1- Linda Williams started Cullumber Designs Co- a company that.docx
 
Observe in a health service area all environmental issues that may exi.docx
Observe in a health service area all environmental issues that may exi.docxObserve in a health service area all environmental issues that may exi.docx
Observe in a health service area all environmental issues that may exi.docx
 
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docx
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docxObligate intracellular parasites- viruses- A-)undergo self-reproductio.docx
Obligate intracellular parasites- viruses- A-)undergo self-reproductio.docx
 
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docx
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docxNOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docx
NOVAK INC- Statement of Cash Flows Cminflows trom Operiting Artivitien.docx
 
Now you are in the Southern Hemisphere on April 4th- which statement i.docx
Now you are in the Southern Hemisphere on April 4th- which statement i.docxNow you are in the Southern Hemisphere on April 4th- which statement i.docx
Now you are in the Southern Hemisphere on April 4th- which statement i.docx
 
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docx
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docxNot actual definitions- in own words!!!! Thanks 1) What is ESG investi.docx
Not actual definitions- in own words!!!! Thanks 1) What is ESG investi.docx
 
nits income statement for the year ended December 31-2025- Sandhill In.docx
nits income statement for the year ended December 31-2025- Sandhill In.docxnits income statement for the year ended December 31-2025- Sandhill In.docx
nits income statement for the year ended December 31-2025- Sandhill In.docx
 
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docx
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docxNocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docx
Nocinal 50P in 201t was s and nomblal GDP in 2012 was 5 (Entor your re.docx
 
Normally- a corporation can do all of the following except- buy curren.docx
Normally- a corporation can do all of the following except- buy curren.docxNormally- a corporation can do all of the following except- buy curren.docx
Normally- a corporation can do all of the following except- buy curren.docx
 
Pay for Performance Communities are frequently concerned about whether.docx
Pay for Performance Communities are frequently concerned about whether.docxPay for Performance Communities are frequently concerned about whether.docx
Pay for Performance Communities are frequently concerned about whether.docx
 

Dernier

Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 

Dernier (20)

Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 

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 ; }