Numbers with same digit set in base 10 and base 16: Difference between revisions
Numbers with same digit set in base 10 and base 16 (view source)
Revision as of 22:29, 6 June 2021
, 3 years ago→{{header|Julia}}
(→{{header|REXX}}: changed "</rexx>" to "</lang>" - and now it displays better. :-)) |
|||
Line 107:
=={{header|Julia}}==
The requirements seem to depend upon interpretations of set and duplicates. Hex number is shown to demonstrate how numbers fit the revised task.
<lang Julia>using Combinatorics
function dheq(N)
found = Set{Int}()
for i in 0:N
d = digits(i)
dlen = length(unique(d))
for j in 1:length(d), c in Iterators.filter(x -> length(unique(x)) == dlen, Combinatorics.with_replacement_combinations(d, j))
for p in permutations(c)
if evalpoly(16, p) == i && !(i in found)
push!(found, i)
print(rpad(i, 6), " == 0x", rpad(evalpoly(10, p), 8), length(found) % 5 == 0 ? "\n" : "")
break
end
end
end
end
end
dheq(100000)
</lang>{{out}}
<pre>
0 == 0x0 1 == 0x1 2
5 == 0x5 6 == 0x6 7 == 0x7 8 == 0x8 9 == 0x9
53 == 0x35 371 == 0x173 913 == 0x391 1040 == 0x410 1041 == 0x411
1042 == 0x412 1043 == 0x413 1044 == 0x414 1045 == 0x415 1046 == 0x416
1047 == 0x417 1048 == 0x418 1049 == 0x419 2080 == 0x820 2081 == 0x821
2082 == 0x822 2083 == 0x823 2084 == 0x824 2085 == 0x825 2086 == 0x826
2087 == 0x827 2088 == 0x828 2089 == 0x829 2339 == 0x923 4100 == 0x1004
5141 == 0x1415 5412 == 0x1524 5441 == 0x1541 6182 == 0x1826 8200 == 0x2008
9241 == 0x2419 13080 == 0x3318 13593 == 0x3519 13665 == 0x3561 13969 == 0x3691
16406 == 0x4016 20530 == 0x5032 21025 == 0x5221 26930 == 0x6932 26946 == 0x6942
30979 == 0x7903 32803 == 0x8023 33638 == 0x8366 33840 == 0x8430 33841 == 0x8431
33842 == 0x8432 33843 == 0x8433 33844 == 0x8434 33845 == 0x8435 33846 == 0x8436
33847 == 0x8437 33848 == 0x8438 33849 == 0x8439 34883 == 0x8843 37943 == 0x9437
38931 == 0x9813 38966 == 0x9836 38995 == 0x9853 39203 == 0x9923 66310 == 0x10306
71444 == 0x11714 71497 == 0x11749 71511 == 0x11757 75120 == 0x12570 75121 == 0x12571
75122 == 0x12572 75123 == 0x12573 75124 == 0x12574 75125 == 0x12575 75126 == 0x12576
75127 == 0x12577 75128 == 0x12578 75129 == 0x12579 75621 == 0x12765 86150 == 0x15086
88165 == 0x15865 91465 == 0x16549 91769 == 0x16679 96617 == 0x17969 98711 == 0x18197
99481 == 0x18499
</pre>
|