
separate (asudx.getkeyinputs)

function lphints( nchn: in integer ) return boolean is 
--helpful comments to console


	procedure boxes1( wasOutput: in out boolean ) is
		k1, k2, bnum: integer;
	begin
		for br in 0..2 loop
		for bc in 0..2 loop
			bnum:=br*3+bc+1;
			k1:=0; k2:=0;
			for r in 0..2 loop
			for c in 0..2 loop
				if colorL2(digSelect,nchn, br*3+r+1, bc*3+c+1)=1 then k1:=k1+1; end if;
				if colorL2(digSelect,nchn, br*3+r+1, bc*3+c+1)=2 then k2:=k2+1; end if;
			end loop;
			end loop;
			if k1>1 then

				put(" LinkedPairs box#"&i2st(bnum));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for r in 0..2 loop
				for c in 0..2 loop
				if colorL2(digSelect,nchn,br*3+r+1,bc*3+c+1)=1 then
					colorL2(digSelect,nchn,br*3+r+1,bc*3+c+1):=3; 
				end if;
				end loop;
				end loop;

			end if;
			if k2>1 then

				put(" LinkedPairs box#"&i2st(bnum));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for r in 0..2 loop
				for c in 0..2 loop
				if colorL2(digSelect,nchn,br*3+r+1,bc*3+c+1)=2 then
					colorL2(digSelect,nchn,br*3+r+1,bc*3+c+1):=3; 
				end if;
				end loop;
				end loop;

			end if;
		end loop;
		end loop;
	end boxes1;

	procedure rows1( wasOutput: in out boolean ) is
		k1, k2: integer;
	begin
		for row in 1..9 loop
			k1:=0; k2:=0;
			for col in 1..9 loop
				if colorL2(digSelect,nchn, row,col)=1 then k1:=k1+1; end if;
				if colorL2(digSelect,nchn, row,col)=2 then k2:=k2+1; end if;
			end loop; --row
			if k1>1 then

				put(" LinkedPairs row:"&i2st(row));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for col in 1..9 loop
				if colorL2(digSelect,nchn,row,col)=1 then
					colorL2(digSelect,nchn,row,col):=3; 
				end if;
				end loop;

			end if;
			if k2>1 then

				put(" LinkedPairs row:"&i2st(row));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for col in 1..9 loop
				if colorL2(digSelect,nchn,row,col)=2 then
					colorL2(digSelect,nchn,row,col):=3; 
				end if;
				end loop;

			end if;
		end loop; --row
	end rows1;


	procedure cols1( wasOutput: in out boolean ) is
		k1, k2: integer;
	begin
		for col in 1..9 loop
			k1:=0; k2:=0;
			for row in 1..9 loop
				if colorL2(digSelect,nchn, row,col)=1 then k1:=k1+1; end if;
				if colorL2(digSelect,nchn, row,col)=2 then k2:=k2+1; end if;
			end loop; --row
			if k1>1 then

				put(" LinkedPairs col:"&i2st(col));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for row in 1..9 loop
				if colorL2(digSelect,nchn,row,col)=1 then
					colorL2(digSelect,nchn,row,col):=3; 
				end if;
				end loop;

			end if;
			if k2>1 then

				put(" LinkedPairs col:"&i2st(col));
				put(", dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for row in 1..9 loop
				if colorL2(digSelect,nchn,row,col)=2 then
					colorL2(digSelect,nchn,row,col):=3; 
				end if;
				end loop;

			end if;
		end loop; --row
	end cols1;


	procedure fdiag1( wasOutput: in out boolean ) is
		k1, k2: integer;
	begin
			k1:=0; k2:=0;
			for diag in 1..9 loop
				if colorL2(digSelect,nchn, diag,diag)=1 then k1:=k1+1; end if;
				if colorL2(digSelect,nchn, diag,diag)=2 then k2:=k2+1; end if;
			end loop; --row
			if k1>1 then

				put(" LinkedPairs FwdDiag:");
				put(" dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for diag in 1..9 loop
				if colorL2(digSelect,nchn,diag,diag)=1 then
					colorL2(digSelect,nchn,diag,diag):=3; 
				end if;
				end loop;

			end if;
			if k2>1 then

				put(" LinkedPairs FwdDiag:");
				put(" dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for diag in 1..9 loop
				if colorL2(digSelect,nchn,diag,diag)=2 then
					colorL2(digSelect,nchn,diag,diag):=3; 
				end if;
				end loop;

			end if;
	end fdiag1;

	procedure bdiag1( wasOutput: in out boolean )  is
		k1, k2: integer;
	begin
			k1:=0; k2:=0;
			for diag in 1..9 loop
				if colorL2(digSelect,nchn, diag,10-diag)=1 then k1:=k1+1; end if;
				if colorL2(digSelect,nchn, diag,10-diag)=2 then k2:=k2+1; end if;
			end loop; --row
			if k1>1 then

				put(" LinkedPairs BakDiag:");
				put(" dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for diag in 1..9 loop
				if colorL2(digSelect,nchn,diag,10-diag)=1 then
					colorL2(digSelect,nchn,diag,10-diag):=3; 
				end if;
				end loop;

			end if;
			if k2>1 then

				put(" LinkedPairs BakDiag:");
				put(" dig= "&i2st(digSelect));
				put("...multiple same-color-digits => removable.");
				new_line;
				wasOutput:=true;

				for diag in 1..9 loop
				if colorL2(digSelect,nchn,diag,10-diag)=2 then
					colorL2(digSelect,nchn,diag,10-diag):=3; 
				end if;
				end loop;

			end if;
	end bdiag1;










	procedure sees2colors( wasOutput: in out boolean )  is 
	--a dig sees both colors in its 4 houses



		procedure search(rr,cc,xx: s9;  found: out boolean) is

			rowyes, colyes, boxyes, fdyes, bdyes: boolean := false;

			procedure rowsearch is
			begin
				for c in 1..9 loop
					if c/=cc then
					if colorL2(digSelect,nchn,rr,c)=xx then
						rowyes:=true;
					end if;
					end if;
				end loop;
			end rowsearch;

			procedure colsearch is
			begin
				for r in 1..9 loop
					if r/=rr then
					if colorL2(digSelect,nchn,r,cc)=xx then
						colyes:=true;
					end if;
					end if;
				end loop;
			end colsearch;

			procedure Fdiagsearch is --rr=cc
			begin
				for diag in 1..9 loop
				if diag/=rr then
				if colorL2(digSelect,nchn,diag,diag)=xx then
					fdyes:=true;
				end if;
				end if;
				end loop;
			end Fdiagsearch;

			procedure Bdiagsearch is --rr=10-cc
			begin
				for diag in 1..9 loop
				if diag/=rr then
				if colorL2(digSelect,nchn,diag,10-diag)=xx then
					bdyes:=true;
				end if;
				end if;
				end loop;
			end Bdiagsearch;
					

			procedure boxsearch is
				thisbr, thisbc, lr, lc: integer;
			begin
				thisbr:= (rr-1)/3;
				thisbc:= (cc-1)/3;

				for r in 0..2 loop
				for c in 0..2 loop
					lr:=thisbr*3+r+1;
					lc:=thisbc*3+c+1;
					if lr/=rr or lc/=cc then
					if colorL2(digSelect,nchn,lr,lc)=xx then
						boxyes:=true;
					end if;
					end if;
				end loop; --c
				end loop; --r

			end boxsearch;


		begin
			rowsearch;
			colsearch;
			boxsearch;

			if rr=cc then
				Fdiagsearch;
			end if;

			if rr=10-cc then
				Bdiagsearch;
			end if;

			found := boxyes or colyes or rowyes or fdyes or bdyes;

		end search;



		found1, found2: boolean;
	begin


		--pick a cell with digSelect still a candidate
		for row in 1..9 loop
		for col in 1..9 loop
		if candidate(row,col)(digSelect) and colorL2(digSelect,nchn,row,col)=0 then
			--search 4 houses of (row,col) for both a 1-color and a 2-color
			search(row,col,1, found1);
			search(row,col,2, found2);
			if found1 and found2 then

				colorL2(digSelect,nchn,row,col):=3; --signifies removable
				put(" LinkedPairs: removable dig= "
					&i2st(digSelect)&" @("
					&i2st(row)
					&","
					&i2st(col)
					&") can see 2 colors!");
				new_line;
				wasOutput:=true;
			end if;
		end if;
		end loop; --col
		end loop; --row

	end sees2colors;



	written: boolean;

begin

	written:=false;

	--houses with same color twice
	boxes1(written);
	rows1(written);
	cols1(written);
	fdiag1(written);
	bdiag1(written);


	-- digit that see both colors
	sees2colors(written);

	if written then
		put(digBuf(digSelect,nchn));
		new_line; --separate console output from any prior
	end if;

	return written;

end lphints;


