Largest five adjacent number: Difference between revisions

(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 354:
(example)
<pre>99929</pre>
 
=={{header|jq}}==
<syntaxhighlight lang="bash">
< /dev/random tr -cd '0-9' | head -c 1000 | jq -R '
length as $n
| . as $s
| ($s[0:5] | tonumber) as $m
| reduce range(1; $n - 5) as $i ( {min: $m, max: $m};
($s[$i: $i+5] | tonumber) as $x
| if $x < .min then .min = $x
elif $x > .max then .max = $x
else . end)
'
</syntaxhighlight>
{{output}}
<pre>
{
"min": 224,
"max": 99772
}
</pre>
 
 
=={{header|Julia}}==
Line 376 ⟶ 398:
Maximum is 99999 at position 763.
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">MinMax[FromDigits /@ Partition[RandomInteger[{0, 9}, 1000], 5, 1]]</syntaxhighlight>
2,442

edits