mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
feat: rewrite programming-challenges CLI (#3)
This commit is contained in:
@ -10,4 +10,4 @@ The function should return `true` if a given string (case insensitive) is a pali
|
||||
|
||||
## Examples
|
||||
|
||||
See the `input-output.json` file for examples of input/output.
|
||||
See the `test` folder for examples of input/output.
|
||||
|
@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"input": ["kayak"],
|
||||
"output": true
|
||||
},
|
||||
{
|
||||
"input": ["hello"],
|
||||
"output": false
|
||||
},
|
||||
{
|
||||
"input": ["Was it a cat I saw"],
|
||||
"output": true
|
||||
},
|
||||
{
|
||||
"input": ["No lemon, no melon"],
|
||||
"output": true
|
||||
},
|
||||
{
|
||||
"input": ["achievement"],
|
||||
"output": false
|
||||
}
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
# is-palindrome/javascript/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 9 June 2021.
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import readline from 'readline'
|
||||
|
||||
const input = []
|
||||
const readlineInterface = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
readlineInterface.on('line', (value) => {
|
||||
input.push(value)
|
||||
})
|
||||
readlineInterface.on('close', solution)
|
||||
|
||||
function solution() {
|
||||
const string = input[0].replace(/ /g, '').toLowerCase()
|
||||
const isPalindrome = string.split('').reverse().join('') === string
|
||||
console.log(isPalindrome)
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
# typescript-palindrome - is-palindrome
|
||||
|
||||
Programming language : TypeScript
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
|
@ -1,6 +0,0 @@
|
||||
function solution (string: string) {
|
||||
const formattedString = string.replace(/ /g,'').toLowerCase()
|
||||
return formattedString === formattedString.split("").reverse().join('')
|
||||
}
|
||||
|
||||
export default solution
|
1
challenges/is-palindrome/test/1/input.txt
Normal file
1
challenges/is-palindrome/test/1/input.txt
Normal file
@ -0,0 +1 @@
|
||||
kayak
|
1
challenges/is-palindrome/test/1/output.txt
Normal file
1
challenges/is-palindrome/test/1/output.txt
Normal file
@ -0,0 +1 @@
|
||||
true
|
1
challenges/is-palindrome/test/2/input.txt
Normal file
1
challenges/is-palindrome/test/2/input.txt
Normal file
@ -0,0 +1 @@
|
||||
hello
|
1
challenges/is-palindrome/test/2/output.txt
Normal file
1
challenges/is-palindrome/test/2/output.txt
Normal file
@ -0,0 +1 @@
|
||||
false
|
1
challenges/is-palindrome/test/3/input.txt
Normal file
1
challenges/is-palindrome/test/3/input.txt
Normal file
@ -0,0 +1 @@
|
||||
Was it a cat I saw
|
1
challenges/is-palindrome/test/3/output.txt
Normal file
1
challenges/is-palindrome/test/3/output.txt
Normal file
@ -0,0 +1 @@
|
||||
true
|
1
challenges/is-palindrome/test/4/input.txt
Normal file
1
challenges/is-palindrome/test/4/input.txt
Normal file
@ -0,0 +1 @@
|
||||
No lemon, no melon
|
1
challenges/is-palindrome/test/4/output.txt
Normal file
1
challenges/is-palindrome/test/4/output.txt
Normal file
@ -0,0 +1 @@
|
||||
true
|
1
challenges/is-palindrome/test/5/input.txt
Normal file
1
challenges/is-palindrome/test/5/input.txt
Normal file
@ -0,0 +1 @@
|
||||
achievement
|
1
challenges/is-palindrome/test/5/output.txt
Normal file
1
challenges/is-palindrome/test/5/output.txt
Normal file
@ -0,0 +1 @@
|
||||
false
|
Reference in New Issue
Block a user