egg-problem/src/main/java/exxeta/interview/eggs/ExxetaInterviewEggs.java
/**
     * @return maximum Floor of unbroken egg
     */
@return maximum Floor of unbroken egg
@return maximum Floor of unbroken egg
public int fall() {
        int res = -1;
        int x, y = 25, z = 1;
        boolean tmp = true;
        Set<Integer> testing_floor = new HashSet<Integer>();
        for (int i = 1; i < getFloorCount(); i++) {
            testing_floor.add(i);
        }
        for (x = 50; x < getFloorCount(); x++) {
            if (testing_floor.contains(x)) {
                if (testFloor(x)) {
                    if (vajce == 1) {
                        tmp = testFloor(x + 1);
                    } else {
                        tmp = testFloor(x + y);
                    }
                    if (!tmp) {
                    } else {
                        x = x + y;
                    }
                    if (!tmp && vajce <= 1) {
                        res = x;
                        return res;
                    }
                } else {
                    vajce--;
                    y = 1;
                    if (vajce <= 0) {
                        res = x - 1;
                        return res;
                    }
                    tmp = testFloor(z);
                    if (tmp) {
                        x = z - 1;
                    } else {
                        break;
                    }
                }
                testing_floor.remove(x);
            }
            if (!tmp) {
                vajce--;
            }
            if (vajce <= 0) {
                break;
            }
            y /= 2;
            if (z >= getFloorCount()) {
                break;
            }
        }
        res = x;
        return res;
    }
public int fall ( ) { int res = - 1 ; int x , y = 25 , z = 1 ; boolean tmp = true ; Set < Integer > testing_floor = new HashSet < Integer > ( ) ; for ( int i = 1 ; i < getFloorCount ( ) ; i ++ ) { testing_floor . add ( i ) ; } for ( x = 50 ; x < getFloorCount ( ) ; x ++ ) { if ( testing_floor . contains ( x ) ) { if ( testFloor ( x ) ) { if ( vajce == 1 ) { tmp = testFloor ( x + 1 ) ; } else { tmp = testFloor ( x + y ) ; } if ( ! tmp ) { } else { x = x + y ; } if ( ! tmp && vajce <= 1 ) { res = x ; return res ; } } else { vajce -- ; y = 1 ; if ( vajce <= 0 ) { res = x - 1 ; return res ; } tmp = testFloor ( z ) ; if ( tmp ) { x = z - 1 ; } else { break ; } } testing_floor . remove ( x ) ; } if ( ! tmp ) { vajce -- ; } if ( vajce <= 0 ) { break ; } y /= 2 ; if ( z >= getFloorCount ( ) ) { break ; } } res = x ; return res ; }
@return maximum Floor of unbroken egg
@return maximum Floor of unbroken egg
// set of testing floor  // adding every floor into set // nothing to do  // posledne vajce bolo rozbite // posledne vajce bolo rozbite // vrat predosle poschodie // aby zacalo testovat od prveho poschodia // after test remove item from set