Numbers with same digit set in base 10 and base 16: Difference between revisions

m
(→‎{{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)
dheq(N) = [i for i in 0:N for p in permutations(digits(i)) if evalpoly(16, p) == i]
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)
foreach(p -> print(rpad(p[2], 6), p[1] % 10 == 0 ? "\n" : ""), enumerate(dheq(100000)))
</lang>{{out}}
<pre>
0 == 0x0 1 == 0x1 2 3 == 0x2 4 3 5 6== 0x3 7 4 8 == 0x4 9
5 == 0x5 6 == 0x6 7 == 0x7 8 == 0x8 9 == 0x9
53 371 913 1040 1040 1041 1041 1042 1043 1044
53 == 0x35 371 == 0x173 913 == 0x391 1040 == 0x410 1041 == 0x411
1044 1045 1046 1047 1048 1049 2080 2080 2081 2082
1042 == 0x412 1043 == 0x413 1044 == 0x414 1045 == 0x415 1046 == 0x416
2082 2083 2084 2085 2086 2087 2088 2088 2089 4100
1047 == 0x417 1048 == 0x418 1049 == 0x419 2080 == 0x820 2081 == 0x821
4100 5141 5141 5412 6182 8200 8200 9241 20530 20530
2082 == 0x822 2083 == 0x823 2084 == 0x824 2085 == 0x825 2086 == 0x826
21025 21025 26930 75120 75121 75121 75122 75122 75123 75124
2087 == 0x827 2088 == 0x828 2089 == 0x829 2339 == 0x923 4100 == 0x1004
75125 75125 75126 75127 75127 75128 75129 75621 86150 91465
5141 == 0x1415 5412 == 0x1524 5441 == 0x1541 6182 == 0x1826 8200 == 0x2008
98711 98711 99481 99481
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>
 
4,105

edits