boiler wrote: ↑05 Apr 2020, 20:45
This generates the two matched shuffled lists, which I understand to be file names, so then you can read the text in from the files per the defined order of file names.
Code: Select all
Text1 =
(
T1 House
T1 Vehicle
T1 Ball
T1 Pencil
)
Text2 =
(
T2 Red
T2 Car
T2 Big
T2 Blunt
)
Text3 =
(
T3 Tree
T3 Cloth
T3 Table
T3 Book
)
Text4 =
(
T4 Tall
T4 Clean
T4 Short
T4 Old
)
AText := Text1 "`n" Text2
BText := Text3 "`n" Text4
A := StrSplit(AText, "`n", "`r")
B := StrSplit(BText, "`n", "`r")
Order := Merge(A.MaxIndex())
loop, % Order.MaxIndex()
List1 .= A[Order[A_Index]] "`n"
loop, % Order.MaxIndex()
List2 .= B[Order[A_Index]] "`n"
MsgBox, % List1 "`n`n" List2
return
Merge(n) {
n /= 2
c1 := 0
c2 := 0
o := []
loop {
Random, r, 1, 2
o.Push(r = 1 ? ++c1 : ++c2 + n)
} until (c1 = n) || (c2 = n)
loop, % n - c1
o.Push(++c1)
loop, % n - c2
o.Push(++c2 + n)
return o
}
Thanks boiler, but it doesn't seem to work as expected. On first run my merged lists seem to be okay, just that an empty line preceded each list. On subsequent execution, the MsgBox kept being appended with inconsistent subsequent results. Sometimes there is/are more lines in between list.
I did a bit of modification as a preferred both input (which could contain more that four lines) and output files to read and written to, respectively
Code: Select all
q::
FileRead, Text1, C:\Users\Text1.txt
FileRead, Text2, C:\Users\Text2.txt
FileRead, Text3, C:\Users\Text3.txt
FileRead, Text4, C:\Users\Text4.txt
AText := Text1 "`n" Text2
BText := Text3 "`n" Text4
A := StrSplit(AText, "`n", "`r")
B := StrSplit(BText, "`n", "`r")
Order := Merge(A.MaxIndex())
loop, % Order.MaxIndex()
List1 .= A[Order[A_Index]] "`n"
loop, % Order.MaxIndex()
List2 .= B[Order[A_Index]] "`n"
FileDelete, C:\Users\ADDAI\Desktop\Aascndn\L1.txt
FileDelete, C:\Users\ADDAI\Desktop\Aascndn\L2.txt
FileAppend, %List1%, C:\Users\L1.txt
FileAppend, %List2%, C:\Users\L2.txt
return
Merge(n) {
n /= 2
c1 := 0
c2 := 0
o := []
loop {
Random, r, 1, 2
o.Push(r = 1 ? ++c1 : ++c2 + n)
} until (c1 = n) || (c2 = n)
loop, % n - c1
o.Push(++c1)
loop, % n - c2
o.Push(++c2 + n)
return o
}
Same problem. Any ideas?