{"ScriptPreparationCode":"function shuffle(a) {\r\n var j, x, i;\r\n for (i = a.length; i; i--) {\r\n j = Math.floor(Math.random() * i);\r\n x = a[i - 1];\r\n a[i - 1] = a[j];\r\n a[j] = x;\r\n }\r\n}\r\nvar similar = {\r\n \tall: [],\r\n\tids: [],\r\n\tallLength: 1000,\r\n\tidsLength: 800\r\n};\r\n\r\nfor(var i = 0; i \u003C similar.allLength; i\u002B\u002B) {\r\n similar.all[i] = {id: i, value: \u0027value\u0027 \u002B i };\r\n}\r\n\r\nfor(var i = 0; i \u003C similar.allLength; i\u002B\u002B) {\r\n similar.ids[i] = i;\r\n}\r\nsimilar.ids = similar.ids.splice(similar.allLength - similar.idsLength)\r\nshuffle(similar.all);\r\nshuffle(similar.ids);\r\n\r\nvar distant = {\r\n \tall: [],\r\n\tids: [],\r\n\tallLength: 1000,\r\n\tidsLength: 200\r\n};\r\n\r\nfor(var i = 0; i \u003C distant.allLength; i\u002B\u002B) {\r\n distant.all[i] = {id: i, value: \u0027value\u0027 \u002B i };\r\n}\r\n\r\nfor(var i = 0; i \u003C distant.allLength; i\u002B\u002B) {\r\n distant.ids[i] = i;\r\n}\r\ndistant.ids = distant.ids.splice(distant.allLength - distant.idsLength)\r\nshuffle(distant.all);\r\nshuffle(distant.ids);","TestCases":[{"Name":"800/1000 - map \u002B find iterate on ids","Code":"var output = _.map(similar.ids, function(id) {\r\n var i = _.findIndex(similar.all, { id: id });\r\n return similar.all[i];\r\n});","IsDeferred":false},{"Name":"800/1000 - reduce \u002B includes iterate on all","Code":"var output = _.reduce(similar.all, function(acc, element) {\r\n if(similar.ids.indexOf(element.id) !== -1) {\r\n acc.push(element);\r\n }\r\n return acc;\r\n}, []);","IsDeferred":false},{"Name":"800/1000 - filter \u002B includes iterate on all","Code":"var output = _.filter(similar.all, function(element) {\r\n return similar.ids.indexOf(element.id) !== -1;\r\n});","IsDeferred":false},{"Name":"200/1000 - map \u002B find iterate on ids","Code":"var output = _.map(distant.ids, function(id) {\r\n var i = _.findIndex(distant.all, { id: id });\r\n return distant.all[i];\r\n});","IsDeferred":false},{"Name":"200/1000 - reduce \u002B includes iterate on all","Code":"var output = _.reduce(distant.all, function(acc, element) {\r\n if(distant.ids.indexOf(element.id) !== -1) {\r\n acc.push(element);\r\n }\r\n return acc;\r\n}, []);","IsDeferred":false},{"Name":"200/1000 - filter \u002B includes iterate on all","Code":"var output = _.filter(distant.all, function(element) {\r\n return distant.ids.indexOf(element.id) !== -1;\r\n});","IsDeferred":false}]}