Largest five adjacent number: Difference between revisions

Added Python implementation
(added AWK)
(Added Python implementation)
Line 290:
</pre>
 
=={{header|Python}}==
Seeding the random number generator directly with the datetime stamp produces a warning that it will be deprecated in Python 3.9, hence the "hack" of creating a string out of the timestamp and then seeding with it.
<lang Python>
#Aamrun, 5th October 2021
 
from random import seed,randint
from datetime import datetime
 
seed(str(datetime.now()))
 
largeNum = [randint(1,9)]
 
for i in range(1,1000):
largeNum.append(randint(0,9))
 
maxNum,minNum = 0,99999
 
for i in range(0,994):
num = int("".join(map(str,largeNum[i:i+5])))
if num > maxNum:
maxNum = num
elif num < minNum:
minNum = num
 
print("Largest 5-adjacent number found ", maxNum)
print("Smallest 5-adjacent number found ", minNum)
</lang>
Results from multiple runs :
{{out}}
<pre>
 
 
Largest 5-adjacent number found 99743
Smallest 5-adjacent number found 102
 
 
Largest 5-adjacent number found 99965
Smallest 5-adjacent number found 84
 
 
Largest 5-adjacent number found 99808
Smallest 5-adjacent number found 58
 
 
Largest 5-adjacent number found 99938
Smallest 5-adjacent number found 10
 
 
Largest 5-adjacent number found 99957
Smallest 5-adjacent number found 35
</pre>
=={{header|Raku}}==
Show minimum too because... why not?
503

edits