feat(euler-problem): Add tests and solution for Problem 4: Largest palindrome product#15856
Conversation
|
@AungMyoKyaw This is a nice start. It looks like you got a build error. Is this passing for you locally when you run Also, could you share a working solution here to make this easier to QA? |
5559c3d to
1381d76
Compare
|
@AungMyoKyaw updated the pull request. |
1381d76 to
0d7d775
Compare
|
@AungMyoKyaw updated the pull request. |
|
@AungMyoKyaw Any luck getting this to pass locally? |
|
Hi @QuincyLarson |
|
@AungMyoKyaw It looks like Node may be interpreting some of your code as octals. This Stack Overflow answer may be relevant: https://stackoverflow.com/questions/23609042/how-to-avoid-octal-literals-are-not-allowed-in-strict-mode-with-createwritestr @texas2010 Do you know what might be causing this? |
|
Hi @QuincyLarson , "const largestPalindromeProduct = (digit)=>{\n let start = 1;\n let end = Number(`1e${digit}`) - 1;\n let palindrome = [];\n for(let i=start;i<=end;i++){\n for(let j=start;j<=end;j++){\n let product = i*j;\n let palindromeRegex = new RegExp('\\b(\\d)(\\d?)(\\d?).?\\3\\2\\1\\b','gi');\n palindromeRegex.test(product) && palindrome.push(product);\n }\n }\n return Math.max(...palindrome);\n}"Here is more readable version const largestPalindromeProduct = (digit)=>{
let start = 1;
let end = Number(`1e${digit}`) - 1;
let palindrome = [];
for(let i=start;i<=end;i++){
for(let j=start;j<=end;j++){
let product = i*j;
let palindromeRegex = new RegExp('\\b(\\d)(\\d?)(\\d?).?\\3\\2\\1\\b','gi');
palindromeRegex.test(product) && palindrome.push(product);
}
}
return Math.max(...palindrome);
} |
|
I've granted @alvinkl write access to this repo. He has agreed to help QA your pull requests since he knows more about the process of importing and improving these Project Euler challenges than anyone. |
|
@QuincyLarson I am not sure (for my lack of expertise on the topic) what this needs for a QA? Are we able to either merge or close this? |
|
Hi there @AungMyoKyaw. I was asked to take a look at your pull request. I have it running fine here on my local machine, and @QuincyLarson, is there a way to trigger another Travis-CI build on your end? Or would it be best for @AungMyoKyaw to close and reopen this pull request? Maybe squash and push an empty commit? I'm not sure what would be best in this case. |
|
@scissorsneedfoodtoo this pull request simply needs a re-base against the current staging. @AungMyoKyaw you need to That will re-base the code and trigger the build again. |
|
@raisedadead Thank you! I'll definitely keep that in mind. @AungMyoKyaw, good luck with the new build. |
0d7d775 to
5ec8341
Compare
|
@AungMyoKyaw updated the pull request. |
|
Hi @QuincyLarson , @raisedadead , @scissorsneedfoodtoo |
|
@AungMyoKyaw, no worries! Thank you for updating your pull request. Sorry the build is still failing. It seems to be a problem with another challenge, possibly Create a Priority Queue Class. I'm looking into it now. Hope we can get this sorted out and merge your pull request soon! |
|
@AungMyoKyaw, I think I figured out the problem. If you change your solution to this, then your pull request should have no problems passing the tests: I believe the problem was that the new RegExp function. Seems like it wasn't allowing proper character escapes, which caused the error. Anyway, you should be good to go after that change! |
5ec8341 to
b1d3037
Compare
|
@raisedadead updated the pull request. |
|
@QuincyLarson thanks to @scissorsneedfoodtoo I have updated @AungMyoKyaw 's pull request to address the error in the tests. /cc @BerkeleyTrue I had to add a check here in the test entry point https://github.com/freeCodeCamp/freeCodeCamp/pull/15856/files#diff-fa70e80f212af821d2f311eb03e2ad60R218 Seems, there is sneaky exception thrown without it. |
|
@raisedadead, thank you for updating @AungMyoKyaw's PR! I'm sorry I didn't do it sooner. Everything LGTM! No exceptions or errors thrown anymore. |
|
@scissorsneedfoodtoo Awesome - thanks! @raisedadead so we're just waiting for @BerkeleyTrue's approval of your change before we can merge this? https://github.com/freeCodeCamp/freeCodeCamp/pull/15856/files#diff-fa70e80f212af821d2f311eb03e2ad60R218 |
|
Yes. That is correct @QuincyLarson |
|
@AungMyoKyaw, thank you! Glad we could get your contribution merged. |
feat(euler-problem): Add tests and solution for Problem 4: Largest palindrome product
Add tests and solution for Problem 4: Largest palindrome product
Pre-Submission Checklist
stagingbranch of freeCodeCamp.fix/,feature/, ortranslate/(e.g.fix/signin-issue)npm test. Usegit commit --amendto amend any fixes.Type of Change
Checklist:
Description