# Fractures **by [Robert Leckenby](https://github.com/zabamund)** You will receive a [JSON](https://www.json.org/json-en.html) string containing an array of records. The records represent fractures mapped from a planar, horizontal outcrop. Each record represents one fracture and looks like this: ```python {"survey": "DGPS", "coords": [65.371, 28.593, 130.629, 47.407], "is_open": true} ``` Notice that each fracture has the following attributes: - **survey** — either a differential GPS survey (`'DGPS'`) or based on airborne imagery (`'SRVY'`). - **coords** — a list of `x1, y1, x2, y2` coordinates in metres for each fracture. The point (x1, y1) represents one end of the fracture, and (x2, y2) represents the other. - **is_open** — indicating whether the fracture is open or sealed. **Considering only the fractures measured with DGPS**, answer the following questions: 1. How many open fractures are there? 2. Of these open fractures, how many are strictly longer than 10 m? 3. These longer, open fractures fall into two orientation clusters. What is the product of the number of fractures in the two clusters? The data you get from `requests` is a `str` in JSON format. You can convert JSON into a Python data structure using the [`json`](https://docs.python.org/3/library/json.html) built-in library. For example, `json.loads('[1, 2, 3]')` results in a Python `list`. ## Example Here is a small example dataset: ``` {"fractures": [{"survey": "DGPS", "coords": [ 65.371, 28.593, 130.629, 41.407], "is_open": true}, {"survey": "SRVY", "coords": [ 34.704, -14.876, 47.296, -3.124], "is_open": true}, {"survey": "DGPS", "coords": [-57.088, 42.648, -48.912, 37.352], "is_open": false}, {"survey": "DGPS", "coords": [-66.568, -70.693, 63.432, -69.307], "is_open": true}, {"survey": "DGPS", "coords": [-42.117, 60.92, -39.215, 59.717], "is_open": true}, {"survey": "DGPS", "coords": [-87.201, 93.463, -88.799, -92.537], "is_open": true}, ], "meta_data": {"survey_date": "2013-06-29", "surveyor": "AcmeSurveying"}, } ``` You'll have many more fractures than this small example. Here's how we'd answer the questions for this example data set: 1. In this dataset, there are **4** `open` fractures surveyed with `'DGPS'`. 2. There are **3** such fractures that are longer than 10 m. 3. The product of fracture counts the two orientations is 2 × 1 = **2**. ## A quick reminder how this works This document is formatted in [Markdown](https://daringfireball.net/projects/markdown/). You can retrieve your data, which is always a string, by choosing a **``** (also a string). This ensures that you have different data from other people, so be creative. ``` url = 'https://kata.scienxlab.org/challenge/fractures' params = { 'key': # Replace with your own string. } r = requests.get(url, params) r.text ``` To answer question 1, change the `params`: ``` params = { 'key': , # Use the same key you used to get your input. 'question': 1, 'answer': 1234 # Your answer; can be a float, int, list or array; # the challenge description will tell you which. } ``` To get a hint for a question, provide the question number but no answer: ``` params = { 'question': 1, } ``` [Complete instructions at kata.scienxlab.org](https://kata.scienxlab.org/challenge) [An example notebook to get you started](https://gist.github.com/kwinkunks/50f11dac6ab7ff8c3e6c7b34536501a2) ---- © 2024 [Scienxlab](https://scienxlab.org/) — Code: openly licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) — Text: openly licensed under [CC BY](https://creativecommons.org/licenses/by/4.0/).