Rezultati

Up. imeNalogaJezikRezultatČas oddaje
iota-2017 Hodnik Java 100/100OK 20. apr '17 @ 18:33

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 33,320 MiB 0,000 s OK
#2 10/10 36,672 MiB 0,000 s OK
#3 10/10 33,578 MiB 0,000 s OK
#4 10/10 33,527 MiB 0,000 s OK
#5 10/10 34,766 MiB 0,000 s OK
#6 10/10 56,684 MiB 0,000 s OK
#7 10/10 55,598 MiB 0,000 s OK
#8 10/10 57,113 MiB 0,000 s OK
#9 10/10 56,496 MiB 0,000 s OK
#10 10/10 57,023 MiB 0,000 s OK

Ocenjevani program (HallwayMain.java):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by iota-2017 on 4/20/17.
 */
public class HallwayMain {

    public static int ham(String s1, String s2){
        int c =0;
        for (int i=0; i<s1.toCharArray().length ;i++){
            if (s1.toCharArray()[i]!=s2.toCharArray()[i]){
                c++;
            }
        }
        return c;
    }

    public static String gen(int n, char s){
        String str = String.valueOf(s);
        for (int i=1; i<n; i++){
            if (str.toCharArray()[i-1]=='0'){
                str+="1";
            }else{
                str+="0";
            }
        }
        return str;
    }

    public static void main(String[] args) {
        BufferedReader in
                = new BufferedReader(new InputStreamReader(System.in));
        try {
            String s = in.readLine();

            int a = ham(s, gen(s.length(), '0'));
            int b = ham(s, gen(s.length(), '1'));
            if (a<b){
                System.out.println(a);
            }else{
                System.out.println(b);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}