My solutions to problems at projecteuler.net solved with javascript.
Some solutions are slow. That's why I've added a timer function to make it easier to find which solutions I can optimize at a later time.
-
Add the number of the problem to the
problem
array insolvedProblems.js
const problems = [1, 2, 3, 4, 5];
-
Create a new module in
src/js/web-worker/problems/
and name itproblem5.js
if it's the fifth problem. -
It has to contain a
function
thatonly returns a number
and are named the same as the file name. -
Functions for the problems don't need to be exported. If you want to import helper functions use:
importScript("../web-worker/utils/[module].js");
This is because the code is executed by Web Workers to not block the main thread when dealing with a slow implmentation of a solution to a problem. This makes it possible to calculate multiple solutions simultaneously.
Use serve to view the project in the browser.
npm install -g serve
serve