package ru.skrser.ctci1dot6;

/**
 * Created by Sergey Skryabin
 * on 01.01.2017.
 */
public class Solution {
}

@@ -103,10 +103,952 @@
 ution %7B%0A
+%0A    public static void rotate(byte%5B%5D%5B%5D%5B%5D image) %7B%0A        if (image == null)%0A            return;%0A        if (image.length != image%5B0%5D.length) // TODO%0A            throw new IllegalArgumentException(%22Image should be square to rotate!%22);%0A        int quater = image.length/2 + image.length%252;%0A        for (int i = 0; i %3C quater;i++) %7B%0A            for (int j = 0; j %3C quater; j++) %7B%0A                rotatePixel(image, i, j);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private static void rotatePixel(byte%5B%5D%5B%5D%5B%5D image, int x, int y) %7B%0A        byte%5B%5D tmpPixel = image%5Bx%5D%5By%5D;%0A%0A        int prevX = x;%0A        int prevY = y;%0A        int nextX;%0A        int nextY;%0A%0A        for (int i = 0; i%3C 3; i++) %7B%0A            nextX = image.length - 1 - prevY;%0A            nextY = image.length - 1 - prevX;%0A            image%5BprevX%5D%5BprevY%5D = image%5BnextX%5D%5BnextY%5D;%0A            prevX = nextX;%0A            prevY = nextY;%0A        %7D%0A        image%5BprevX%5D%5BprevY%5D = tmpPixel;%0A    %7D%0A%0A
 %7D%0A

question 1.6