Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
UpDia_sum := 0
downdia_sum := 0
UpDia := 1
downDia := 1
col := 0
array =
(
1 2 1
3 4 2
3 4 6
)
_array := []
for k, v in StrSplit(array, "`n")
for M, q in StrSplit(v, " ")
_array[k, M] := q
StringSplit, rows, array, `n
loop % rows0
Col := col + 1
if ( col != rows0 )
{
MsgBox wrong Input
ExitApp
}
;MsgBox col is %col% and row is %rows0%
;;;adding more lines;;;;;;;;
a := 1
b := 1
R := 1
C := Col + 1
loop % rows0
{
loop % col - 1
{
_array[R, C] := _array[a, b]
;MsgBox %R% and %c% so far generated
; MsgBox % _array[R, C]
b := b + 1
c := C+1
}
R := R + 1
a := a + 1
b := 1
C := Col + 1
}
;;;;;;;;;;;; duplicate lines generated for arrays;;;;;;;;;;;;;;;;;
K := 1
M := 1
MM := 1
loop %col%
{
;MsgBox initial array for %k% and %m% and %a_index%
M := A_index
Loop
{
;MsgBox M is %M%
if ( _array[K, M] != "" )
{
; MsgBox we are at %k% and %m%
UpDia := Updia * _array[K, M]
; MsgBox % _array[K, M]
;MsgBox %updia% is the result so far
K := K + 1, M := M + 1
}
else
{
;MsgBox %updia% %k% is k and %m% m
Updia_Sum := Updia_sum + updia
K := 1, updia := 1
goto, label
}
}
label:
}
;MsgBox %updia_sum% is the sum of up diagonals ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;down diagonal sum to be calculated now;;;;;;;;;;;;;;;;;
K := col
M := 1
loop %col%
{
; MsgBox %A_index%
;MsgBox initial array for %k% and %m% and %a_index%
M := A_index
Loop
{
;MsgBox M is %M%
if ( _array[K, M] != "" )
{
; MsgBox we are at %k% and %m%
downDia := downdia * _array[K, M]
; MsgBox % _array[K, M]
;MsgBox %downdia% is the result so far
K := K - 1, M := M + 1
}
else
{
;MsgBox %downdia% %k% is k and %m% m
downdia_Sum := downdia_sum + downdia
K := col, downdia := 1
goto, label2
}
}
label2:
}
;MsgBox %downdia_sum% is the sum of up down diagonals ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MsgBox % updia_sum - downdia_sum