Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Executable-library/NetRexx/executable-library.netrexx
Normal file
35
Task/Executable-library/NetRexx/executable-library.netrexx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
import RHailstoneSequence
|
||||
|
||||
runSample(arg)
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method runSample(arg) private static
|
||||
parse arg beginNum endNum .
|
||||
if beginNum = '' | beginNum = '.' then beginNum = 1
|
||||
if endNum = '' | endNum = '.' then endNum = 100000
|
||||
if beginNum > endNum then signal IllegalArgumentException('Gronk!')
|
||||
|
||||
-- collect sequences
|
||||
hailstones = 0
|
||||
loop hn = beginNum while hn < endNum
|
||||
hslist = RHailstoneSequence.hailstone(hn)
|
||||
hscount = hslist.words()
|
||||
hailstones[hscount] = hailstones[hscount] + 1
|
||||
end hn
|
||||
|
||||
-- locate most common
|
||||
mostOftenNum = 0
|
||||
mostOftenCount = 0
|
||||
loop hn = beginNum while hn < endNum
|
||||
if hailstones[hn] > mostOftenCount then do
|
||||
mostOftenCount = hailstones[hn]
|
||||
mostOftenNum = hn
|
||||
end
|
||||
end hn
|
||||
|
||||
say 'The length of hailstone sequence that is most common in the range' beginNum '<= N <' endNum 'is' mostOftenNum'. It occurs' mostOftenCount 'times.'
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue