delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/06/18:38:24

Message-ID: <37FBC13F.A81E46E9@pentek.com>
Date: Wed, 06 Oct 1999 17:38:07 -0400
From: "Charles Krug Jr." <charles AT pentek DOT com>
X-Mailer: Mozilla 4.61 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How do I allocate more memory for .exe?
References: <37FBA7A1 DOT B7FAEBD6 AT cc DOT umanitoba DOT ca>
NNTP-Posting-Host: mail.pentek.com
X-Trace: 6 Oct 1999 17:41:17 -0400, mail.pentek.com
Lines: 35
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

umaveci0 wrote:
> 
> I have an assignment in which I must write a program which solves a
> letter 'Jumble'. User types in some letters (rivfey, for example), all
> permutations (different combinations) of the letters are put into a
> vector ( vector<string> ) and each permutation is compared to another
> vector of strings containing about 20,000 words (a dictionary) to get
> the answer (verify). Problem is I run out of memory.  Both
> vector<string> 's are big and solving a 6 letter Jumble causes the
> program to crash (5 is okay). I am referencing the vectors. How do I
> allow the program to use more memory?
> 
> I'm using DJGPP in WIN95 and have 64Mb of RAM.
> 
> Thanks.

Hmmm . . . Why not rewrite your program to use less memory?

You don't seem to have any trouble generating your vector of
permutations.  That's actually kind of tricky, getting all the loops
right.  But remember that the size of this vector will get HUGE very
quickly -- it increases as n! the number of letters.

So rather than storing the entire vector of permutations, why not just
store each one in turn?  This will require a single string instead of a
vector<string> with n! elements.  If you don't get a match, you generate
your next permutation.

If the assignment is worded such that you must use a vector for your
permutations, as opposed to just the dictionary, then decide in advance
how large you will allow your vector to grow.  Then divide your vector
of permutations accordingly.


Charles

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019