Yandex Frontend Contest. Task 8.

Solution with 5 div only.

HTML

<div class="s s1"></div>
<div class="s s2"></div>
<div class="s s4"></div>
<div class="s s5"></div>
<div class="s s6"></div>

CSS

.s {
width: 150px; height: 150px;
border: 30px double #000;
position: absolute;
background-color: #fff;
}
.s::before {
content: "";
display: block;
position: absolute;
width: 70px; height: 70px;
left: 10px; top: 10px;
border: 30px double #000;
background-color: #fff;
z-index: inherit;
}
.s::after {
    content: "";
    display: block;
    position: absolute;
    border: 30px double #000;
    background-color: #fff;
    z-index: inherit;
}
html, body {
padding: 0; margin: 0;
}
body {
padding: 315px; width: 0; height: 0; position: relative;
}

body::before {
    content: "";
    display: block;
left: 0; top: 140px;
width: 110px; height: 150px;
border: 30px double #000;
border-right: 0;
position: absolute;
background-color: #fff;
}
body::after{
    content: "";
    display: block;
position: absolute;
width: 70px; height: 70px;
left: 40px; top: 180px;
border: 30px double #000;
border-right: 0;
background-color: #fff;
}


.s2 {
right: 0; top: 0;
}
.s4 {
right: 0; bottom: 140px;
}
.s6 {
right: 140px; bottom: 0;
}

.s1 {
left: 140px; top: 0;
height: 530px;
border-bottom: 0;
z-index: 5;
}
.s1::before {
    height: 490px;
    border-bottom: 0;
}
.s1::after {
    width: 210px;
    height: 10px;
    left: 40px;
    top: 110px;
    border-left: 0 none;
    border-right: 0 none;
}

.s2 {
    z-index: 4;
}
.s2::after {
    width: 10px;
    height: 350px;
    left: -30px;
    top: 110px;
    border-top: 0 none;
    border-bottom: 0 none;
}


.s5 {
    left: 0; bottom: 0;
    z-index: 4;
}
.s5::after {
    right: -380px;
    top: -170px;
    width: 210px;
    height: 10px;
    border-left: 0 none;
    border-right: 0 none;
}

.s4 {
    z-index: 6;
    border-left: 0;
    width: 110px;
}
.s4::before {
    border-left: 0;
    left: 0;
}
.s4::after {
    left: -280px;
    top: 110px;
    width: 210px;
    height: 10px;
    border-left: 0 none;
    border-right: 0 none;
}

.s4 {
    z-index: 6;
    border-left: 0;
    width: 110px;
}
.s4::before {
    border-left: 0;
    left:...