Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $lines = [IO.File]::ReadAllText("D:\scripts\Sequences.txt") -split "[\r\n]" | where {$_}
- $grid = New-Object 'object[,]'3,3
- $grid[0,0] = 1
- $grid[0,1] = 2
- $grid[0,2] = 3
- $grid[1,0] = 4
- $grid[1,1] = 5
- $grid[1,2] = 6
- $grid[2,0] = 7
- $grid[2,1] = 8
- $grid[2,2] = 9
- $x = 1
- $y = 1
- function CodeDigit($sequencetocheck){
- for($i=0; $i -lt $sequencetocheck.length; $i++){
- if($sequencetocheck[$i] -eq 'U'){
- if ($y -ne 0){
- $y -= 1
- }
- }
- elseif($sequencetocheck[$i] -eq 'D'){
- if ($y -ne 2){
- $y += 1
- }
- }
- elseif($sequencetocheck[$i] -eq 'R'){
- if ($x -ne 2){
- $x += 1
- }
- }
- else{
- if ($x -ne 0){
- $x -= 1
- }
- }
- }
- return $grid[$y,$x]
- }
- $one = CodeDigit($lines[0])
- $two = CodeDigit($lines[1])
- $three = CodeDigit($lines[2])
- $four = CodeDigit($lines[3])
- $five = CodeDigit($lines[4])
- write-host 'Urination Authorization Code:' $one$two$three$four$five
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement