Numbers with same digit set in base 10 and base 16: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: chanched to to_set method) |
No edit summary |
||
Line 400: | Line 400: | ||
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128 |
71511 75120 75121 75122 75123 75124 75125 75126 75127 75128 |
||
75129 75621 86150 88165 91465 91769 96617 98711 99481</pre> |
75129 75621 86150 88165 91465 91769 96617 98711 99481</pre> |
||
=={{header|Delphi}}== |
|||
{{works with|Delphi|6.0}} |
|||
{{libheader|SysUtils,StdCtrls}} |
|||
<syntaxhighlight lang="Delphi"> |
|||
function HasSameDigits1016(N: integer): boolean; |
|||
{Return true if base-10 string and base-16 string have same characters} |
|||
var S10,S16: string; |
|||
var I: integer; |
|||
begin |
|||
Result:=False; |
|||
{Get base-10 and -16 string} |
|||
S10:=IntToStr(N); |
|||
S16:=Format('%x',[N]); |
|||
{Compare S10 to S16} |
|||
for I:=1 to Length(S10) do |
|||
if Pos(S10[I],S16)=0 then exit; |
|||
{Compare S16 to S10} |
|||
for I:=1 to Length(S16) do |
|||
if Pos(S16[I],S10)=0 then exit; |
|||
Result:=True; |
|||
end; |
|||
procedure ShowSameDigits1016(Memo: TMemo); |
|||
var I,Cnt: integer; |
|||
var S: string; |
|||
begin |
|||
Cnt:=0; |
|||
for I:=0 to 100000-1 do |
|||
if HasSameDigits1016(I) then |
|||
begin |
|||
Inc(Cnt); |
|||
S:=S+Format('%8D',[I]); |
|||
If (Cnt mod 5)=0 then S:=S+CRLF; |
|||
end; |
|||
Memo.Lines.Add(S); |
|||
Memo.Lines.Add('Count='+IntToStr(Cnt)); |
|||
end; |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
0 1 2 3 4 |
|||
5 6 7 8 9 |
|||
53 371 913 1040 2080 |
|||
2339 4100 5141 5412 5441 |
|||
6182 8200 9241 13593 13665 |
|||
13969 16406 20530 26946 30979 |
|||
32803 33638 33840 33841 33842 |
|||
33843 33844 33845 33846 33847 |
|||
33848 33849 34883 37943 38931 |
|||
38966 38995 66310 71444 71497 |
|||
71511 75120 75121 75122 75123 |
|||
75124 75125 75126 75127 75128 |
|||
75129 75621 86150 88165 91465 |
|||
91769 96617 98711 99481 |
|||
Count=69 |
|||
Elapsed Time: 41.373 ms. |
|||
</pre> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |