Imports system.io Module Module1 Sub Main() Dim ins As New FileStream("DATA4.txt", FileMode.Open, FileAccess.Read) Dim read As New StreamReader(ins) Dim outs As New FileStream("OUT4.txt", FileMode.Create, FileAccess.Write) Dim write As New StreamWriter(outs) Dim aa As String Dim totalcom As Integer Dim ary(20, 20, 20) As Integer Dim total As Integer For z As Integer = 0 To 4 For x As Integer = 0 To 9 aa = read.ReadLine For y As Integer = 0 To 9 If aa.Chars(y) = "#" Then totalcom += 1 ary(totalcom, 0, 0) = y ary(totalcom, 1, 0) = x End If Next Next Dim tempy1, tempx1, tempy2, tempx2, tempx3, tempy3 As Integer Dim temp3, temp4 As Integer Select Case totalcom Case 2 tempy1 = ary(1, 0, 0) tempx1 = ary(1, 1, 0) tempy2 = ary(2, 0, 0) tempx2 = ary(2, 1, 0) temp3 = tempx2 - tempx1 If temp3 < 0 Then temp3 *= -1 End If temp4 = tempy2 - tempy1 If temp4 < 0 Then temp4 *= -1 End If total = temp4 + temp3 total *= 2 Case 3 tempy1 = ary(1, 1, 0) tempx1 = ary(1, 0, 0) tempy2 = ary(2, 1, 0) tempx2 = ary(2, 0, 0) tempy3 = ary(3, 1, 0) tempx3 = ary(3, 0, 0) temp3 = tempx2 - tempx1 temp4 = tempy2 - tempy1 If temp3 < 0 Then temp3 *= -1 End If If temp4 < 0 Then temp4 *= -1 End If total += temp4 + temp3 temp3 = tempy3 - tempx2 temp4 = tempy3 - tempx2 If temp3 < 0 Then temp3 *= -1 End If If temp4 < 0 Then temp4 *= -1 End If total += temp4 + temp3 temp3 = tempy3 - tempx1 temp4 = tempy3 - tempx1 If temp3 < 0 Then temp3 *= -1 End If If temp4 < 0 Then temp4 *= -1 End If total += temp4 + temp3 Case Else total = 64 End Select write.WriteLine(total) Next write.Close() End Sub End Module