Untitled

 avatar
user_1487033724
plain_text
2 years ago
2.7 kB
4
Indexable
Never
package solution;

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

class Result {

    /*
     * Complete the 'calcularFase' function below.
     *
     * The function is expected to return an INTEGER.
     * The function accepts following parameters:
     *  1. STRING pInicial
     *  2. STRING pActual
     */

    public static int calcularFase(String pInicial, String pActual) {
                 
        pInicial.charAt(0);
        pInicial.charAt(1);
        pInicial.charAt(2);
        pInicial.charAt(3);
        
        pActual.charAt(0);
        pActual.charAt(1);
        pActual.charAt(2);
        pActual.charAt(3);
        
        
        String Fase1;
        Fase1 =""+pActual.charAt(0)+pActual.charAt(1)+pActual.charAt(2)+pActual.charAt(3);
        
        String Fase2;
        Fase2 =""+pActual.charAt(2)+pActual.charAt(3)+pActual.charAt(1)+pActual.charAt(0);
        
        String Fase3;
        Fase3 =""+pActual.charAt(1)+pActual.charAt(0)+pActual.charAt(3)+pActual.charAt(2);
        
        String Fase4;
        Fase4 =""+pActual.charAt(3)+pActual.charAt(2)+pActual.charAt(0)+pActual.charAt(1);
       
        if(pInicial.equals(Fase1)){
            System.out.println(1);
        } else { 
                if(pInicial.equals(Fase2)){
                 System.out.println(2);
        } else {
                if(pInicial.equals(Fase3)){
                    System.out.println(3);
        } else {    
                 if(pInicial.equals(Fase4)){
                    System.out.println(4);
        } else {
                 System.out.println(-1);
                }
        
            }
        }
        }
        
        return 1;
    }
        
    
   }


public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));

        String inicial = bufferedReader.readLine();

        String actual = bufferedReader.readLine();

        int resFase = Result.calcularFase(inicial, actual);

        bufferedWriter.write(String.valueOf(resFase));
        bufferedWriter.newLine();

        bufferedReader.close();
        bufferedWriter.close();
    }
}