/drunken-computing-machine

this sounds like an interesting name for an application

Primary LanguageJavaScriptMIT LicenseMIT

drunken-computing-machine

This repo name was generated by github and sounded like an interesting name for an application, so I created the repo.

These scripts will scramble a word input and hide the word in a long string of characters. There is also an unscramble script that will find the word in the field of scrambled letters.

scramble.js

**To unscramble: run **

node scramble yourword

yourword cannot have duplicate letters (e.g. beaver, javascript, giraffe)

The script should output a yourword.txt file in the directory where you ran the script. This text file will contain the scrambled field string that contains your word.

unscramble.js

**To unscramble: run **

node unscramble

This will unscramble the default field, that is defined in the script and log the result to the console.

If you want to override the default scrambled character string, use the following call:

node unscramble ./path/to/file.txt

NOTE: If using a .txt file, the contents of the file should ONLY be the field of characters you want to unscramble.

###How does the unscramble work?

The unscramble will:

Sort the characters in the following string:

abcdefghijklmnopqrstuvwxyz_

by the number of times the character appears in the scrambled character field. See the example in unscramble.js, where I set the var charField.

Now take the sorted string, and drop all the characters after (and including) the _. The remaining word is the answer.


[comment]: <>(http://www.joelonsoftware.com/articles/fog0000000038.html)

[comment]: <>(http://www.fogcreek.com/Jobs/SupportEngineer/)