Skip to content

Solution to Problem 4#105

Open
michaelkamau wants to merge 1 commit into
rust-nairobi:masterfrom
michaelkamau:problem-4
Open

Solution to Problem 4#105
michaelkamau wants to merge 1 commit into
rust-nairobi:masterfrom
michaelkamau:problem-4

Conversation

@michaelkamau

Copy link
Copy Markdown
Member

Solution Number: 4

Checklist:

  • Created binary in src/bin
  • Written Documentation
  • Written Tests

What

https://projecteuler.net/problem=4

How

  • Finds the largest palindrome made from the product of two n-digit numbers. This is an naive brute-force method. It finds all possible palindromes and then pick the largest one.

@michaelkamau

Copy link
Copy Markdown
Member Author

Add better documentation

@mattgathu

Copy link
Copy Markdown
Contributor

Alternative is_palindrome implementation

fn is_palindrome(num: u64) -> bool {
    let num_str: String = format!("{}", num); // 9009-> "9009"
    num_str == num_str.chars().rev().collect::<String>() 
}

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.

2 participants