Pascal Source Code

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

program puzzle001;
var
  O,E,N,T,E2,carry,tmp: integer;
  done: boolean;
begin
    done := false;
    for O := 1 to 9 do 
    begin
        for E := 0 to 9 do 
        begin
            if O <> E then
            begin
                tmp := E*4;
	            carry := tmp div 10;
	            N := tmp mod 10;
	            tmp := carry + N*4;
	            carry := tmp div 10;
	            E2 := tmp mod 10;
	            T := carry + O*4;
	            if (N <> O) AND (N <> E) AND (E2 = E) AND (T < 10) AND (T <> O) AND (T <> E) AND (T <> N) then
	            begin
	                writeln('Answer is');
	                writeln('');
	                writeln(' ',O,N,E);
	                writeln(' ',O,N,E);
	                writeln(' ',O,N,E);
	                writeln('+',O,N,E);
	                writeln('----');
	                writeln(' ',T,E,N);
	                done := true;
	                break;
	            end;
            end;
        end;
        if done then break;
    end;
end.