MacTech Network:   MacTech Forums  |  MacForge.net  |  Computer Memory  |  Register Domains  |  Cables  |  iPod Deals  | Mac Deals  | Mac Book Shelf


  MacTech Magazine

The journal of Macintosh technology

 
 

Magazine In Print
  About MacTech  
  Home Page  
  Subscribe  
  Archives DVD  
  Submit News  
  MacTech Forums  
  Get a copy of MacTech RISK FREE  
MacTech Only Search:
Community Search:
MacTech Central
  by Category  
  by Company  
  by Product  
MacTech News
  MacTech News  
  Previous News  
  MacTech RSS  
Article Archives
  Show Indices  
  by Volume  
  by Author  
  Source Code FTP  
Inside MacTech
  Writer's Kit  
  Editorial Staff  
  Editorial Calendar  
  Back Issues  
  Advertising  
Contact Us
  Customer Service  
  MacTech Store  
  Legal/Disclaimers  
  Webmaster Feedback  
 Get Netflix

 March 2002 Programmer's Challenge

Megaminx

Mail solutions to: progchallenge@mactech.com
Due Date: 11:59pm ET, Monday, 4 March 2002

Some months the Challenge ideas come easily. Other months an interesting idea eludes me. This is one of those "other" months. The column deadline looms near, becomes imminent, encroaches into the present, overtakes me, and rushes onward, leaving me in its past. The wrath of my editor awaits. What to do?

Just in time, my collection of mechanical puzzles beckons, and an idea pops into my head. Time for another Meffert puzzle, perhaps. Something more difficult than the Tetraminx Challenge from June of 1999. Something even more difficult than the R*biks Cube Challenge. Yes, this month we’ll Challenge readers to solve the Megaminx, pictured below.

 

The Megaminx is a regular solid with twelve faces, where each face is divided into one center face element (which I’ll call a facelet), five corner facelets, and five edge facelets. The faces are colored with six colors, pairs of opposing faces being colored the same. The solid is divided into slices corresponding to the faces of the Megaminx. Each face can be rotated clockwise or counterclockwise, with five rotation steps in the same direction bringing the corresponding slice back to its original position. Your Challenge is to restore a scrambled Megaminx to its original position. Entries this month will be complete applications, so there is no prototype for the code you should write.

To describe the coloring of the solid, we’re going to have to agree on some notation to identify the facelets. We’ll number the faces from 1..12, thinking of face 1 as the "top" face. Face 2 will be one of the five faces adjacent to the top face, and faces 3..6 the other faces adjacent to the top face, proceeding clockwise from face 2 when viewed from above the top face. Faces 7..12 will be numbered such that face N+6 is opposite face N. We’ll number the colors of the solved Megaminx using 1..6 as well, assigning color N to the center facelet of faces N and N+6. Sounds complicated perhaps, but if you read carefully, it should become clear. If it isn’t, perhaps the following list of face adjacencies will help:

Face 1 is adjacent to faces:

2

3

4

5

6

Face 2 is adjacent to faces:

6

10

11

3

1

Face 3 is adjacent to faces:

2

11

12

4

1

Face 4 is adjacent to faces:

3

12

8

5

1

Face 5 is adjacent to faces:

4

8

9

6

1

Face 6 is adjacent to faces:

5

9

10

2

1

Face 7 is adjacent to faces:

8

9

10

11

12

Face 8 is adjacent to faces:

12

4

5

9

7

Face 9 is adjacent to faces:

8

5

6

10

7

Face 10 is adjacent to faces:

9

6

2

11

7

Face 11 is adjacent to faces:

10

2

3

12

7

Face 12 is adjacent to faces:

11

3

4

8

7

Your program must process multiple test cases, the number of which is provided in the file input.txt. The initial conditions for each test case are provided in file megaminxNN.in, where NN ranges from 1 to the number of test cases. Each input file contains 120 lines, 60 describing the coloring of the corner facelets, followed by 60 describing the coloring of the edge facelets. The lines describing the corner facelets will contain four comma-delimited numbers: the number of the face on which the facelet lies, the number of one of the other faces on this corner piece, the number of the third face on this corner piece, and the color of the facelet. The lines describing the edge facelets will contain three comma-delimited numbers: the number of the face on which the facelet lies, the number of the other face defining this corner piece, and the color of the facelet. So, for a Megaminx in the "solved" orientation, the megaminxNN.in file would contain the following lines for the top face:

1,2,3,1
1,3,4,1
1,4,5,1
1,5,6,1
1,6,2,1

1,2,1
1,3,1
1,4,1
1,5,1
1,6,1

The puzzle is solved with a sequence of slice rotations, resulting in each facelet being moved to the face that matches its color. Each rotation moves the corner and edge pieces of the rotated slice to new positions. A clockwise rotation of the slice corresponding to face 1, for example, moves corner piece (1,2,3) to (1,3,4), which moves to (1,4,5), which moves to (1,5,6), which moves to (1,6,2). A clockwise rotation of slice 2 moves the corners from (2,3,1) -> (2,1,6) -> (2,6,10) -> (2,10,11) -> (2,11,3) -> (2,3,1).

After reading the input for each test case, you should determine the sequence of rotations needed to solve the puzzle and output them to a file rotationsNN.txt. Each rotation should produce one line of output of the form:

face,direction

… where face is the number of the slice being rotated, and "direction" is the character ‘+’ for a clockwise rotation and ‘-‘ for a counterclockwise rotation.

Finally, your program should produce a megaminx.log file, with one line per test case containing the integer number of microseconds used by your application to solve that test case, including the time to read the input, find the solution, and produce the rotationsNN.txt output.

Scoring will be based on minimizing execution time. You can earn a reduction of up to 25% of your execution time if your application has an option to display the Megaminx as it is being solved. (Scoring will be done with the display option disabled, so the display time will not count against your solution.) The bonus will be awarded based on a subjective evaluation of the quality and attractiveness of your application.

This will be a native PowerPC Challenge, using the development environment of your choice, provided I have or can obtain a copy - email progchallenge@mactech.com to check before you start. You can develop for Mac OS 9 or Mac OS X. Your solution should be a complete Macintosh application, and your submission should provide everything needed to build your application.


Test data for this Challenge is available.


You can get a head start on the Challenge by reading the Programmer's Challenge mailing list. It will be posted to the list on or before the 12th of the preceding month. To join, send an email to listserv@listmail.xplain.com with the subject "subscribe challenge-A". You can also join the discussion list by sending a message with the subject "subscribe challenge-D".





Generate a short URL for this page:


Click on the cover to
see this month's issue!

TRIAL SUBSCRIPTION
Get a RISK-FREE subscription to the only technical Mac magazine!

Today's Deal


Apple Special

Order
Snow Leopard,
Mac Box Set, Family Pack,
and Snow Leopard Server
at a discount.
 


MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797

Register Low Cost (ok dirt cheap!) Domain Names in the MacTech Domain Store. As low as $1.99!
Save on long distance * Upgrade your Computer. See local info about Westlake Village
appleexpo.com | bathjot.com | bathroomjot.com | bettersupplies.com | comclothing.com | computerlunatics.com | dotcomclothing.com | explainit.com | exposinternational.com | homeismycastle.com | hoodcards.com | intlexpo.com | keyinfocard.com | kosheru.com | learnmorsels.com | localdealcards.com | lvschools.com | macjobsearch.com | mactechjobs.com | mactechmonitor.com | mactechsupplies.com | macwishbook.com | movie-depot.com | netprofessional.com | nibblelearning.com | notesintheshower.com | officejot.com | onlinebigbox.com | palmosdepot.com | peopleslineitemveto.com | showerjot.com | snapestore.com | snapishop.com | snapistore.com | snaptradingpost.com | stimulusmap.com | stimulusroadmap.com | triunfoguides.com | video-depot.com
Staff Site Links



All contents are Copyright 1984-2008 by Xplain Corporation. All rights reserved.

MacTech is a registered trademark of Xplain Corporation. Xplain, Video Depot, Movie Depot, Palm OS Depot, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, NetProLive, JavaTech, WebTech, BeTech, LinuxTech, Apple Expo, MacTech Central and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.