11-01-2004, 01:54 AM
Recently I came upon a problem to do in QBASIC and I've had some trouble with it. It came from some computer contest or something of that nature. Well here it is:
Write a program to determine the number of distinguishable ways to place and orient a cube with a solid color on each of its six sides. The programs will ask for the one letter color symbol for each of the sides in the following order: TOP, FRONT, BOTTOM, BACK, RIGHT, LEFT. Output will be the statement, NUMBER OF DISTINGUISHABLE CUBES = ##, where ## is the number [of] different ways to position and orient the cube. Examples:
INPUT: Enter TOP side: Y
Enter FRONT side: Y
Enter BOTTOM side: Y
Enter BACK side: Y
Enter RIGHT side: Y
Enter LEFT side: Y
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 1
INPUT: Enter TOP side: G
Enter FRONT side: G
Enter BOTTOM side: G
Enter BACK side: G
Enter RIGHT side: G
Enter LEFT side: Y
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 6
INPUT: Enter TOP side: B
Enter FRONT side: B
Enter BOTTOM side: O
Enter BACK side: Y
Enter RIGHT side: G
Enter LEFT side: R
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 24
I've had a little trouble coming up with the forumula to get the number of cubes from the colors and translating that into code. I've tried a few different ways but the program I have so far barely scratches the surface and I was wondering if I am heading in the right direction. Any help would be greatly appreciated:
'Cube problem
'Sides for equation
sides = 6
INPUT "Enter TOP side: ", top$
INPUT "Enter FRONT side: ", front$
INPUT "Enter BACK side: ", back$
INPUT "Enter RIGHT side: ", ight$
INPUT "Enter LEFT side: ", eft$
IF top$ AND front$ AND back$ AND ight$ AND eft$ <> "R" OR "O" OR "Y" OR "G" OR "B"
PRINT "Use only R, O, Y, G, or B"
WHILE INKEY$ = ""
WEND
'Reselect from menu
ELSEIF top$ = front$ OR top$ = back$ OR top$ = ight$ OR top$ = eft$ THEN
Thank you for any feedback, in the meantime I'll be coding away...
Write a program to determine the number of distinguishable ways to place and orient a cube with a solid color on each of its six sides. The programs will ask for the one letter color symbol for each of the sides in the following order: TOP, FRONT, BOTTOM, BACK, RIGHT, LEFT. Output will be the statement, NUMBER OF DISTINGUISHABLE CUBES = ##, where ## is the number [of] different ways to position and orient the cube. Examples:
INPUT: Enter TOP side: Y
Enter FRONT side: Y
Enter BOTTOM side: Y
Enter BACK side: Y
Enter RIGHT side: Y
Enter LEFT side: Y
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 1
INPUT: Enter TOP side: G
Enter FRONT side: G
Enter BOTTOM side: G
Enter BACK side: G
Enter RIGHT side: G
Enter LEFT side: Y
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 6
INPUT: Enter TOP side: B
Enter FRONT side: B
Enter BOTTOM side: O
Enter BACK side: Y
Enter RIGHT side: G
Enter LEFT side: R
OUTPUT: NUMBER OF DISTINGUISHABLE CUBES = 24
I've had a little trouble coming up with the forumula to get the number of cubes from the colors and translating that into code. I've tried a few different ways but the program I have so far barely scratches the surface and I was wondering if I am heading in the right direction. Any help would be greatly appreciated:
'Cube problem
'Sides for equation
sides = 6
INPUT "Enter TOP side: ", top$
INPUT "Enter FRONT side: ", front$
INPUT "Enter BACK side: ", back$
INPUT "Enter RIGHT side: ", ight$
INPUT "Enter LEFT side: ", eft$
IF top$ AND front$ AND back$ AND ight$ AND eft$ <> "R" OR "O" OR "Y" OR "G" OR "B"
PRINT "Use only R, O, Y, G, or B"
WHILE INKEY$ = ""
WEND
'Reselect from menu
ELSEIF top$ = front$ OR top$ = back$ OR top$ = ight$ OR top$ = eft$ THEN
Thank you for any feedback, in the meantime I'll be coding away...