Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6155509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:26:54+00:00 2026-05-23T20:26:54+00:00

Looking for a fast way to limit duplicates to a max of 2 when

  • 0

Looking for a fast way to limit duplicates to a max of 2 when they occur next to each other.

For example: jeeeeeeeep => ['jep','jeep']

Looking for suggestions in python but happy to see an example in anything – not difficult to switch.

Thanks for any assistance!

EDIT: English doesn’t have any (or many) consonants (same letter) in a row right? Lets limit this so no duplicate consonants in a row and up to two vowels in a row

EDIT2: I’m silly (hey that word has two consonants), just checking all letters, limiting duplicate letters that are next to each other to two.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:26:55+00:00Added an answer on May 23, 2026 at 8:26 pm

    Here’s a recursive solution using groupby. I’ve left it up to you which characters you want to be able to repeat (defaults to vowels only though):

    from itertools import groupby
    
    def find_dub_strs(mystring):
        grp = groupby(mystring)
        seq = [(k, len(list(g)) >= 2) for k, g in grp]
        allowed = ('aeioupt')
        return rec_dubz('', seq, allowed=allowed)
    
    def rec_dubz(prev, seq, allowed='aeiou'):
        if not seq:
            return [prev]
        solutions = rec_dubz(prev + seq[0][0], seq[1:], allowed=allowed)
        if seq[0][0] in allowed and seq[0][1]:
            solutions += rec_dubz(prev + seq[0][0] * 2, seq[1:], allowed=allowed)
        return solutions
    

    This is really just a heuristically pruned depth-first search into your “solution space” of possible words. The heuristic is that we only allow a single repeat at a time, and only if it is a valid repeatable letter. You should end up with 2**n words at the end, where n is he number times an “allowed” character was repeated in your string.

    >>> find_dub_strs('jeeeeeep')
    ['jep', 'jeep']
    >>> find_dub_strs('jeeeeeeppp')
    ['jep', 'jepp', 'jeep', 'jeepp']
    >>> find_dub_strs('jeeeeeeppphhhht')
    ['jepht', 'jeppht', 'jeepht', 'jeeppht']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a fast way in C# to find all dates in a
I'm looking for a fast, clean, pythonic way to divide a list into exactly
I'm looking for a fast way to interconvert between linear and multidimensional indexing in
I am looking for a fast way to find the number of files in
I am looking for a script or a fast way of putting together a
I am looking for a fast and efficient way to calculate the frequency of
I'm looking for a fast & elegant way of converting my object IDs with
I'm looking for a fast way to setup a method of returning a bitmask
I'm looking for a fast way to apply a new palette to an existing
I am looking for a fast way to calculate the size of a folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.