-
Notifications
You must be signed in to change notification settings - Fork 28
/
Shapes.kt
52 lines (49 loc) · 974 Bytes
/
Shapes.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
fun main() {
// Square Variables
val sqSide = 7
val sqChar1 = "X "
val sqChar2 = "O "
// Write your code below
for (i in 1..sqSide) {
for (j in 1..sqSide) {
if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 ==1) {
print(sqChar1)
} else {
print(sqChar2)
}
}
println()
}
// Triangle Variables
val triRows = 10
var triCount = 0
var triRowLen = triRows
val triChar1 = "/ "
val triChar2 = " "
// Write your code below
for (i in triRows downTo 1) {
while (triCount < triRowLen) {
triCount++
print(triChar1)
}
println()
triCount = 0
triRowLen--
}
triRowLen = triRows
for (i in triRows downTo 1) {
while (triCount < triRowLen) {
triCount++
if (triCount != 1 && triCount != triRowLen && i != triRows) {
print(triChar2)
} else {
print(triChar1)
}
}
println()
triCount = 0
triRowLen--
}
}