Code: Select all
var =
(
1
5
9
1
2
3
4
6
)
in my example should i get 7 and 8
smallest is 7
largest is 8
Code: Select all
var =
(
1
5
9
1
2
3
4
6
)
Code: Select all
list =
(
1
5
9
1
2
3
4
6
)
arr := StrSplit(list, "`n"), arr2 := [], low := low(arr)
Loop, % high(arr) - low - 1
n := low + A_Index, (!Instr("`n" list "`n", "`n" n "`n")) && arr2.Push(n)
min := low(arr2), max := high(arr2)
MsgBox, 64, Result, Largest = %max%`n`nSmallest = %min%
high(arr) {
For each, num in arr
n := n > "" ? Max(n, num) : num
Return n
}
low(arr) {
For each, num in arr
n := n > "" ? Min(n, num) : num
Return n
}
Code: Select all
var =
(
1
5
9
1
2
3
4
6
)
Sort, var, N U
RegExMatch(var, "^(\d+).*?(\d+)$", M)
Loop,% M2-M1-1
IF !Instr(Var, "`n" N := A_Index+M1 "`n")
Out .= N
MsgBox,% Out
H̶i̶ ̶R̶o̶h̶w̶e̶d̶d̶e̶r̶,̶ ̶S̶o̶r̶r̶y̶ ̶f̶o̶r̶ ̶t̶h̶e̶ ̶i̶n̶c̶o̶n̶v̶e̶n̶i̶e̶n̶c̶e̶,̶Rohwedder wrote: ↑28 Nov 2022, 11:43Hallo,
try:Code: Select all
var = ( 1 5 9 1 2 3 4 6 ) Sort, var, N U RegExMatch(var, "^(\d+).*?(\d+)$", M) Loop,% M2-M1-1 IF !Instr(Var, "`n" N := A_Index+M1 "`n") Out .= N MsgBox,% Out
Code: Select all
A := new biga() ; requires https://github.com/biga-ahk/biga.ahk
var =
(
1
5
9
1
2
0
3
4
6
)
arr := strSplit(var, "`n", "`r")
gaps := A.difference(A.range(A.min(arr), A.max(arr)), arr)
; => [7, 8]