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 6062595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:12+00:00 2026-05-23T09:04:12+00:00

The basic idea of the program is that it searches a large list for

  • 0

The basic idea of the program is that it searches a large list for a given string, notes its index, and assigns other words based upon that index. The major issue is that, as there are some requirements built into the system that reject certain words, a very large recursion depth is likely to occur. There may be solutions that circumvent this problem (which I would be very interested in seeing) by avoiding recursion altogether, but recursion seems to be the most elegant solution, especially as there will be several versions of this program, that handle more and more words and indexes. Therefore, the major question is, how is it possible to get it to count recursion, so that it can kick out of the function if a depth limit is reached? Ideally, this would be in a loop, so that it could start where it left off from after that, but that seems to be a different problem. As it is, the counters are resetting unexpectedly.

lines = open ('newkj')
corpus= []
for line in lines :
corpus.extend(line.split())

limit = 800000
globallimit=800000
count=0
count2=0

"""This one is unique as it carries the null case in it. It is also a forward facing no check function"""

def curgb (indexa=indexof('the'),count=0) :
    worda=wordfor (indexa)
    wordb = wordfor (indexa+1)
    indexb=indexof(wordb)
    wordc = wordfor (advance(indexa)+1)
    indexc=indexof (wordc)
    if indexa> globallimit:
        print ('no results')
        return (indexa)
    elif indexb<limit and indexc<limit:
        curgd (indexc,indexb,indexa,count2+1)
    else:
        curgb(advance(indexa),count+1)
"""This function is also forward facing no check"""

def curgd (indexc,indexb,indexa,count2=0):
    wordd = wordfor (indexc+1)
    indexd = indexof(wordd)
    indexd=check(indexd,indexb,-1)
    print(count2)
    if indexd<limit and indexc<limit and indexb< limit and wordfor(indexd-1)==wordfor(indexb):
        """print (wordfor(indexa),wordfor(indexb))
        print (wordfor(indexd),wordfor (indexc))
        print ('     ')"""
        curgd(advance(indexc),indexb,indexa,count2+1)
    else :
        curgb(advance(indexa),count+1)

As it is, this is simplified and not likely to hit a recursion limit, but the major problem of the counter resetting is still there. Running the program is a matter of calling curgb() with an integer argument, corresponding to a given index.

  • 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-23T09:04:13+00:00Added an answer on May 23, 2026 at 9:04 am

    You seem to be mixing local and global variables.

    In curgb, count2 variable isn’t defined, and in curgd, count variable isn’t defined. Either use global keywork to access them, or pass both variable as arguments to both functions (the later is what you should do)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The basic idea is to take a string and evaluate it against an XML
Here's the basic idea: There is a java window (main) that opens another java
I'm trying to write a program that takes a large file (of any type)
The basic idea behind a Cancel button is to enable closing your window with
The basic idea of a masterpage is simple -- you have a block of
Binary search is harder to implement than it looks. Although the basic idea of
I have a python program that uses subprocess.Popen to launch another process (python process
I have been trying to create a Ruby program that will be running online
Basic requests are: human readable / text format (for easy version control) online (for
Basic question : How to I create a bidirectional one-to-many map in Fluent NHibernate?

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.