sicily1128.DICE

1128. DICE


Description


Imagine looking at a six-sided die so two sides face east-west, two face north-south, and the last two sides face up-down. You could write down the number of dots on each side in the order: east, west, north, south, up, down.
Normal dice are labeled so that the sum of opposing sides sum to seven. This constraint is sufficient to reduce dice into two categories, "Left handed"and "Right handed."Left handed dice can be oriented so that the east face is 1, the north face is 2, and the down face is 3. Right handed dice can be oriented so that the east face is 1, the north face is 2, and the up face is 3.
In this problem, given the face values of a sequence of dice, you are to determine the handedness of the dice.

Input


The input file will contain a sequence of one or more face descriptions of a die. These will be written as six digits (not separated by white space) on a single line. The numbers will represent (in order) the face values of the east, west, north, south, up, and down faces of the given die.

Output


Other than the standard leader and trailer, the output file simply has the word "left"or "right"for each dice in the input file.

Sample Input

162534
162543
526134

Sample Output

right
left
left

 
//ans[1]-ans[6]는 각각 동서 북남 상하의 값을 기록하고 우리는 마지막에 반드시 돌려야 한다고 확정할 수 있다.//ans[1]=1,ans[3]=2, 즉 the east face is1, the north face is2,//왼쪽이나 라이트라고 판단하기 위해 우리는 먼저 동쪽을 1로 돌리고 북쪽을 2,/마지막으로 위가 3이면 라이트이다.아래가 3이면 left #include #include using namespace std; intmain() {charch[10]; int ans[10], tmp;while(cin>>ch+1) {for(int i=1;i<=6;+i)ans[i]=ch[i]'0';if(ans[5]==1|ans[6]=1)//1이 위나 아래에 있으면 1을 수평면(동서북남) {tmp=ans[5];ans[5]=ans[4];ans[6];ans[6]=ans[3]; ans[3]=tmp;}while(ans[1]!=1)//수평면에서 회전합니다. 4걸음 돌면 원래 상태로 돌아갈 수 있기 때문에 3걸음 안에 동쪽을 1{tmp=ans[2]로 돌릴 수 있습니다.
   ans[2]=ans[4];ans[4]=ans[1];ans[1]=ans[3];        ans[3]=tmp;//수평면 회전: 북->동->남->서->북,즉 ans[3]->ans[1]->ans[4]->ans[2]->ans[3]}while (ans[3]!=2)//수직면에서 회전 {tmp=ans[5];ans[5]=ans[4];ans[4]=ans[6];ans[6]=ans[3];ans[3]=tmp;//수직면의 회전은:북->하->남->상->북, 즉 ans[3]->ans[5]->ans[5]]]->ans[3]]];ans[3]]if(ans[5]=3)//ans[5]==3은 위의 3printf("right")를 나타낸다.        else            printf("left");   }    return 0; }
 

좋은 웹페이지 즐겨찾기