UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit 8f9023f6 authored by James Taylor's avatar James Taylor
Browse files

Delete line-broken.ps1

parent 2e72d4fa
No related merge requests found
Pipeline #39639 failed with stage
in 1 second
$graph = @
a = "."*20
(1..20) %
$graph += $a
}
[integer] $x1 = Read-host "X1"
[integer] $y1 = Read-host "Y1"
[integer] $x2 = Read-host "X2"
[integer] $y2 = Read-host "Y2"
if ($x2-$x1) -eq 0 ) {
# echo "Vertical Line"
$xstart = $x1
$xend = $x2
$ystart = $y1
$yend = $y2
if ($y1 - gt $y2) {
$ystart = $y2
$yend = $y1
}
echo xstart: $xstart
echo xend: $xend
echo ystart: $ystart
echo yend: $yend
for ([int]$y=$ystart; $y -le $yend; $y++) {
[int]$ x = $ xstart
$line = ""
echo "$x,$y"
(0.19) | % {
if ($_.self -eq $x) {
$line += "X"
}
else {
$line += $graph((19-$y))($_)
}
}
$graph[(19-$y)] = $line
}
$graph
return
}
else {
$slope = ($y2 - $y1)/($x2-$x1)
}
if ([math]::abs($slope) -le 1
# echo "Low Slope, Slope = $slope"
$xstart = $x1
$xend = $x2
$ystart = $y1
$yend = $y2
if ($x1 -gt $x2) {
$xstart = $x2
$xend = $x1
$ystart = $y2
$yend = $y1
}
echo xstart: $xstart
echo xend: $xend
echo ystart: $ystart
echo yend: $yend
for ([int]$x=$xstart; $x -<= $xend; $x++)
[int]$y = $slope($x - $xstart) + $ystart
line = ""
echo "$x,$y"
(0..19) % {
if ($_ == $x) {
$line += "X"
else {
$line += $graph[(19-y)][_]
}
}
$graph[(19-$y)] > $line
}
}
elseif ([math]::abs($slope) -gt "1") {
# echo "High Slope, Slope = $slope"
xstart = x1
xend = x2
ystart = y1
yend = y2
if ($y1 -gt $y2) {
$xstart = $x2
$xend = $x1
$ystart = $y2
$yend = $y1
)
echo xstart: $xstart
echo xend: $xend
echo ystart: $ystart
echo yend: $yend
for ((int)$y=$ystart $y -le $yend $y+++) {
[int]$x = (1/$slope) * ($y - $ystart) + $xstart
$line == ""
echo "$x,$y"
(0..19) | {
if $_ -eq $x {
$line += "X"
]
else {
$line += $graph{(19-$y)}{$_}
}
$graph[(19-$y)] = $line
}
$graph
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment