Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.programming Subject: Re: Coding while drunk and stoned take 2. (Yes, I know this is a cross post) Date: Thu, 27 Feb 2020 21:06:27 +0000 Organization: A noiseless patient Spider Lines: 27 Message-ID: <87a753viy4.fsf@bsb.me.uk> References: <0b8d1b58-3651-47ed-a2b8-63dc1d659c91@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="c5b2f88804383f9a4f3ed96188f26610"; logging-data="12879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r8I7iI0Hhhh/o6PaaYOHXPR5y4yLYwEs=" Cancel-Lock: sha1:TfqGAKgwiOTiuZXVIdg9xzJ3N70= sha1:Hg8Nfl/m7YovRoojtFQaJIy8JrA= X-BSB-Auth: 1.d64db599aaa773d3a81d.20200227210627GMT.87a753viy4.fsf@bsb.me.uk Xref: csiph.com comp.programming:10696 "Chad Altenburg, Ph.D." writes: > https://codingbat.com/prob/p180759 > > And here is the problem statement... > > Look for patterns like "zip" and "zap" in the string -- length-3, > starting with 'z' and ending with 'p'. Return a string where for all > such words, the middle letter is gone, so "zipXzap" yields "zpXzp". > > zipZap("zipXzap") → "zpXzp" > zipZap("zopzop") → "zpzp" > zipZap("zzzopzop") → "zzzpzp" There's are some interesting corner cases. What about zipZap("zipp") → "zpp" or "zp"? And if "overlapping" zXp strings like this are to be ignored, the problem statement is not clear about zipZap("zzpp") → "zpp" or "zzp"? You get different result from forward and reverse scans. -- Ben.