Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Executable-library/AutoHotkey/executable-library-1.ahk
Normal file
28
Task/Executable-library/AutoHotkey/executable-library-1.ahk
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#NoEnv
|
||||
SetBatchLines, -1
|
||||
|
||||
; Check if we're executed directly:
|
||||
If (A_LineFile = A_ScriptFullPath){
|
||||
h27 := hailstone(27)
|
||||
MsgBox % "Length of hailstone 27: " (m := h27.MaxIndex()) "`nStarts with "
|
||||
. h27[1] ", " h27[2] ", " h27[3] ", " h27[4]
|
||||
. "`nEnds with "
|
||||
. h27[m-3] ", " h27[m-2] ", " h27[m-1] ", " h27[m]
|
||||
|
||||
Loop 100000
|
||||
{
|
||||
h := hailstone(A_Index)
|
||||
If (h.MaxIndex() > m)
|
||||
m := h.MaxIndex(), longest := A_Index
|
||||
}
|
||||
MsgBox % "Longest hailstone is that of " longest " with a length of " m "!"
|
||||
}
|
||||
|
||||
|
||||
hailstone(n){
|
||||
out := [n]
|
||||
Loop
|
||||
n := n & 1 ? n*3+1 : n//2, out.insert(n)
|
||||
until n=1
|
||||
return out
|
||||
}
|
||||
17
Task/Executable-library/AutoHotkey/executable-library-2.ahk
Normal file
17
Task/Executable-library/AutoHotkey/executable-library-2.ahk
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#NoEnv
|
||||
#Include %A_ScriptDir%\hailstone.ahk
|
||||
SetBatchLines -1
|
||||
|
||||
col := Object(), highestCount := 0
|
||||
|
||||
Loop 100000
|
||||
{
|
||||
length := hailstone(A_Index).MaxIndex()
|
||||
if not col[length]
|
||||
col[length] := 0
|
||||
col[length]++
|
||||
}
|
||||
for length, count in col
|
||||
if (count > highestCount)
|
||||
highestCount := count, highestN := length
|
||||
MsgBox % "the most common length was " highestN "; it occurred " highestCount " times."
|
||||
Loading…
Add table
Add a link
Reference in a new issue