Node-js solution for magnetic contest