Bootcamp
Searchโฆ
Pairing Assignments
Batch 1 (Oct 2020 - Apr 2021)

# FTBC4 (Jul-Dec 2021)

1
Chuan Xin, Shen Nan
Jia En, Justin\
โ
2
Shen Nan, Justin
Jia En, Chuan Xin\
โ
3
Chuan Xin, Justin
Shen Nan, Jia En

## Formation Calculation Code

Formation ID is determined by `(((weekNum - 1) * 5 + dayOfWeekNum) % 3) + 1`. `weekNum` is the week number of the course, i.e. 1-24. `dayOfWeekNum` is the day number corresponding to the day of week, i.e. 1-5.
1
/* Based on: https://gist.github.com/dblock/1081513
2
* For a given date, get the ISO week number
3
*
4
* Based on information at:
5
*
6
* http://www.merlyn.demon.co.uk/weekcalc.htm#WNR
7
*
8
* Algorithm is to find nearest thursday, it's year
9
* is the year of the week number. Then get weeks
10
* between that date and the first day of that year.
11
*
12
* Note that dates in one year can be weeks of previous
13
* or next year, overlap is up to 3 days.
14
*
15
* e.g. 2014/12/29 is Monday in week 1 of 2015
16
* 2012/1/1 is Sunday in week 52 of 2011
17
*/
18
function getWeekNumber(d) {
19
// Copy date so don't modify original
20
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
21
// Set to nearest Thursday: current date + 4 - current day number
22
// Make Sunday's day number 7
23
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
24
// Get first day of year
25
var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
26
// Calculate full weeks to nearest Thursday
27
var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
28
// Return array of year and week number
29
return weekNo;
30
}
31
โ
32
var formationCount = 3;
33
โ
34
var daysInAWeek = 5;
35
โ
36
var ordinalDayOfWeek = new Date().getDay() + 1; // day of week - 1-7
37
โ
38
var weekNum = getWeekNumber(new Date());
39
โ
40
var formationNumber = ((weekNum * daysInAWeek + ordinalDayOfWeek) % formationCount) + 1;
41
โ
42
console.log( formationNumber );
Copied!

# FTBC5

## Section 1 (Michelle)

Ben, Bryan, David, FrankieT, HP, Joseph, Shannon

## Section 2 (Foong)

BW, FrankieN, Dom, Gary, JH, Justus, Tristan

# PTBC1

1
Zack, CK
Diyana Ramlan, Zaver
Eric Foo, Kimmi Lee
Graham James Lim, Jia Yi
โ
2
Zack, Zaver
CK, Kimmi Lee
Diyana Ramlan, Jia Yi
Eric Foo, Graham James Lim
โ
3
Zaver, Kimmi Lee
Zack, Jia Yi
CK, Graham James Lim
Diyana Ramlan, Eric Foo
โ
4
Kimmi Lee, Graham James Lim
Zaver, Jia Yi
Zack, Eric Foo
CK, Diyana Ramlan
โ
5
Jia Yi, Diyana Ramlan
Kimmi Lee, Graham James Lim
Zaver, Eric Foo
Zack, CK
โ
6
Graham James Lim, Zack
Jia Yi, Eric Foo
Kimmi Lee, Diyana Ramlan
Zaver, CK
โ
7
Eric Foo, Zaver
Graham James Lim, Diyana Ramlan
Jia Yi, CK
Kimmi Lee, Zack
โ
8
Diyana Ramlan, Jia Yi
Eric Foo, CK
Graham James Lim, Zack
Kimmi Lee, Zaver
โ
9
CK, Eric Foo
Diyana Ramlan, Zack
Graham James Lim, Zaver
Jia Yi, Kimmi Lee

## Formation Calculation Code

Formation ID is determined by `(((weekNum - 1) * 5 + dayOfWeekNum) % 3) + 1`. `weekNum` is the week number of the course, i.e. 1-24. `dayOfWeekNum` is the day number corresponding to the day of week, i.e. 1-5.
1
/* Based on: https://gist.github.com/dblock/1081513
2
* For a given date, get the ISO week number
3
*
4
* Based on information at:
5
*
6
* http://www.merlyn.demon.co.uk/weekcalc.htm#WNR
7
*
8
* Algorithm is to find nearest thursday, it's year
9
* is the year of the week number. Then get weeks
10
* between that date and the first day of that year.
11
*
12
* Note that dates in one year can be weeks of previous
13
* or next year, overlap is up to 3 days.
14
*
15
* e.g. 2014/12/29 is Monday in week 1 of 2015
16
* 2012/1/1 is Sunday in week 52 of 2011
17
*/
18
function getWeekNumber(d) {
19
// Copy date so don't modify original
20
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
21
// Set to nearest Thursday: current date + 4 - current day number
22
// Make Sunday's day number 7
23
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
24
// Get first day of year
25
var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
26
// Calculate full weeks to nearest Thursday
27
var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
28
// Return array of year and week number
29
return weekNo;
30
}
31
โ
32
var formationCount = 8;
33
โ
34
var daysInAWeek = 5;
35
โ
36
var ordinalDayOfWeek = new Date().getDay() + 1; // day of week - 1-7
37
โ
38
var weekNum = getWeekNumber(new Date());
39
โ
40
var formationNumber = ((weekNum * daysInAWeek + ordinalDayOfWeek) % formationCount) + 1;
41
โ
42
console.log( formationNumber );
Copied!

# Pairings

1
const studentNames = ['kai','iak'];
2
โ
3
const DUMMY = -1;
4
// returns an array of round representations (array of player pairs).
5
// http://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm
6
function permutate(n, ps) { // n = num players
7
const rs = []; // rs = round array
8
if (!ps) {
9
ps = [];
10
for (let k = 1; k <= n; k += 1) {
11
ps.push(k);
12
}
13
} else {
14
ps = ps.slice();
15
}
16
if (n % 2 === 1) {
17
ps.push(DUMMY); // so we can match algorithm for even numbers
18
n += 1;
19
}
20
for (let j = 0; j < n - 1; j += 1) {
21
rs[j] = []; // create inner match array for round j
22
for (let i = 0; i < n / 2; i += 1) {
23
const o = n - 1 - i;
24
if (ps[i] !== DUMMY && ps[o] !== DUMMY) {
25
// flip orders to ensure everyone gets roughly n/2 home matches
26
const isHome = i === 0 && j % 2 === 1;
27
// insert pair as a match - [ away, home ]
28
rs[j].push([isHome ? ps[o] : ps[i], isHome ? ps[i] : ps[o]]);
29
}
30
}
31
ps.splice(1, 0, ps.pop()); // permutate for next round
32
}
33
return rs;
34
};
35
โ
36
const pairs = permutate(studentNames.length, studentNames)
37
console.log( pairs )
38
โ
39
pairs.forEach((day, index) => {
40
let groupNum = index+1;
41
console.log(groupNum);
42
day.forEach(set=>console.log(set.join(', ')));
43
console.log(' ');
44
});
Copied!