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 16:39, 19 June 2021
, 2 years ago→{{header|Raku}}: DRY. Factor out common code
Thundergnat (talk | contribs) m (→{{header|Raku}}: typo) |
Thundergnat (talk | contribs) (→{{header|Raku}}: DRY. Factor out common code) |
||
Line 688:
are composed of the same digit glyphs. (All the same glyphs, all the same
quantity.)\n";
display-numbers calculated-with &infix:<eqv>, <Bag>;
say .elems ~ " found:\n" ~ .batch(20)».fmt('%5d').join("\n") given▼
(^18699).map( {:16(.Str)} ).hyper(:1000batch).grep( { [eqv] (.fmt('%x'), $_).map( *.comb.Bag ) } ).cache;▼
say "\nNumbers up to 100,000 which when expressed in hexadecimal and in decimal
are composed from the same digit glyphs. (All the same glyphs are present,
possibly different quantity.)\n";
display-numbers calculated-with &infix:<eqv>, <Set>;
say "\nNumbers up to 100,000 which, when expressed in hexadecimal use glyphs
that are a subset of those used when expressed in decimal. (Every glyph in
decimal is present in hexadecimal the same or fewer (possibly zero) times)\n";
display-numbers calculated-with &infix:<⊆>, <Bag>;
say "\nNumbers up to 100,000 which, when expressed in hexadecimal use glyphs
Line 710 ⟶ 704:
decimal is present in hexadecimal in some quantity, possibly zero, possibly more
than in decimal)\n";
display-numbers calculated-with &infix:<⊆>, <Set>;
sub calculated-with ( &op, $container ) {
▲
reduce( &op, (.fmt('%x'), $_).map: { .comb."$container"() } )
} )
}</lang>
{{out}}
<pre>Numbers which when expressed in hexadecimal and in decimal are composed of
|