Divide a circle into as many parts using 4 lines...

erikiksaz

Diamond Member
Nov 3, 1999
5,486
0
76
This was a fun little problem i encountered at one of my training classes. Anyways, we find the answer, but here's the kicker...

Write an equation for solving the problem, so that one doesn't have to use trial and error in finding the answer.


And btw, the max # of parts is....

















11. Just to save you time.

As for the equation, my friend came up with some sort of series problem, but i don't know if that counts as an equation. For example, if you needed to find out how many parts you can cut the circle into with 7 lines, you'd have to start from 1 line all the way up to 7 using his method. I, instead, was working at some equation with X being # of lines crossed. Didn't work out too well though.
 

Evadman

Administrator Emeritus<br>Elite Member
Feb 18, 2001
30,990
5
81
The answer is always the same based on the number of lines, as each line can cross every other line except itself, since the definition of a line doesn't allow for it crossing itself unless in a universe that allows more than 4 dimensions. (Height, Width, Depth and Time)

A simple equasion to give you the number of lines would be (Number of lines * (Number of lines -1)) -1

For example:
4 lines: (4 * (4-1)) - 1 = 4 * 3 -1 = 11
7 lines: (7 * (7-1)) - 1 = 7 * 6 -1 = 41
 
Aug 27, 2002
10,043
2
0
4*3-1 it's not that difficult

4 lines 3 possible intersections per line -1 because you won't have any lines that don't interect with another line in the equation if you're looking for max divisions

btw it's the same no matter how many lines 5 lines would be

5*4-1
 

Evadman

Administrator Emeritus<br>Elite Member
Feb 18, 2001
30,990
5
81
Originally posted by: lobadobadingdong
4*3-1 it's not that difficult

4 lines 3 possible intersections per line -1 because you won't have any lines that don't interect with another line in the equation if you're looking for max divisions

btw it's the same no matter how many lines 5 lines would be

5*4-1

Thats what I had, but it is not correct. Example:

1 line: (1 * (1-1)) - 1 = -1, but 2 is correct
2 lines: (2 * (2-1)) - 1 = 1, but 4 is correct
3 lines: (3 * (3-1)) - 1 = 5, but 7 is correct

The problem is you need to add a different number to the previous answer.
Split lines = Pieces (Add to previous answer)
0 = 1 (0)
1 = 2 (1)
2 = 4 (2)
3 = 7 (3)
4 = 11 (4)
5 = 16 (5)
6 = 22 (6)
 

Evadman

Administrator Emeritus<br>Elite Member
Feb 18, 2001
30,990
5
81
Alright, all my math schooling has left my head. I know there is a way to do this, but all I can think of is a quick loop. So, I wrote a VB function to solve for it that works as long as you don't feed in a negitive number.
I am sure that fusetalk is gonna fubar this, but have it anyway :)

Function NumberOfCirclePieces(ByVal SplitLines as integer) as integer
  if splitlines <0 then exit function 'return zero
  Dim LoopCount as integer
  NumberOfCirclePieces = 1
  Do until splitlines = 0
     loopcount = loopcount +1
     NumberOfCirclePieces = NumberOfCirclePieces + loopcount
     splitlines = splitlines -1
  loop
end function
 

Yomicron

Golden Member
Mar 5, 2002
1,735
1
81
Evadman is right, here's my version:

for n >= 0,

f(0) = 1
f(n) = f(n-1) + n

----

int NumberOfPieces( int n )
{
if(n < 0)
reutrn -1;
if(n == 0)
return 1;
else return NumberOfPieces( n-1 ) - n;
}
 

DeRusto

Golden Member
May 31, 2002
1,249
0
86
Originally posted by: Yomicron
Evadman is right, here's my version:

for n >= 0,

f(0) = 1
f(n) = f(n-1) + n

----

int NumberOfPieces( int n )
{
if(n < 0)
reutrn -1;
if(n == 0)
return 1;
else return NumberOfPieces( n-1 ) + n;
}

 

Sahakiel

Golden Member
Oct 19, 2001
1,746
0
86
Originally posted by: Evadman
The problem is you need to add a different number to the previous answer.
Split lines = Pieces (Add to previous answer)
0 = 1 (0)
1 = 2 (1)
2 = 4 (2)
3 = 7 (3)
4 = 11 (4)
5 = 16 (5)
6 = 22 (6)
[/quote]

Given f(0) = 0 and n>=0
f(0) = 1
f(1) = f(0) + 1 = 2
f(2) = f(1) + 2 = 4
f(3) = f(2) + 3 = 7
.
.
.
f(n) = f(n-1) + n = f(n-2) + (n-1) + n = f(n-3) + (n-2) + (n-1) +n = ... = f(0) + 1 + 2 + 3 + ... + (n-1) + n
f(n) = n(n+1)/2 + 1

Hardly a solid proof, but good enough for this application.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: Sahakiel
Originally posted by: Evadman
The problem is you need to add a different number to the previous answer.
Split lines = Pieces (Add to previous answer)
0 = 1 (0)
1 = 2 (1)
2 = 4 (2)
3 = 7 (3)
4 = 11 (4)
5 = 16 (5)
6 = 22 (6)

Given f(0) = 0 and n>=0
f(0) = 1
f(1) = f(0) + 1 = 2
f(2) = f(1) + 2 = 4
f(3) = f(2) + 3 = 7
.
.
.
f(n) = f(n-1) + n = f(n-2) + (n-1) + n = f(n-3) + (n-2) + (n-1) +n = ... = f(0) + 1 + 2 + 3 + ... + (n-1) + n
f(n) = n(n+1)/2 + 1

Hardly a solid proof, but good enough for this application.[/quote]

I got the same equation too. Assuming you have a circle already maximally divided by n lines. When you add a line, it will cross all n lines and n+1 spaces. When you divide an existing space you add one space to the total region count.

f(n+1)=f(n)+n+1
f(0)=1

f(n)=1+n(n+1)/2
 

Mookow

Lifer
Apr 24, 2001
10,162
0
0
Originally posted by: Citrix
you people who do math just for fun scare me...

It's OK, just like gay people, math people can't reproduce without outside help. Give it time...


;):p