Jump to content

Positive decimal integers with the digit 1 occurring exactly twice: Difference between revisions

→‎Pascal: replace complicated solution with straightforward implementation working with any dialect of Pascal
(Ada version)
(→‎Pascal: replace complicated solution with straightforward implementation working with any dialect of Pascal)
Line 158:
Number 1 occurs twice 1-999: 27
</pre>
 
==={{header|Free PascalDelphi}}===
''See [[#Pascal|Pascal]]''
 
=={{header|F_Sharp|F#}}==
Line 199 ⟶ 202:
print</lang>
{{out}}<pre>11 101 110 112 113 114 115 116 117 118 119 121 131 141 151 161 171 181 191 211 311 411 511 611 711 811 911</pre>
 
=={{header|Free Pascal}}==
''See [[#Pascal|Pascal]]''
 
=={{header|Go}}==
Line 430 ⟶ 436:
11 101 110 112 113 114 115 116 117 118 119 121 131 141 151 161 171 181 191 211 311 411 511 611 711 811 911</pre>
=={{header|Pascal}}==
<lang pascal>program positiveDecimalIntegersWithTheDigit1occurringExactlyTwice(output);
==={{header|Free Pascal}}===
<lang pascal>
program OneOne;
const
SUBSTITUTES ='023456789';
ONES = '111';
var
col,idx n: integer;
new : string[3];
begin
for For coln := 1 to 3999 do
begin
if ord(n mod 10 = 1) + ord(n mod 100 div 10 = 1) + ord(n div 100 = 1) = 2 then
new := ONES;
begin
For idx := 1 to length(SUBSTITUTES) do
writeLn(n)
begin
end;
new[col] := SUBSTITUTES[idx];
end
write(new:4);
end;
writeln;
end;
end.</lang>
{{Out}}
<pre>
011 211 311 411 511 611 711 811 911
101 121 131 141 151 161 171 181 191
110 112 113 114 115 116 117 118 119</pre>
 
=={{header|Perl}}==
149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.