id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

calculateOverlaps


Problem: Hydrothermal Vent Mapping

Problem Description: You're continuing your deep-sea exploration and come across a dense field of hydrothermal vents. These vents release plumes of hot water and are often aligned in straight lines across the ocean floor. To ensure safe navigation, the submarine's sonar system has identified the locations of these vent lines.

The submarine provides a list of vent lines as coordinates. Each vent line is defined by its start and end points in the form x1,y1 -> x2,y2.

Task: To minimize risk, you need to calculate the number of points where at least two vent lines overlap. For simplicity, only consider horizontal and vertical lines (lines where x1 = x2 or y1 = y2).


calculateOverlaps(["0,1 -> 5,1", "2,2 -> 2,4", "4,4 -> 4,1", "1,0 -> 1,3", "5,0 -> 5,3"]) → 3
calculateOverlaps(["0,0 -> 2,0", "1,1 -> 1,4", "3,3 -> 3,6", "2,2 -> 4,2", "5,0 -> 5,5"]) → 0
calculateOverlaps(["0,1 -> 4,1", "3,0 -> 3,3", "1,3 -> 1,5", "5,2 -> 0,2", "4,4 -> 4,0"]) → 4

...Save, Compile, Run (ctrl-enter)

public int calculateOverlaps(List<String> ventLines) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy