Fortran 90 Source Code
! Author: Hannes du Plooy
! Date: 8 October 2013
! Objective: To solve the following
! ONE
! ONE
! ONE
! +ONE
! ----
! TEN
program puzzle001
implicit none
integer :: O, E, N, T, E2, carry1, tmp1, carry2, tmp2
character(len=4) :: line
do O=1,9
do E=0,9
if (O /= E) then
tmp1 = E*4
carry1 = tmp1 / 10
N = MOD(tmp1,10)
tmp2 = carry1 + N*4
carry2 = tmp2 / 10
E2 = MOD(tmp2,10)
T = carry2 + O*4
if (N /= O .and. N /= E .and. E2 == E .and. T < 10 .and. T /= O .and. T /= E .and. T /= N) then
write(*,*) "Answer is"
write(*,*) ""
line = " " // char(O+48) // char(N+48) // char(E+48)
write(*,*) line
write(*,*) line
write(*,*) line
write(*,*) "+" // char(O+48) // char(N+48) // char(E+48)
write(*,*) "----"
write(*,*) " " // char(T+48) // char(E+48) // char(N+48)
stop
endif
endif
enddo
enddo
end program