import kotlin.math.abs import kotlin.math.pow import kotlin.math.sqrt const val EPSILON = 1e-6 typealias Point = Pair fun Point.x() = first fun Point.y() = second data class Line(val a: Double, val b: Double, val c: Double) { companion object { fun fromPoints(left: Point, right: Point) = when { left.x() == right.x() -> Line(1.0, 0.0, -left.x().toDouble()) left.y() == right.y() -> Line(0.0, 1.0, 0.0) else -> { val l = -(left.y() - right.y()).toDouble() / (left.x() - right.x()).toDouble() Line(l, 1.0, -l * left.x() - left.y()) } } } fun isParallel(other: Line) = abs(a - other.a) < EPSILON && abs(b - other.b) < EPSILON fun isPerpendicular(other: Line) = a / b == other.b / other.a } fun distance(a: Point, b: Point): Double = sqrt((b.x() - a.x()).toDouble().pow(2) + (b.y() - a.y()).toDouble().pow(2)) fun main() { val (a, b, c, d) = System.`in`.bufferedReader().lineSequence().take(4).map { l -> l.split(" ").take(2).map { it.toLong() }.let { (a, b) -> a to b } }.sortedWith(Comparator.comparingLong { it.x() }.thenBy { it.y() }).toList() val ab = Line.fromPoints(a, b) val ac = Line.fromPoints(a, c) val ad = Line.fromPoints(a, d) val bc = Line.fromPoints(b, c) val bd = Line.fromPoints(b, d) val cd = Line.fromPoints(c, d) return when { /* Square B D A C */ ab.isPerpendicular(ac) && ab.isPerpendicular(bd) && ac.isPerpendicular(cd) && bd.isPerpendicular(cd) -> when { distance(a, b) - distance(a, c) < EPSILON -> println("square") else -> println("rectangle") } /* B D A C B D A C B D A C B C D A */ // paralelogram ab.isParallel(cd) && ac.isParallel(bd) -> println("parallelogram") ab.isParallel(cd) && ad.isParallel(bc) -> println("parallelogram") /* Trapezium BC A D B D A D BC D B A C A C */ ad.isParallel(bc) || ab.isParallel(cd) -> println("trapezium") // rhombus (distance(a, b) - distance(b, d)) < EPSILON && (distance(a, b) - distance(d, c)) < EPSILON && (distance(a, b) - distance(a, c)) < EPSILON -> println("rhombus") /* kite C C A D A D B B Diagonal either AD or BC */ distance(a, c) - distance(c, d) < EPSILON && distance(a, b) - distance(b, d) < EPSILON -> println("kite") distance(a, b) - distance(a, c) < EPSILON && distance(c, d) - distance(b, d) < EPSILON -> println("kite") else -> println("none") } }