-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1028.ps1
More file actions
32 lines (30 loc) · 902 Bytes
/
Copy path1028.ps1
File metadata and controls
32 lines (30 loc) · 902 Bytes
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
## Write a program which draws a diamond of the form illustrted
## below. The letter which is to appear at the widest point of the
## figure (E in the example) is to be specified as the input data.
## A
## B B
## C C
## D D
## E E
## D D
## C C
## B B
## A
Param([char]$letter = "E")
$start = [int][char]"B"
$end = [int]$letter
$outerpadding = ($end - $start) + 5
$innerpadding = -1
Write-Host "$(" " * $outerpadding)A"
foreach($char in ([string[]][char[]]($start..$end))) {
$innerpadding += 2
$outerpadding--
Write-Host "$(" " * $outerpadding)$char$(" " * $innerpadding)$char"
}
$end--
foreach($char in ([string[]][char[]]($end..$start))) {
$innerpadding -= 2
$outerpadding++
Write-Host "$(" " * $outerpadding)$char$(" " * $innerpadding)$char"
}
Write-Host "$(" " * $outerpadding) A"