Skip to content

algorithm: palindrome number#93

Closed
fatima-0000 wants to merge 4 commits into
TheAlgorithms:masterfrom
fatima-0000:master
Closed

algorithm: palindrome number#93
fatima-0000 wants to merge 4 commits into
TheAlgorithms:masterfrom
fatima-0000:master

Conversation

@fatima-0000

Copy link
Copy Markdown
Contributor

The purpose of this pr is to add the is_palindrome algorithm in the maths algorithms. It checks whether a given number is a palindrome or not.


describe("IsPalindrome", () => {
test.each([[5, true], [1234, false], [12321, true], [32.23, true], [31343, false]])(
"correct output for for %i",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double "for"

Comment thread maths/is_palindrome.ts
let stringValue = number.toString();
let length = stringValue.length - 1;
for (let i = length; i >= 0; --i) {
reverseString = reverseString + stringValue[i];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why build a reverse string using repeated string concatenations when you could instead just check character-wise equality right in this loop?

@zFl4wless

Copy link
Copy Markdown
Contributor

@appgurueu This can now be closed. Finished in #118

@appgurueu appgurueu closed this Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants