All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.esm.strings.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"strings.js","sources":["../../lib/strings.mjs"],"sourcesContent":["\n\n\n/**\n * Get all possible combinations of substrings that add up to the given string\n * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string\n * @param {string} input\n * @return {string[][]}\n */\nexport const allSubstrings = (input) => {\n\n    if( input.length === 1) return [[input]];\n\n\t/** @type {string[][]} */\n    let result = [];\n\n\tconst start = input.substring(1);\n    const suba = allSubstrings(start);\n\n\tsuba.forEach(function(subresult) {\n        let tmp = subresult.slice(0);\n        tmp[0] = input.charAt(0) + tmp[0];\n        result.push(tmp);\n\n        tmp = subresult.slice(0);\n        tmp.unshift(input.charAt(0));\n        result.push(tmp);\n    });\n\n    return result;\n}\n"],"names":["allSubstrings","input","length","result","start","substring","suba","forEach","subresult","tmp","slice","charAt","push","unshift"],"mappings":";AAGA;AACA;AACA;AACA;AACA;AACA;AACaA,MAAAA,aAAa,GAAIC,KAAD,IAAW;EAEpC,IAAIA,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,OAAO,CAAC,CAACD,KAAD,CAAD,CAAP,CAAA;AAE3B;;EACG,IAAIE,MAAM,GAAG,EAAb,CAAA;AAEH,EAAA,MAAMC,KAAK,GAAGH,KAAK,CAACI,SAAN,CAAgB,CAAhB,CAAd,CAAA;AACG,EAAA,MAAMC,IAAI,GAAGN,aAAa,CAACI,KAAD,CAA1B,CAAA;AAEHE,EAAAA,IAAI,CAACC,OAAL,CAAa,UAASC,SAAT,EAAoB;AAC1B,IAAA,IAAIC,GAAG,GAAGD,SAAS,CAACE,KAAV,CAAgB,CAAhB,CAAV,CAAA;AACAD,IAAAA,GAAG,CAAC,CAAD,CAAH,GAASR,KAAK,CAACU,MAAN,CAAa,CAAb,CAAA,GAAkBF,GAAG,CAAC,CAAD,CAA9B,CAAA;IACAN,MAAM,CAACS,IAAP,CAAYH,GAAZ,CAAA,CAAA;AAEAA,IAAAA,GAAG,GAAGD,SAAS,CAACE,KAAV,CAAgB,CAAhB,CAAN,CAAA;IACAD,GAAG,CAACI,OAAJ,CAAYZ,KAAK,CAACU,MAAN,CAAa,CAAb,CAAZ,CAAA,CAAA;IACAR,MAAM,CAACS,IAAP,CAAYH,GAAZ,CAAA,CAAA;GAPP,CAAA,CAAA;AAUG,EAAA,OAAON,MAAP,CAAA;AACH;;;;"}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy