Numbers in base-16 representation that cannot be written with decimal digits: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
(6 intermediate revisions by 6 users not shown)
Line 124:
250 251 252 253 254 255
</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">nonDecimalNums: select 1..500 'x ->
empty? intersection digits.base:16 x @0..9
 
loop split.every: 7 nonDecimalNums 'x ->
print map x 's -> pad to :string s 4</syntaxhighlight>
 
{{out}}
 
<pre> 10 11 12 13 14 15 170
171 172 173 174 175 186 187
188 189 190 191 202 203 204
205 206 207 218 219 220 221
222 223 234 235 236 237 238
239 250 251 252 253 254 255</pre>
 
=={{header|AWK}}==
Line 349 ⟶ 366:
254
255</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">∾⟜(16⊸×⊸+⌜˜) 10+↕6</syntaxhighlight>
{{out}}
<pre>┌─
╵ 10 11 12 13 14 15
170 171 172 173 174 175
186 187 188 189 190 191
202 203 204 205 206 207
218 219 220 221 222 223
234 235 236 237 238 239
250 251 252 253 254 255
┘</pre>
 
=={{header|C}}==
Line 371 ⟶ 401:
10 11 12 13 14 15 26 27 28 29 30 31 42 43 44 45 46 47 58 59 60 61 62 63 74 75 76 77 78 79 90 91 92 93 94 95 106 107 108 109 110 111 122 123 124 125 126 127 138 139 140 141 142 143 154 155 156 157 158 159 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255
</pre>
 
=={{header|C++}}==
<syntaxhighlight lang="cpp">
Line 643 ⟶ 674:
254
255</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
 
function HasNoBase10(N: integer): boolean;
{Test N for decimal digits in hex string}
var I: integer;
var S: string;
begin
Result:=False;
S:=Format('%x',[N]);
for I:=1 to Length(S) do
if S[I] in ['0'..'9'] then exit;
Result:=True;
end;
 
 
 
procedure ShowNoBase10inHex(Memo: TMemo);
var I,Cnt: integer;
var S: string;
begin
Cnt:=0;
for I:=0 to 500-1 do
if HasNoBase10(I) then
begin
Inc(Cnt);
S:=S+Format('%8D',[I]);
If (Cnt mod 5)=0 then S:=S+#$0D#$0A;
end;
Memo.Lines.Add('Count='+IntToStr(Cnt));
Memo.Lines.Add(S);
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
Count=42
10 11 12 13 14
15 170 171 172 173
174 175 186 187 188
189 190 191 202 203
204 205 206 207 218
219 220 221 222 223
234 235 236 237 238
239 250 251 252 253
254 255
</pre>
 
 
=={{header|F_Sharp|F#}}==
Line 775 ⟶ 860:
;:inv hfd each I.(9 */ .< 16 #.inv ])"0 i.500
a b c d e f aa ab ac ad ae af ba bb bc bd be bf ca cb cc cd ce cf da db dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
'''Also works with gojq, the Go implementation of jq, and with fq'''
<syntaxhighlight lang=jq>
def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def hex_stream:
recurse(if . >= 16 then ./16|floor else empty end) | . % 16 ;
 
# Emit a stream of the decimal integers in range(1; $upper+1) satisfying the condition
def no_hex_digits($upper):
range(1; $upper)
| select( all(hex_stream; . > 9) );
 
[no_hex_digits(500)]
| (_nwise(14) | map(lpad(3)) | join(" ")),
"\n\(length) such numbers found."
</syntaxhighlight>
{{output}}
<pre>
10 11 12 13 14 15 170 171 172 173 174 175 186 187
188 189 190 191 202 203 204 205 206 207 218 219 220 221
222 223 234 235 236 237 238 239 250 251 252 253 254 255
 
42 such numbers found.
</pre>
 
=={{header|Julia}}==
Line 1,175 ⟶ 1,287:
Found 42 numbers
done...
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
≪ { 0 10 11 12 13 14 15 } → abc
≪ { }
1 7 '''FOR''' a 1 7 '''FOR''' b 2 7 '''FOR''' c
abc a GET 256 * abc b GET 16 * + abc c GET +
'''IF''' DUP 500 ≤ '''THEN''' + '''ELSE''' DROP '''END'''
'''NEXT NEXT NEXT'''
≫ ≫ ''''TASK'''' STO
{{out}}
<pre>
1: { 10 11 12 13 14 15 170 171 172 173 174 175 186 187 188 189 190 191 202 203 204 205 206 207 218 219 220 221 222 223 234 235 236 237 238 239 250 251 252 253 254 255 }
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">p (0..500).select{|n| n.digits(16).all?{|d| d > 9} }</syntaxhighlight>
{{out}}
<pre>
[10, 11, 12, 13, 14, 15, 170, 171, 172, 173, 174, 175, 186, 187, 188, 189, 190, 191, 202, 203, 204, 205, 206, 207, 218, 219, 220, 221, 222, 223, 234, 235, 236, 237, 238, 239, 250, 251, 252, 253, 254, 255]
</pre>
 
Line 1,220 ⟶ 1,353:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
var decimal = "0123456789"
9,485

edits