• + 0 comments

    Solution in C

        int height = 1, springs = n/2 + n%2, summers = n - springs;
        for (; springs > 0; springs--) {
            height *= 2;
            if(summers > 0) height++, summers--;
        }
        return height;