Maximum difference between adjacent elements of list: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
Alpha bravo (talk | contribs) (Added AutoHotkey) |
||
Line 295: | Line 295: | ||
7 2 9 |
7 2 9 |
||
7 10 3</pre> |
7 10 3</pre> |
||
=={{header|AutoHotkey}}== |
|||
<lang AutoHotkey>List := [1,8,2,-3,0,1,1,-2.3,0,5.5,8,6,2,9,11,10,3] |
|||
mxDiff := [] |
|||
loop % List.Count() -1 |
|||
mxDiff[d := Abs(list[A_Index+1] - list[A_Index])] .= list[A_Index] ", " list[A_Index+1] " ==> " d "`n" |
|||
MsgBox % result := Trim(mxDiff[mxDiff.MaxIndex()], "`n")</lang> |
|||
{{out}} |
|||
<pre>1, 8 ==> 7 |
|||
2, 9 ==> 7 |
|||
10, 3 ==> 7</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |