Curses Programming

A

alexander

Hi, all

Here is the test. Plz help.....

/
***************************************************************************************************************************************************/
If you use the new image search of Google, you will find that the
result images are layouted in a way that each row has the same height,
but contains different number of images dependents the width-height
ratio of each image. The goal is to make each row of images having
approximately same total width. Just try search any image
inimages.google.com, you will get the idea.
If you're the programmer designing this page, what algorithm would you
use to select images for each row?
Input:
The input of the program is a plain text file, each line in the file
containg 2 numbers, describing the width and height of an image
e.g.
800 600
640 400
720 1280
....
Goal:
Design an algorithm to put those images into a number of rows, each
row is 150 pixel height and 1200 pixel wide. You could scale images
proportionally to the same height. You need make sure the images are
aligned as closely as possbile to the row boundary.
Output:
The indexes of the images you would put on each row followed by blank
line.
e.g.
0
1
2
According to the input file example, this output means image-0 (800 x
600) and image-1 (640 x 400) is put on the first row and image-2 (720
x 1280) is put on the second row.
Constraint:
Assuming, the input file contains less than 100 lines. Your algorithm
should finish within 5 secs on a standard laptop.

/
**********************************************************************************************************************************************/

Could any give a hand?
Thanks a lot
Alex
 
C

Chris Rebert

Subject: Curses Programming

This has nothing whatsoever to do with the (n)curses library or even
console programming. Lying in your subject line does not help gain you
goodwill.
Hi, all

    Here is the test. Plz help.....
<problem specification snipped>

If you want homework help, show that you've at least made /some/ sort
of attempt, and ask a *specific* question regarding what part is
giving you trouble.
Otherwise, you're liable to be ignored with prejudice. Usage of
expressions like "Plz" doesn't help your case either.

Regards,
Chris
 
R

r0g

Hi, all

Here is the test. Plz help.....

/
***************************************************************************************************************************************************/
If you use the new image search of Google, you will find that the
result images are layouted in a way that each row has the same height,
but contains different number of images dependents the width-height
ratio of each image. The goal is to make each row of images having
approximately same total width. Just try search any image
inimages.google.com, you will get the idea.
If you're the programmer designing this page, what algorithm would you
use to select images for each row?
Input:
The input of the program is a plain text file, each line in the file
containg 2 numbers, describing the width and height of an image
e.g.
800 600
640 400
720 1280
...
Goal:
Design an algorithm to put those images into a number of rows, each
row is 150 pixel height and 1200 pixel wide. You could scale images
proportionally to the same height. You need make sure the images are
aligned as closely as possbile to the row boundary.
Output:
The indexes of the images you would put on each row followed by blank
line.
e.g.
0
1
2
According to the input file example, this output means image-0 (800 x
600) and image-1 (640 x 400) is put on the first row and image-2 (720
x 1280) is put on the second row.
Constraint:
Assuming, the input file contains less than 100 lines. Your algorithm
should finish within 5 secs on a standard laptop.

/
**********************************************************************************************************************************************/

Could any give a hand?
Thanks a lot
Alex


Alex,

At least try thinking about how you would solve the problem - that is
after all the whole point of the exercise i.e. to think up an algorithm,
not to code it in python. That part is your homework and nobody here
will do it for you. Also, if you don't enjoy solving this kind of
problem it's possible you are studying the wrong subject.

If you can think of a basic strategy to solve the above problem and can
explain it in fairly plain english then I'm sure some people here will
be happy to a) improve it and b) Help you if you are struggling to
translate your concept into working python code.

Even then, it being a homework assignment you can't expect people to
just give it to you on a plate. Expect homework assistance to be at
least slightly oblique, it's for your own good. If you don't have to do
any thinking yourself then you're not going to learn much either and
next week you'll be right back where you were, pestering some other poor
forum.

Good luck with it!

Roger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top