1count1 = studyPair(Table 1)
2while (Table 1 has more rows) {
3 Read the first row X in Table 1
4 if (X.CityTown == "Chennai") {
5 Move X to Table CHN
6 }
7 if (X.CityTown == "Bengaluru") {
8 Move X to Table BLR
9 }
10 if (X.CityTown == "Vellore") {
11 Move X to Table VLR
12 }
13}
14count2 = studyPair(Table CHN) + studyPair(Table BLR) + studyPair(Table VLR)
15
16Procedure studyPair(Table 1)
17 Table T1 = Table 1
18 A = 0
19 while (Table T1 has more rows) {
20 Read the first row X in Table T1
21 Move X to Table T2
22 while (Table T1 has more rows) {
23 Read the first row Y in Table T1
24 Move Y to Table T3
25 if (-10 ≤ X.Mathematics - Y.Mathematics ≤ 10) {
26 A = A + 1
27 }
28 }
29 Move all rows from Table T3 to Table T1
30 }
31 return(A)
32End studyPair