Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- require 'csv'
- x, y = [], []
- cnt = 0
- CSV.foreach("triangles.txt") {|row|
- x = [row[0], row[2], row[4]].map(&:to_i)
- y = [row[1], row[3], row[5]].map(&:to_i)
- cnt += 1 if [x[0]*y[1]-y[0]*x[1],
- x[1]*y[2]-y[1]*x[2],
- x[2]*y[0]-y[2]*x[0]].map {|e| e >= 0 ? true : false }.uniq.size == 1
- }
- p cnt
Add Comment
Please, Sign In to add comment