{"ScriptPreparationCode":"function CompletedCourses() {\r\n \r\n\r\n this.init = function() {\r\n this._state = new Array(COURSES.length).fill(false);\r\n }\r\n\r\n this.completeCourse = function(index) {\r\n this._state[index] = true;\r\n }\r\n\r\n\r\n this.getCompletedCourses = function() {\r\n const completedCourses = COURSES.filter((course, index) =\u003E this._state[index]);\r\n return completedCourses;\r\n }\t\r\n this.init();\r\n \treturn this;\r\n}\r\n\r\nfunction CompletedCoursesBits() {\r\n \r\n\t\r\n \r\n this.initBits = function() {\r\n // using bits\r\n this._status = 0;\r\n }\r\n\r\n this.completeCourseBit = function(index) {\r\n this._status = this._status | 1 \u003C\u003C index;\r\n }\r\n\r\n this.getCompletedCoursesByBits = function() {\r\n const completedCourseWithBits = COURSES.filter((course, index) =\u003E (this._status \u0026 1 \u003C\u003C index));\r\n return completedCourseWithBits;\r\n }\r\n this.initBits();\r\n return this;\r\n}\r\n\r\nfunction Student(name, completedCourses) {\r\n this.name = name;\r\n this.courses = completedCourses;\r\n}\r\n\r\nvar COURSES = [\r\n \u0027English\u0027,\r\n \u0027Chemistry\u0027,\r\n \u0027Physics\u0027,\r\n \u0027Literature\u0027,\r\n \u0027Arts\u0027,\r\n \u0027Algabra\u0027,\r\n \u0027Infi\u0027,\r\n \u0027Algorithms\u0027,\r\n \u0027DataStructures\u0027,\r\n \u0027Complexity\u0027\r\n];\r\n\r\nvar n = 10000;","TestCases":[{"Name":"Bitwise","Code":"function startBits() {\r\n // create\r\n const students = [];\r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n students.push(new Student(\u0027Mike\u0027, new CompletedCoursesBits()));\r\n }\r\n \r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n const student = students[i];\r\n COURSES.forEach((course, index) =\u003E index \u0026 1 ? student.courses.completeCourseBit(index) : \u0027\u0027)\r\n }\r\n \r\n // log\r\n const list = [];\r\n \r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n const student = students[i];\r\n list.push(student.courses.getCompletedCoursesByBits());\r\n }\r\n}\r\nstartBits();","IsDeferred":false},{"Name":"Boolean","Code":"function start(){\r\n // create\r\n const students = [];\r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n students.push(new Student(\u0027Mike\u0027, new CompletedCourses()));\r\n }\r\n \r\n // populate\r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n const student = students[i];\r\n COURSES.forEach((course, index) =\u003E index \u0026 1 ? student.courses.completeCourse(index) : \u0027\u0027)\r\n }\r\n \r\n // log\r\n const list = [];\r\n for (let i = 0; i \u003C n; i\u002B\u002B) {\r\n const student = students[i];\r\n list.push(student.courses.getCompletedCourses());\r\n }\r\n}\r\nstart();","IsDeferred":false}]}