Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      48 of 130

      Darts at a square

      A lake sits on a square map, and its shape has no formula. Darts were thrown at random, evenly over the whole map, and for each one you know whether it landed in the lake. Write estimate_area(darts, square, lake): the lake’s estimated area, in the map’s units squared (km² for a map measured in km).

      A lake on a 2 km by 2 km map, with no formula for its shape. Darts land at random all over the map, and some land in the water. Counting them isn’t the area: the count can be bigger than the whole map. The goal is the lake’s area in km², from the darts alone. Your estimate_area() works it out.

      A lake on a 2 km by 2 km map. No formula gives its area.02 km2Mill lakethe map: 2 km × 2 km = 4 km²darts thrown: 100in the lake: 52
      Your functionestimate_area(darts, square, lake)
      dartswhere each dart landed, [x, y] on the map (a list of pairs)e.g. [[0.131, 0.31], [0.942, 0.755], [0.615, 0.…
      squarethe map's side length, e.g. 2 for a 2 km by 2 km mape.g. 1
      lake1 if that dart landed in the lake, else 0 (a list, one per dart)e.g. [1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1,…
      returnsthe lake's estimated area, e.g. 2.5 (km² on a map measured in km)
      solution.pyLoading Python
      Sign in for an AI hint
      ← Why sums look like bellsWhere does the weather settle? →