VB.NET Source Code

Option Strict 

Imports System

rem Author: Hannes du Plooy
rem Date: 8 October 2013
rem Objective: To solve the following
rem  ONE
rem  ONE
rem  ONE
rem +ONE
rem ----
rem  TEN

Public Module Puzzle001
    Public Sub Main()
        Dim O As Integer
        Dim E As Integer
        Dim N As Integer
        Dim T As Integer
        Dim E2 As Integer
        Dim carry1 As Integer
        Dim carry2 As Integer
        Dim tmp1 As Integer
        Dim tmp2 As Integer
        Dim done as Boolean
        
        done = false
        For O = 1 to 9
            For E = 0 to 9
                If O <> E Then
	                tmp1 = E*4
	                carry1 = tmp1 \ 10
	                N = tmp1 mod 10
	                tmp2 = carry1 + N*4
	                carry2 = tmp2 \ 10
	                E2 = tmp2 mod 10
	                T = carry2 + O*4
	                If Not (N = O OR N = E OR E2 <> E OR T >= 10 OR T = O OR T = E OR T = N) Then
	                    Console.WriteLine("Answer is")
	                    Console.WriteLine("")
	                    Console.WriteLine(" "  & O  & N  & E)
	                    Console.WriteLine(" "  & O  & N  & E)
	                    Console.WriteLine(" "  & O  & N  & E)
	                    Console.WriteLine(" "  & O  & N  & E)
	                    Console.WriteLine("----")
	                    Console.WriteLine(" "   & T  & E  & N)
	                    done = true
	                    Exit For
	                End If
                End If
            Next E
            If done Then
                Exit For
            End If
        Next O
    End Sub
End Module