Programming Challenge 24-1

Programming Challenge 24-1

john.uhden
Mentor Mentor
1,009 Views
19 Replies
Message 1 of 20

Programming Challenge 24-1

john.uhden
Mentor
Mentor

Given a roll of 20 mil vinyl pool liner material, solve for how many feet of material are left if the outside diameter measures 11 inches and the hard cardboard core has an OD of 2.0 inches.

All calculations shall be made using AutoLisp with all code submitted for review.

It would be best written to accept input for each of the variables so that it could be used for any combination of conditions, and it must contain error trapping to report any invalid conditions, e.g. if the roll OD is less than the core OD (of course the answer could be 0 feet), or if any measurement is negative.

John F. Uhden

0 Likes
Accepted solutions (3)
1,010 Views
19 Replies
Replies (19)
Message 2 of 20

Kent1Cooper
Consultant
Consultant

I would assume that in real life [let's say] 5 layers of material would measure more than 100 mils -- there's got to be some little bit of air layer or non-sticking-together dusting or surface irregularities or other don't-quite-lie-precisely aspect.  I assume that should be ignored, but maybe an extra mil or two per layer should be assumed.

Kent Cooper, AIA
0 Likes
Message 3 of 20

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Nope, I am talking real life as you might recall I wrote software for a swimming pool liner manufacturer and served some time as their general manager.  There are never any gaps nor is there any discernable stretching as we always checked every bolt of material for thickness with a micrometer.  Typical thicknesses are 16 mil, 20 mil, and 27 mil depending on the size of the pool.  Don't want to get gypped.  Plus, we have to be sure that each panel which is designed in AutoCAD and then cut on an Eastman automatic cutting machine has exact dimensions.  Each liner is designed, cut, and assembled to fit the pool exactly.  Wrinkles are taboo.

Don't overthink it.

John F. Uhden

0 Likes
Message 4 of 20

Sea-Haven
Mentor
Mentor

My $0.05, ignores stuff like spiral step increase.

 

 

(defun JOHN:CH124 ( / ans rod tod thk rad num tot)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))

(setq ans (AH:getvalsm (list "Enter values" "Roll OD" 5 4 "10" "Thickness mil" 5 4 "20" "Tube OD" 5 4 "2")))

(setq rod (atof (car ans))
  Thk (/ (atof (cadr ans)) 1000.)
  tod (atof (caddr ans))
)

(cond 
  ((> tod (- rod 0.125))
    (progn (alert "Roll is to small for calulation \n\nWill now exit please run again")(exit))
  )
  ((> tod rod)
    (progn (alert "Inside roll tube  is set too large bigger than roll \n\nWill now exit please run again")(exit))
  )
  ((= thk 0.016)(princ))
  ((= thk 0.02)(princ))
  ((= thk 0.027)(princ))
  (alert "You have entered a incorrect thickness 16 20 or 27 are valid ")
)

(setq num (fix (/ (/ (- rod tod) 2.0) thk)))
(setq rad (+ (/ tod 2.0) (/ thk 2.0)))
(setq tot (* pi (* 2.0 rad)))

(repeat (- num 1)
  (setq rad (+ rad thk))
  (setq tot (+ tot (* pi (* 2.0 rad))))
)

(alert (strcat "You have " (rtos (/ tot 12) 2 1) " feet left"))

(princ)
)
(JOHN:CH124)

 

 

 

 

 

SeaHaven_0-1704609977951.pngSeaHaven_1-1704609994557.png

 

0 Likes
Message 5 of 20

john.uhden
Mentor
Mentor

For those who are at all interested, stretch IS part of the consideration.

In addition to panels being overlapped with heat "welded" seams, the manufacturer takes out another inch or more in length as part of the AutoCAD design because when the liner is placed within the pool walls, the water pressure will stretch the material to create a snug fit.  Remember, no wrinkles!

*** HINT ***

BTW #1, A 2 inch core is incorrect.  It's really a 3.5 inch core.  I guess I was thinking about rolls of plotter paper.

BTW #2, I doubt that you will develop the formula on your own.  I couldn't.

John F. Uhden

0 Likes
Message 6 of 20

Sea-Haven
Mentor
Mentor

11" dia 3.5" core 20 mil is this close ? You question was the length of the roll available.

 

SeaHaven_0-1704673636828.png

 

0 Likes
Message 7 of 20

john.uhden
Mentor
Mentor

@Sea-Haven 

(equal ans 1423.5 1069)  T

Read BTW #2

John F. Uhden

0 Likes
Message 8 of 20

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

....

BTW #2, I doubt that you will develop the formula on your own.  I couldn't.


Oh, I know the formula(s); it's just a matter of encoding them.  The number of layers [assuming you can realistically measure the outside diameter of the roll to the nearest fiftieth of an inch with any precision, and the sheet material doesn't compress in the measurement, and so on] is easy enough, and the amount of additional sheet length for each successive layer.  There's a quite short formula for how much additional roll length is to be added beyond just the tube circumference x the number of layers, based on the number of layers but not involving (repeat)ing to add some for each layer, successively more for each, one at a time.  But I'll keep that to myself until I get to putting it all together.

 

To be even more unrealistically realistic to a greater precision than would ever be possible, the length of the first layer should be measured at* the mid-way line of the sheet thickness -- there would be slight compression inboard of that, and slight stretching outboard.  [* The actual no-compression-or-stretch plane is really not exactly at the mid-thickness line, but that's at least much closer than the inside face, i.e. than the tube surface for the first layer.  Getting it exactly I think would require specifics about the physical properties of the material.]  And I would think a general calculation has to be based on the assumption that all layers go all the way around, and the last layer ends right over where the first one begins.

Kent Cooper, AIA
0 Likes
Message 9 of 20

Sea-Haven
Mentor
Mentor

Yes used a 1/2 thickness plus tube rad for starting circle. Looked at slope where layer rises up over existing and it seemed to add marginal length increase, like 0.5" to total did not check very closely. I used a formula not CAD for answer.

0 Likes
Message 10 of 20

john.uhden
Mentor
Mentor

@Kent1Cooper ,

You are overthinking it.

If there isn't at least 3 feet more than what's needed for the next liner, then they'll send the roll back for recycling.  Yeah, it's a loss, but not so great as the wasted labor cutting and seaming it again.

John F. Uhden

0 Likes
Message 11 of 20

john.uhden
Mentor
Mentor

@Sea-Haven ,

My apologies.

It's actually (equal ans 1423.5  2937) ;; in inches, a factor of 2± short.

John F. Uhden

0 Likes
Message 12 of 20

Kent1Cooper
Consultant
Consultant
Accepted solution

@john.uhden wrote:

If there isn't at least 3 feet more than what's needed for the next liner, then they'll send the roll back ....


Your BTW #2 implies there's something hard-to-derive about the calculations, which implies a certain level of precision that I assumed, which 3' of "slop" argues against, but overthinking or not, here's my approach.

 

The formula I alluded to before is in line 49.  Think of the incremental increase in circumference per layer as billiard balls -- the cumulative total over the layers [beyond the first one] of one bit of extra to add for the second layer, two for the next, etc.  The formula for the total of a "pyramidal" stack like that, with X rows, is X times {half-of-X-plus-one-half}.  Just plug in X [X=5 gives you the 15 billiard balls], and no repeating X times, and adding up along the way, is needed.  One line of code sums up the whole thing.

 

The code assumes the 3 standard thicknesses you list are all that are allowed, but it could be made to allow additional values instead of limiting it to those 3.  It offers 20-mil as initial default.  It offers 3.5" as the tube initial default diameter, though for that it allows any positive size input.  It forbids invalid [including negative] inputs for tube diameter and outside roll diameter in relation to it.

 

And in case one enters a roll diameter that is not a multiple of sheet thickness beyond the tube diameter [as is the case with your 11" vs. 3.5", which at 20 mils comes to 187.5 layers], it (fix)es the result, since you can't have a half-layer in terms of thickness.  It could instead round it to the nearest value up or down, instead of (fix)ing [rounding downward only].

Kent Cooper, AIA
Message 13 of 20

john.uhden
Mentor
Mentor

@Kent1Cooper ,

I am excruciatingly impressed!

I have to admit that I couldn't figure it out on my own so I found the formula on-line somewhere, and yes we got the same result within a foot.  Your only slight flaw is that you reported the length in inches, not feet.  And, yes, since we don't want precision >0 and don't want to round up, fixing the answer after conversion to feet is a sound idea.

Years ago I made an XLS for Maria in cutting so that they wouldn't load a roll onto the vertical carousel if there wasn't enough material for any jobs in the queue.  And if it was obvious that there wouldn't be enough material for any normal liner, then it was carted off to the recycling stack.  Understand that these rolls weigh hundreds of pounds so they have to use a forklift with a  6' long 2.5" steel rod to move the rolls around.  The reason for a carousel is that there are dozens of patterns so they want to get the ones in the queue ready to go to reduce down time.  I remember that once the giant chain rotating the rolls into place broke a link.  It cost them 3 weeks and $28K to replace it.  Luckily they have more than one cutting machine.  And luckily no one was around the carousel when the link broke.  They said you could hear the rolls fall to the floor from down the street.

John F. Uhden

0 Likes
Message 14 of 20

dbroad
Mentor
Mentor

Using an online archimedies spiral calculator, this is what I get:

2024-01-09_9-55-44.jpg

Of course, the O & I diameters would need to be measured with a micrometer for the answer to be precise and I would assume that given that, there would be a minimum error of 2*pi*11/12 feet. Also, stretch couldn't be calcuated without more information such as the initial stretch from the factory, the stress in place, and the modulus of elasticity I believe. That doesn't even consider the fact that if it is stretched from the factory, then each layer would be slightly less thick than nominal.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 15 of 20

Kent1Cooper
Consultant
Consultant

@dbroad wrote:

Using an online archimedies spiral calculator, this is what I get:  .... the O & I diameters would need to be measured with a micrometer for the answer to be precise....


Oh, so much stuff we can get over-picky about, but I find it fun to consider the details, however unrealistic.  This is why @Sea-Haven in Message 4 said "ignores stuff like spiral step increase."

 

The spiral length can't be precise because of course the wrapping doesn't really follow a spiral path:

Kent1Cooper_0-1704815789274.png

The true shape of the stepping would be affected by the flexibility of the material, and by how tight it's pulled in the winding.  And it would gradually broaden and smooth out as the number of layers increases.

 

If one actually had a need to account for such things in detail, it's hard to imagine how they could be calculated.

Kent Cooper, AIA
0 Likes
Message 16 of 20

john.uhden
Mentor
Mentor

Hi, @dbroad ,

Looks to me like your answer is correct.  Don't know what the formula looks like, but my source didn't credit Archimedes at all.

Of course you know that I can't give you credit because you haven't provided any AutoLisp code, but at least you have provided Kent and me some reassurance.

John F. Uhden

0 Likes
Message 17 of 20

dbroad
Mentor
Mentor
Accepted solution

Not looking for credit.  Since the difference in radii is so slight with each turn due to the thinness and the original tube shape, it simplfies roughly to calculating the number of turns and then multiplying the circumference of the average circle by its number of turns.

Turns = (OD-ID)/2/Thk = (11-3.5)/2/0.02=187.5

Ravg=(OD+ID)/4 = (11+3.5)/4=3.625

Arclength=Turns*2*pi*Ravg=187.5*2*pi*3.625=4270.6in=355.88 ft

Combining in terms of OD, ID and Thk=>  Arclength=pi*(OD^2-ID^2)/(4*Thk)

(defun foo (OD ID Thk)
  (/
    (* pi (- (* OD OD)(* ID ID)))
    (* 4 Thk)))
Architect, Registered NC, VA, SC, & GA.
Message 18 of 20

Sea-Haven
Mentor
Mentor
Accepted solution

2 mistakes in my code

(setq num (fix (/ (/ (- rod tod) 2.0) thk)))
(setq rad (+ (/ tod 2.0)(/ thk 2.0)))

 dia 11 od 3.5 thk 0.02 = 354.4 feet. V's 355.8 

0 Likes
Message 19 of 20

john.uhden
Mentor
Mentor

@dbroad,

That's good enough for me (except that there are a lot of FOOs out there).

That's the same formula that I had found.

John F. Uhden

0 Likes
Message 20 of 20

john.uhden
Mentor
Mentor

@Sea-Haven ,

A critical improvement.

Well done!

John F. Uhden

0 Likes