?
Solved

I need a help with math and code

Posted on 2008-02-11
10
Medium Priority
?
148 Views
Last Modified: 2010-04-21
Hello guys,

I have a table in access with 1200 words,

In a stringGrid I need to have column with 16 words. Each Column will be a group with
16 words.

but the problem is, From 3 group created, each group created must have 60 % of words
in previous groups created.

With my math 1200 words with + 60 % of repeated words I will have a total of 1920 split in
120 column

this example can be made with number

thanks

0
Comment
Question by:hidrau
9 Comments
 
LVL 2

Expert Comment

by:LordWolfy
ID: 20868980

Your question really could be a lot clearer.

60% of 16 is 9.6 - so if you if you need at least 60% (I'm assuming at least rather than exactly), then at least 10 of youre previous group of 16 will have to be duplicated (is there a rule for this or do you just take any 10??)

By this logic, the minimum number of words you will have is 1200 + (((1200 / 16) - 1) * 10)
= 1200 + 740
= 1940

Minimum number of columns = 1940 / 16 = 121.25
rounded up = 122 with the free space filled by virtue of it being at least 60% instead of exactly.

You also said  'From 3 group created'.  What does that mean?  If that has a bearing on the process and calculations then these figures will probably be completely off.
0
 
LVL 1

Author Comment

by:hidrau
ID: 20869316
Hello LordWolfy,

I am gonna try to clear my question better. Sorry my mistakes in english, ok :))

Imagine something like this:

I have a edit that you enter the percent of repeated word for each group.

The repeated words will be repeated from my 3 group, that is,
after creating 3 goups with this sequence:

Group A [ 1..16]
Group B [ 17..32 ]
Group C [ 33..49 ]

Now, other groups will be created with a percent from previous groups, that is:

Group D will have a little of my group A - B - C

Group E will have a little of my group A - B - C - D

Group F will have a little of my group A - B - C - D - E

and so on


Well, if I will have an increase of 740 repeated words or number on my 1200 words, then I will need
split all the 1940 words into 122 groups. If I have a percent less than 60, obvisouly I will have a less
group of words.

Did you get it?
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20869493
The example easily gets out of hand...

If group A has 16 words, group B has 16 words, and group C has 16 words to start...

  You want to go to group D (and later) and take at least 60 % of it's values from the previous groups without going over 16 in each...

  You would rapidly get into a situation where you cannot take a value from each group because you are only allowed 16.

  If We are only filling in "at least 60%" from the previous columns, where do we get the rest of the words to fill in?  Generate them from a simple number counter?

  If you are ok with only getting 10 from previous columns, how are they chosen?  could you take 3 from A, 3 from B, none from C, and 4 from D to get the 10 for group E?   A simple random routine could randomly grab words from columns if there is no issue with getting more than one from the same column while filling another column.

  For that matter, do you want to make sure that - as we pull out words - one word is pulled out only once for the entire run?

Sorry, but we need more info!
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
LVL 1

Author Comment

by:hidrau
ID: 20974455
Sorry for the delay of my reply.

Well, i think it is missing information about what I am trying to do. I am gonna describe what I need to do and you will be able to give a better solution to accomplish it.

I have a database of picture with 1064 pictures inside.

I need assemble groups of 16 pictures, I could split those images into the groups. But I need something different.

So, imagine this situation:

I start my first lesson (first group of 16 images), after studying them I can start another lesson and so on.

When I am at 6 lesson, I would like to have some pictures in my new groups from past groups studied, maybe 40 % of my 16 pictures will be from those images that I already studied. I also thought in having groups formed from images that I already studied, then I will have a group with 100% of studied images.

So it could be

For each 6 groups studied I will have one or two groups with only images studied.
I need to informa the system that after X studied groups I want some pictures from repeated
studied groups.

All those can be made with number that will represent the ID of each image

Did you get it?
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20996921
From what you explained this is the general idea for each set of 6 lessons...
Lesson1 new images
Lesson2 new images
Lesson3 new images
Lesson4 new images
Lesson5 new images
Lesson6 40% from lessons 1-5 the rest new.

Is this correct?  and, if it is correct, would you want lesson 7 to contain only images not in lessons 1-6?

Let me know
0
 
LVL 1

Author Comment

by:hidrau
ID: 20997431
Yeah it is correct,

Lesson6 must have some repeated images from those lessons studied as a random reinforce.

After lesson6, each lesson is gonna get 40 % from past lessons and so on. But it is interresting another
way, see below.

 if I could have for each 5 lesson created two lesson with only repeated images from my past lessons, so, an example:

Lesson1 new images
Lesson2 new images
Lesson3 new images
Lesson4 new images
Lesson5 new images

Lesson6 100 % of images from all past lesson [1..5]
Lesson7 100 % of images from all past lesson [1..5]

Lesson8 new images
Lesson9 new images
Lesson10 new images
Lesson11 new images
Lesson12 new images

Lesson13 100 % of images from all past lesson [1..12]
Lesson14 100 % of images from all past lesson [1..12]

What I told you above, it is another example different from the first one that I asked.
So, let's see now the original order


Lesson1 new images
Lesson2 new images
Lesson3 new images
Lesson4 new images
Lesson5 new images

Lesson6 40 % from lessons[1.5] and more new images
Lesson7 40 % from lessons[1.6] and more new images
Lesson7 40 % from lessons[1.7] and more new images

developmentguru, it is my ideia about, but you can give me your opinion on this. So fee free
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 1500 total points
ID: 21040448
One thing I should know.  Are you storing your images in a TImageList?  The indexing would make some of this easier.  Are they stored in a database?  Separate files?  In any case if you load them into a TImageList then the following code should work.  Keep in mind, rather than come up with many images to use I am using strings.  The same principal applies though.  Place two memos and a button on a form and paste the code in.  Attach the FormCreate method, and the ButtonClick method.  Form Create fills the first memo with strings to use.  Button Click uses the values in memo 1 to create lessons.  In your case, instead of using strings in a string list you would use indexes stored in a TList, the concept is the same.  Let me know if this example gives you the tools you need, it should.
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  L, I : Integer;
  Total, Chosen : TStringList;
  Choice : integer;
 
begin
  //Total holds the list to start from
  Total := TStringList.Create;
  Total.Assign(Memo1.Lines);
  try
    //Chosen holds the list of those that have been chosen.
    Chosen := TStringList.Create;
    try
      for L := 1 to 14 do
        begin
          Memo2.Lines.Add('Lesson:' + IntToStr(L));
          if L mod 7 in [0..4] then
            begin
              for I := 1 to 16 do
                begin
                 Choice := Random(Total.Count);
                 Chosen.Add(Total[Choice]);
                 Memo2.Lines.Add(Total[Choice]);
                 Total.Delete(Choice);
                end;
            end
          else
            begin
              for I := 1 to 16 do
                begin
                 Choice := Random(Chosen.Count);
                 Memo2.Lines.Add(Chosen[Choice]);
                end;
            end;
        end;
    finally
      Chosen.Free;
    end;
  finally
    Total.Free;
  end;
end;
 
procedure TForm1.FormCreate(Sender: TObject);
var
  I : Integer;
 
begin
  Memo1.Clear;
  for I := 1 to 1000 do
    Memo1.Lines.Add(IntToStr(I));
  Memo2.Clear;
end;
 
end.

Open in new window

0
 
LVL 10

Expert Comment

by:Jacco
ID: 21151054
The math ;-)
n - number of pictures each lesson
x - lessons before the start repeating images
p - the fraction of images that should be repeats in stead of new ones
t - the total number of images

before repeats: x * n new images
with repeats: (1 - p) * n per lesson

lessons needed:
lessons needed for whole course = x + (t - (x * n)) / ((1 - p) * n)

So for 1200 images start after 3 lessons with 0.6 repeats and 16 images per lesson:
3 + (1200 - 16*3) / (0.4*16) = 183 lessons

Its discreet math though :S
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 31429884
thanks
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question