This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes cut a certain stripe of a square Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "cut a certain stripe of a square" Watch "cut a certain stripe of a square" New topic
Author

cut a certain stripe of a square

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Draw a square with width N.
Cut of a rectangular stripe of width c at the right.
Turn the stripe inside the remaining rectangle, so that all corners will be positioned on the resulting outer rectangle.
How long has the width of the cut to be, to make the stripe fit?

(Note: An turning angle of n*90�, n being an integer, is not allowed.)

Schematical image - the outer rectangle shall be a square.

Why isn't this shown in monospace-font?
Copy it to a monospaced-font editor to view it right

Well - it's more a geometrical/ mathematical diversion, but I needed assistance from Java to find a nearly solution iterating, and on that way I observed some details, which helped solving it mathematically.

A link to the solution will follow soon.

I hope it's new to the most of you.

Well here is a graphical representation of the quiz.
At the bottom of the page is a link to the solution.
http://home.arcor.de/hirnstrom/minis/qdk/QuadratQuizQuiz.html
[ April 24, 2006: Message edited by: Stefan Wagner ]

[ April 24, 2006: Message edited by: Stefan Wagner ]
[ April 24, 2006: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Ajay A Patil
Greenhorn

Joined: Apr 13, 2006
Posts: 22
Trick question.. The stripe will never fit.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Ajay: Why? Give a prove, or at least a reason.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

c = N/2 works nicely (just fold the square in half).

(No, I didn't get that by geometric intuition. I derived the equation N sin a + c cos a = N - c and noticed that a = 0 gave that solution. It's time to go to bed so I'm not going to look for nontrivial solutions just now.)
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Well, Paul, have a nice sleep, and read the next morning this:

I added a restriction for the too clever ones:

(Note: An turning angle of n*90�, n being an integer, is not allowed.)
Ajay A Patil
Greenhorn

Joined: Apr 13, 2006
Posts: 22
Stefan..

Ajay: Why? Give a prove, or at least a reason.

The hypotenus of a right-angle triangle cannot be the same length
as one of the other sides.

But, the problem was really nice.
I am sorry if I spoilt it for the others.
Ajay A Patil
Greenhorn

Joined: Apr 13, 2006
Posts: 22
I am sorry. my reason/proof is wrong.
** lol ** need to give more thought.
Ajay A Patil
Greenhorn

Joined: Apr 13, 2006
Posts: 22
Noticed that
N sin a + c cos a = N - c
N cos a + c sin a = N

But, unable to solve this and get 'c' in terms of 'N'.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Or:

(1) c sin a = N (1 - cos a)
(2) c (1 + cos a) = N (1 - sin a)

Multiply (1) by 1 + cos a:

(3) c sin a (1 + cos a) = N sin2 a [that's sine-squared a]
(4) c (1 + cos a) = N sin a

Combine (2) with (4):

(5) sin a = 1/2
(6) cos a = sqrt(3)/2
(7) c = N (2 - sqrt(3))
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Fast solution, Paul. (I needed 3 starts in 4 years to solve this f...in' problem ).
Can you tell me where a is, because I used a different way to find the same solution?
my way:
http://home.arcor.de/hirnstrom/minis/qdk/QuadratQuiz.html
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

"a" is the angle in the small triangle at the lower left of the square, about where "b/)'y" is at the bottom of your diagram.
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1006
    
    3
Originally posted by Paul Clapham:
"a" is the angle in the small triangle at the lower left of the square, about where "b/)'y" is at the bottom of your diagram.


Or even better...

It's where the "a)" is in the top line. In fact, I assumed that's how Ajay picked the variable a for that angle.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Ah - you're talking about the ascii-art.
I'm searching and searching the real graphics on the webpage ...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Stefan Wagner:
Ah - you're talking about the ascii-art.
Of course. I didn't even look at the web page until I had the answer. Would have been cheating.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cut a certain stripe of a square
 
Similar Threads
Etch-a-Sketch Analytic Geometry
Generate random strings
BitOrgel (bitorgan)
Nine 4s to make it 2000
Casting long to int, when it does not fit