Created
December 5, 2019 03:07
-
-
Save rgsoto/430c8283f90a878434768fa1942547a7 to your computer and use it in GitHub Desktop.
Node stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palindrome detected: A butt tuba | |
palindrome detected: A man, a plan, a canal—Panama! | |
palindrome detected: A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal–Panama! | |
palindrome detected: A Toyota's a Toyota | |
palindrome detected: Able was I ere I saw Elba. | |
palindrome detected: Ah, Satan sees Natasha | |
palindrome detected: deified | |
palindrome detected: Dennis sinned. | |
palindrome detected: Dennis and Edna sinned. | |
palindrome detected: Dennis, Nell, Edna, Leon, Nedra, Anita, Rolf, Nora, Alice, Carol, Leo, Jane, Reed, Dena, Dale, Basil, Rae, Penny, Lana, Dave, Denny, Lena, Ida, Bernadette, Ben, Ray, Lila, Nina, Jo, Ira, Mara, Sara, Mario, Jan, Ina, Lily, Arne, Bette, Dan, Reba, Diane, Lynn, Ed, Eva, Dana, Lynne, Pearl, Isabel, Ada, Ned, Dee, Rena, Joel, Lora, Cecil, Aaron, Flora, Tina, Arden, Noel, and Ellen sinned. | |
palindrome detected: Go hang a salami, I'm a lasagna hog. | |
palindrome detected: level | |
palindrome detected: Madam, I’m Adam. | |
palindrome detected: No "x" in "Nixon" | |
palindrome detected: No devil lived on | |
palindrome detected: Race fast, safe car | |
palindrome detected: racecar | |
palindrome detected: radar | |
palindrome detected: Was it a bar or a bat I saw? | |
palindrome detected: Was it a car or a cat I saw? | |
palindrome detected: Was it a cat I saw? | |
palindrome detected: Yo, banana boy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/node | |
let fs = require("fs"); | |
let Phrase = require("mhartl-palindrome"); | |
let text = fs.readFileSync("phrases.txt", "utf-8"); | |
text.split("\n").forEach(function(line){ | |
let phrase = new Phrase(line); | |
if (phrase.palindrome()) { | |
console.log("palindrome detected:", line); | |
fs.writeFileSync("palindromes.txt", line, (err)=> { | |
if (err) throw err; | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fs.writeFileSync("palindromes.txt", line, (err)=> { if (err) throw err; })
- This is the part i'm struggling with.