+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
07ca65d
master
1/** 2* Licensed to the Apache Software Foundation (ASF) under one 3* or more contributor license agreements. See the NOTICE file 4* distributed with this work for additional information 5* regarding copyright ownership. The ASF licenses this file 6* to you under the Apache License, Version 2.0 (the 7* "License"); you may not use this file except in compliance 8* with the License. You may obtain a copy of the License at 9* 10* http://www.apache.org/licenses/LICENSE-2.0 11* 12* Unless required by applicable law or agreed to in writing, software 13* distributed under the License is distributed on an "AS IS" BASIS, 14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15* See the License for the specific language governing permissions and 16* limitations under the License. 17*/ 18 19package org .apache .hadoop .examples .dancing ; 20 21/** 22* Of the "normal" 12 pentominos, 6 of them have distinct shapes when flipped. 23* This class includes both variants of the "flippable" shapes and the 24* unflippable shapes for a total of 18 pieces. Clearly, the boards must have 25* 18*5=90 boxes to hold all of the solutions. 26*/ 27public class OneSidedPentomino extends Pentomino { 28 29public OneSidedPentomino () {} 30 31public OneSidedPentomino (int width ,int height ) { 32super (width ,height ); 33 } 34 35/** 36* Define the one sided pieces. The flipped pieces have the same name with 37* a capital letter. 38*/ 39protected void initializePieces () { 40pieces .add (new Piece ("x" ," x /xxx/ x " ,false ,oneRotation )); 41pieces .add (new Piece ("v" ,"x /x /xxx" ,false ,fourRotations )); 42pieces .add (new Piece ("t" ,"xxx/ x / x " ,false ,fourRotations )); 43pieces .add (new Piece ("w" ," x/ xx/xx " ,false ,fourRotations )); 44pieces .add (new Piece ("u" ,"x x/xxx" ,false ,fourRotations )); 45pieces .add (new Piece ("i" ,"xxxxx" ,false ,twoRotations )); 46pieces .add (new Piece ("f" ," xx/xx / x " ,false ,fourRotations )); 47pieces .add (new Piece ("p" ,"xx/xx/x " ,false ,fourRotations )); 48pieces .add (new Piece ("z" ,"xx / x / xx" ,false ,twoRotations )); 49pieces .add (new Piece ("n" ,"xx / xxx" ,false ,fourRotations )); 50pieces .add (new Piece ("y" ," x /xxxx" ,false ,fourRotations )); 51pieces .add (new Piece ("l" ," x/xxxx" ,false ,fourRotations )); 52pieces .add (new Piece ("F" ,"xx / xx/ x " ,false ,fourRotations )); 53pieces .add (new Piece ("P" ,"xx/xx/ x" ,false ,fourRotations )); 54pieces .add (new Piece ("Z" ," xx/ x /xx " ,false ,twoRotations )); 55pieces .add (new Piece ("N" ," xx/xxx " ,false ,fourRotations )); 56pieces .add (new Piece ("Y" ," x /xxxx" ,false ,fourRotations )); 57pieces .add (new Piece ("L" ,"x /xxxx" ,false ,fourRotations )); 58 } 59 60/** 61* Solve the 3x30 puzzle. 62* @param args 63*/ 64public static void main (String []args ) { 65Pentomino model =new OneSidedPentomino (3 ,30 ); 66int solutions =model .solve (); 67System .out .println (solutions +" solutions found." ); 68 } 69 70}