A Distributed solution to /r/dailyprogrammer Challenge #223
A little while ago, I wrote my first distributed computing program to solve the second optional challenge to /r/dailyprogrammer's #223rd problem. I wrote it in Javascript, because I know really know how to utilise the tcp/ip networking stack in any other language yet :(
Anyway, if you want to check out my source code, I have put it up on GitHub. Below I will explain how you can get started with the pair for scripts I wrote, and how they work
Getting Started
Getting started is easy. Just clone the repository & cd
into the new directory:
git clone https://github.com/sbrl/dailyprogrammer-223.git
cd dailyprogrammer-223
Then install the dependency:
npm install
Then you can start a server like so:
node server.js 4321 # starts a new server on port 4321
Or you can start a client like this:
node client.js starbeamrainbowlabs.com:9999
Note that I have used some ES6 features (check out my ES6: Features series), so if you are using Node.js and not io.js, you will need to tack on the --harmony
flag in order to get them to work.
It works by mapping the search space (aaaaa
to zzzzz
) to a set of numbers, starting at 0. I used an ES6 generator to keep track of where we have got up to, wrapped in a function that handles reallocating work units that haven't been completed within a certain time limit. Each work unit consist of 16 words by default (though it can be changed), with the time limit set to 5 times the number of words in the block.
Next time, I will write the client so that it is compatible with a conventional browser - this should make it much easier for people to contribute their CPU time!