|
@@ -182,4 +182,87 @@ for(let i = 0; i < 10; i++) {
|
|
|
}
|
|
|
numbers += '\n'
|
|
|
}
|
|
|
-console.log(numbers)
|
|
|
+console.log(numbers)
|
|
|
+
|
|
|
+//chess
|
|
|
+let height = 3
|
|
|
+let width = 12
|
|
|
+let chessboard = ''
|
|
|
+for(let i = 0; i < height; i++) {
|
|
|
+ for(let j = 0; j < width; j++) {
|
|
|
+ i % 2 === 0? (j % 2 === 0? chessboard+='.' : chessboard+='#') : (j % 2 === 0? chessboard +='#' : chessboard+='.')
|
|
|
+ }
|
|
|
+ chessboard += '\n'
|
|
|
+}
|
|
|
+console.log(chessboard)
|
|
|
+
|
|
|
+//cubes
|
|
|
+let cubes = new Array(10)
|
|
|
+for(let i = 0; i < cubes.length; i++) { cubes[i] = i**3 }
|
|
|
+console.log(cubes)
|
|
|
+
|
|
|
+//multiply table
|
|
|
+let mulTable = []
|
|
|
+for(let i = 0; i < 10; i++) {
|
|
|
+ let innerArr = []
|
|
|
+ for(let j = 0; j < 10; j++) {
|
|
|
+ innerArr.push(i * j)
|
|
|
+ }
|
|
|
+ mulTable[i] = innerArr
|
|
|
+}
|
|
|
+console.log(mulTable[5][6]) //будет 30 (но есть нулевые елементы в массиве)
|
|
|
+
|
|
|
+//matrix to html table
|
|
|
+let tableStr = ''
|
|
|
+let colors = ['red', 'orange', 'yellow', 'green', 'skyblue', 'blue', 'purple', 'red', 'orange']
|
|
|
+let prevColors = []
|
|
|
+tableStr += '<table>'
|
|
|
+for (let i = 1; i < mulTable.length; i++) {
|
|
|
+ tableStr += `<tr>`
|
|
|
+ prevColors.push(colors[i - 1])
|
|
|
+ for (let j = 1; j < mulTable.length; j++) {
|
|
|
+ tableStr += `<td
|
|
|
+ style="text-align: center;
|
|
|
+ color: white;
|
|
|
+ text-shadow: 1px 1px 2px black;
|
|
|
+ background-color: ${j >= prevColors.length? prevColors[i-1] : prevColors[j-1]}";"
|
|
|
+ > ${mulTable[i][j]} </td>`
|
|
|
+ }
|
|
|
+ tableStr += '</tr>'
|
|
|
+}
|
|
|
+tableStr += '</table>'
|
|
|
+document.write(tableStr)
|
|
|
+
|
|
|
+//blue belt
|
|
|
+let trigon = ''
|
|
|
+for(let i = 6, step = 1; i > 0; i--) {
|
|
|
+ let repeats = 10
|
|
|
+ for(let j = 0; j <= repeats; j++) {
|
|
|
+ if(j === i - 1) {
|
|
|
+ repeats = repeats - step + 1
|
|
|
+ for(let k = 0; k < step; k++) {
|
|
|
+ trigon += '#'
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ trigon += '.'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ trigon += '\n'
|
|
|
+ step += 2
|
|
|
+}
|
|
|
+console.log(trigon)
|
|
|
+
|
|
|
+// //blacke belt
|
|
|
+// let history = [1, 1, 1, 1]
|
|
|
+// let predictArray[1][1][1][1] = 0
|
|
|
+
|
|
|
+// while(true) {
|
|
|
+// let variant = +prompt('input 1 or 0') || alert('wrong input!')
|
|
|
+
|
|
|
+// if(+variant === 1 || +variant === 0) {
|
|
|
+
|
|
|
+// history.shift()
|
|
|
+// history.push(variant)
|
|
|
+// }
|
|
|
+// }
|