Compare commits
8 Commits
9870335263
...
hw6
| Author | SHA1 | Date | |
|---|---|---|---|
| 63af3ed7b4 | |||
| b2c005e22c | |||
| 4cf2f56749 | |||
| b0c3660f16 | |||
| b47e479b95 | |||
| eb509fb846 | |||
| 5f692a4708 | |||
| b98abb94cc |
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
**node_modules
|
**node_modules
|
||||||
**to_reform
|
**to_reform
|
||||||
|
.vscode
|
||||||
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 159 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 229 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 347 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 5.2 MiB After Width: | Height: | Size: 5.2 MiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
|
Before Width: | Height: | Size: 4.4 MiB After Width: | Height: | Size: 4.4 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
112
hw/hw6/hw6.js
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
let templates = [
|
||||||
|
[
|
||||||
|
"X--X----",
|
||||||
|
"-XXX-X--",
|
||||||
|
"----X---",
|
||||||
|
"----X---",
|
||||||
|
"------XX",
|
||||||
|
"----XX--",
|
||||||
|
"X-------",
|
||||||
|
"-XX--X--"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"---XX---",
|
||||||
|
"----X-X-",
|
||||||
|
"---XX---",
|
||||||
|
"---X----",
|
||||||
|
"-X------",
|
||||||
|
"X----X-X",
|
||||||
|
"--X--X--",
|
||||||
|
"-X----XX"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"-X-X----",
|
||||||
|
"---X-X--",
|
||||||
|
"X-XX--X-",
|
||||||
|
"--X-X---",
|
||||||
|
"------X",
|
||||||
|
"--------",
|
||||||
|
"X-----X-",
|
||||||
|
"-X-X---X"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"-XX-X---",
|
||||||
|
"-----X--",
|
||||||
|
"----X---",
|
||||||
|
"-----X-X",
|
||||||
|
"-X-X--X-",
|
||||||
|
"-XX----X",
|
||||||
|
"-X------",
|
||||||
|
"XX------"
|
||||||
|
], [
|
||||||
|
"----XX-X",
|
||||||
|
"X-------",
|
||||||
|
"--------",
|
||||||
|
"-----XX-",
|
||||||
|
"---X-X--",
|
||||||
|
"-X---XX-",
|
||||||
|
"-X-X----",
|
||||||
|
"----XXX-"
|
||||||
|
], [
|
||||||
|
"XX------",
|
||||||
|
"-----X--",
|
||||||
|
"-------X",
|
||||||
|
"-X-X----",
|
||||||
|
"X-X----X",
|
||||||
|
"-X-X-X-X",
|
||||||
|
"----X-X-",
|
||||||
|
"-X------"
|
||||||
|
],
|
||||||
|
];
|
||||||
|
const squareSize = templates[0].length;
|
||||||
|
|
||||||
|
//convert to arrays for mutability
|
||||||
|
let temp = []
|
||||||
|
for (let n = 0; n < templates.length; n++) {
|
||||||
|
temp.push([])
|
||||||
|
for (let i = 0; i < squareSize; i++) {
|
||||||
|
temp[n].push([]);
|
||||||
|
for (let j = 0; j < squareSize; j++) {
|
||||||
|
temp[n][i].push(templates[n][i][j] == "X" ? 1 : 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templates = temp;
|
||||||
|
|
||||||
|
const encodedMsg = "Р_НАЙА_СЛЗДЕ_ЛОСЖСТОИКНОЛЬЛЬТКУЮО__КЗАЕ_ДВАОКАЧОЖЗ_УЧАСМОДУ_ТЮЖЕ";
|
||||||
|
|
||||||
|
|
||||||
|
function rotateTemplate(template) {
|
||||||
|
for (let i = 0; i < squareSize; i++) {
|
||||||
|
for (let j = 0; j < i; j++) {
|
||||||
|
let temp = template[i][j];
|
||||||
|
template[i][j] = template[j][i];
|
||||||
|
template[j][i] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < squareSize; i++) {
|
||||||
|
for (let j = 0; j < squareSize / 2; j++) {
|
||||||
|
let temp = template[i][j];
|
||||||
|
template[i][j] = template[i][(squareSize - 1) - j];
|
||||||
|
template[i][(squareSize - 1) - j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let n = 0; n < templates.length; n++) {
|
||||||
|
let out = ""
|
||||||
|
for (let rot = 0; rot < 4; rot++) {
|
||||||
|
for (let i = 0; i < squareSize; i++) {
|
||||||
|
for (let j = 0; j < squareSize; j++) {
|
||||||
|
if (templates[n][i][j]) {
|
||||||
|
out += encodedMsg[i * squareSize + j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rotateTemplate(templates[n]);
|
||||||
|
}
|
||||||
|
console.log(out);
|
||||||
|
console.log("=======");
|
||||||
|
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 37 KiB |