| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,6 @@ class NQueen { | |||
| 36 | 36 | ||
| 37 | 37 | solve (col = 0) { | |
| 38 | 38 | if (col >= this.size) { | |
| 39 | - this.printBoard() | ||
| 40 | 39 | this.solutionCount++ | |
| 41 | 40 | return true | |
| 42 | 41 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,5 +13,4 @@ function BinaryCountSetBits (a) { | |||
| 13 | 13 | return a.toString(2).split('1').length - 1 | |
| 14 | 14 | } | |
| 15 | 15 | ||
| 16 | - // Run `binary_and` Function to find the binary and operation | ||
| 17 | - console.log(BinaryCountSetBits(251)) | ||
| 16 | + export { BinaryCountSetBits } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,8 @@ function Atbash (message) { | |||
| 23 | 23 | } | |
| 24 | 24 | return decodedString | |
| 25 | 25 | } | |
| 26 | - // Atbash Example | ||
| 27 | - const encryptedString = 'HELLO WORLD' | ||
| 28 | - const decryptedString = Atbash(encryptedString) | ||
| 29 | - console.log(decryptedString) // SVOOL DLIOW | ||
| 26 | + | ||
| 27 | + export { Atbash } | ||
| 28 | + | ||
| 29 | + // > Atbash('HELLO WORLD') | ||
| 30 | + // 'SVOOL DLIOW' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,8 +29,7 @@ function rot13 (str) { | |||
| 29 | 29 | return response.join('') | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | - // Caesars Cipher Example | ||
| 33 | - const encryptedString = 'Uryyb Jbeyq' | ||
| 34 | - const decryptedString = rot13(encryptedString) | ||
| 32 | + export { rot13 } | ||
| 35 | 33 | ||
| 36 | - console.log(decryptedString) // Hello World | ||
| 34 | + // > rot13('Uryyb Jbeyq') | ||
| 35 | + // 'Hello World' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,15 +44,11 @@ function keyFinder (str) { // str is used to get the input of encrypted string | |||
| 44 | 44 | for (let w = 0; w < wordBank[i].length; w++) { | |
| 45 | 45 | outStrElement += outStr[s + w] | |
| 46 | 46 | } | |
| 47 | - | ||
| 48 | - // console.log( k + outStrElement + wordBank[i] );//debug | ||
| 49 | - | ||
| 50 | 47 | // this part need to be optimize with the calculation of the number of occurrence of word's probabilities | |
| 51 | 48 | // linked list will be used in the next stage of development to calculate the number of occurrence of the key | |
| 52 | 49 | if (wordBank[i] === outStrElement) { | |
| 53 | 50 | return k // return the key number if founded | |
| 54 | 51 | } | |
| 55 | - | ||
| 56 | 52 | outStrElement = '' // reset the temp word | |
| 57 | 53 | } // end for ( let i=0; i < wordBank.length; i++) | |
| 58 | 54 | } | |
@@ -145,4 +141,7 @@ function caesarCipherEncodeAndDecodeEngine (inStr, numShifted) { | |||
| 145 | 141 | return outStr | |
| 146 | 142 | } | |
| 147 | 143 | ||
| 148 | - console.log('Testing: ' + keyFinder('test')) // returns 0 | ||
| 144 | + export { keyFinder } | ||
| 145 | + | ||
| 146 | + // > keyFinder('test') | ||
| 147 | + // 0 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,19 +3,15 @@ | |||
| 3 | 3 | * @param {String} text - string to be encrypted | |
| 4 | 4 | * @return {String} - decrypted string | |
| 5 | 5 | */ | |
| 6 | - const transcipher = (text) => { | ||
| 6 | + const ROT13 = (text) => { | ||
| 7 | 7 | const originalCharacterList = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | |
| 8 | 8 | const toBeMappedCharaterList = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm' | |
| 9 | 9 | const index = x => originalCharacterList.indexOf(x) | |
| 10 | 10 | const replace = x => index(x) > -1 ? toBeMappedCharaterList[index(x)] : x | |
| 11 | 11 | return text.split('').map(replace).join('') | |
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | - (() => { | ||
| 15 | - const messageToBeEncrypted = 'The quick brown fox jumps over the lazy dog' | ||
| 16 | - console.log(`Original Text = "${messageToBeEncrypted}"`) | ||
| 17 | - const rot13CipheredText = transcipher(messageToBeEncrypted) | ||
| 18 | - console.log(`Ciphered Text = "${rot13CipheredText}"`) | ||
| 19 | - const rot13DecipheredText = transcipher(rot13CipheredText) | ||
| 20 | - console.log(`Deciphered Text = "${rot13DecipheredText}"`) | ||
| 21 | - })() | ||
| 14 | + export { ROT13 } | ||
| 15 | + | ||
| 16 | + // > ROT13('The quick brown fox jumps over the lazy dog') | ||
| 17 | + // 'Gur dhvpx oebja sbk whzcf bire gur ynml qbt' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,8 +71,11 @@ function decrypt (message, key) { | |||
| 71 | 71 | return result | |
| 72 | 72 | } | |
| 73 | 73 | ||
| 74 | - const messageEncrypt = encrypt('Hello World!', 'code') | ||
| 75 | - console.log(messageEncrypt) // "Jhpnr Yrvng!" | ||
| 74 | + export { encrypt, decrypt } | ||
| 76 | 75 | ||
| 77 | - const messageDecrypt = decrypt('Jsopq Zstzg!', 'code') | ||
| 78 | - console.log(messageDecrypt) // "Hello World!" | ||
| 76 | + | ||
| 77 | + // > encrypt('Hello World!', 'code') | ||
| 78 | + // 'Jsopq Zstzg!' | ||
| 79 | + | ||
| 80 | + // > decrypt('Jsopq Zstzg!', 'code') | ||
| 81 | + // 'Hello World!' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,13 @@ function XOR (str, key) { | |||
| 20 | 20 | return result | |
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | - const encryptedString = XOR('test string', 32) | ||
| 24 | - console.log('Encrypted: ', encryptedString) | ||
| 25 | - const decryptedString = XOR(encryptedString, 32) | ||
| 26 | - console.log('Decrypted: ', decryptedString) | ||
| 23 | + export { XOR } | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + // Nb: Node REPL might not output the null char '\x00' (charcode 0) | ||
| 27 | + | ||
| 28 | + // > XOR('test string', 32) | ||
| 29 | + // 'TEST\x00STRING' | ||
| 30 | + | ||
| 31 | + // > XOR('TEST\x00STRING', 32) | ||
| 32 | + // 'test string' | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments