Created
February 23, 2020 00:53
-
-
Save daxxog/12447d133eb80b90592117ddf0189cf5 to your computer and use it in GitHub Desktop.
generator for palindrome case statements
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
const c4se = function(n) { | |
const varname = 'string_x'; | |
var buildCase = ''; | |
console.log('case ' + n + ':'); | |
for(var i = 0; i<~~(n/2); i++) { | |
buildCase += '(string_x[' + i + '] === ' + 'string_x[' + (n - i - 1) + '])'; | |
} | |
console.log(' return ' + buildCase.split(')(').join(')&&(') + ';'); | |
}; | |
for(var i = 0; i<50; i++) { | |
c4se(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment