Intersection of Circles

For given two circles c1 and c2, print:
4 if they do not cross (there are 4 common tangent lines),
3 if they are circumscribed (there are 3 common tangent lines),
2 if they intersect (there are 2 common tangent lines),
1 if a circle is inscribed in another (there is 1 common tangent line),
0 if a circle includes another (there is no common tangent line).

Input
Coordinates and radii of c1 and c2 are given in the following format:
c1x c1y c1r
c2x c2y c2r
c1x, c1y, and c1r represent the center coordinate and radius of the first circle.
c2x, c2y, and c2r represent the center coordinate and radius of the second circle.
All input values are given in integers.

Output
Print "4", "3", "2", "1", or "0" in a line.

Constraints
-1000 ≤ c1x, c1y, c2x, c2y ≤ 1000
1 ≤ c1r, c2r ≤ 1000
c1 and c2 are different.

Sample Input 1
1 1 1
6 2 2

Sample Output 1
4

Sample Input 2
1 2 1
4 2 2

Sample Output 2
3

Sample Input 3
1 2 1
3 2 2

Sample Output 3
2

Sample Input 4
0 0 1
1 0 2

Sample Output 4
1

Sample Input 5
0 0 1
0 0 2

Sample Output 5
0

# Buggy version:

cx1, cy1, r1 = map(float, raw_input().split())
cx2, cy2, r2 = map(float, raw_input().split())

import math
distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )
rsum = r1 + r2
rmax = math.max(r1, r2)
rmin = math.min(r1, r2)

import sys
if distance > rsum:
  print(4)
elif abs(distance - rsum) < sys.float_info.epsilon:
  print(3)
else:
  if rmax < distance + rmin:
    print(2)
  elif abs(rmax - distance - rmin) < sys.float_info.epsilon:
    print(1)
  else:
    print(0)


# Fixed version:

cx1, cy1, r1 = map(float, input().split())
cx2, cy2, r2 = map(float, input().split())

import math
distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )
rsum = r1 + r2
rmax = max(r1, r2)
rmin = min(r1, r2)

import sys
if distance > rsum:
  print(4)
elif abs(distance - rsum) < sys.float_info.epsilon:
  print(3)
else:
  if rmax < distance + rmin:
    print(2)
  elif abs(rmax - distance - rmin) < sys.float_info.epsilon:
    print(1)
  else:
    print(0)

# Buggy version:
# Intersection of Circles
import math

class Circle:
    def __init__(self, x, y, r):
        self.x = x
        self.y = y
        self.r = r

def Exchange(c1, c2):
    return list((c2, c1))

data = list(map(int, input("Please enter the value of c1: ").split()))
c1 = Circle(data[0],data[1],data[2])

data = list(map(int, input("Please enter the value of c2: ").split()))
c2 = Circle(data[0],data[1],data[2])

if c1.r < c2.r:
    [c1, c2] = Exchange(c1, c2)
 
d = math.sqrt((c1.x - c2.x)**2 + (c1.y - c2.y)**2)

if d > c1.r + c2.r:
    print(4)
elif d == c1.r + c2.r:
    print(3)
elif c1.r - c2.r < d and d < c1.r + c2.r:
    print(2)
elif d == c1.r - c2.r:
    print(1)
elif d < c1.r - c2.r:
    print(0)



# Fixed version:
# Intersection of Circles
import math

class Circle:
    def __init__(self, x, y, r):
        self.x = x
        self.y = y
        self.r = r

def Exchange(c1, c2):
    return list((c2, c1))

data = list(map(int, input("").split()))
c1 = Circle(data[0],data[1],data[2])

data = list(map(int, input("").split()))
c2 = Circle(data[0],data[1],data[2])

if c1.r < c2.r:
    [c1, c2] = Exchange(c1, c2)
 
d = math.sqrt((c1.x - c2.x)**2 + (c1.y - c2.y)**2)

if d > c1.r + c2.r:
    print(4)
elif d == c1.r + c2.r:
    print(3)
elif c1.r - c2.r < d and d < c1.r + c2.r:
    print(2)
elif d == c1.r - c2.r:
    print(1)
elif d < c1.r - c2.r:
    print(0)

# Buggy version:
import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

if d > c1r + c2r:
    print(4)
elif d == c1r + c2r:
    print(3)
elif d + c1r > c2r or d + c2r > c1r:
    print(2)
elif d + c1r == c2r or d + c2r == c1r:
    print(1)
else:
    print(0)



# Fixed version:
import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

bcr = 0
scr = 0

if c1r > c2r:
    bcr = c1r
    scr = c2r
else:
    bcr = c2r
    scr = c1r


if d > bcr + scr:
    print(4)
elif d == bcr + scr:
    print(3)
elif d + scr > bcr:
    print(2)
elif d + scr == bcr:
    print(1)
else:
    print(0)