#C14837. Weather Data Summary

    ID: 44530 Type: Default 1000ms 256MiB

Weather Data Summary

Weather Data Summary

You are given a JSON array representing the weather statistics of consecutive days. Each element in the array is a JSON object containing the following fields:

  • date (a string representing the date, e.g. "2023-01-01")
  • temperature (a number representing the temperature on that day)
  • humidity (an integer representing the humidity percentage)
  • wind_speed (a number representing the wind speed)

Your task is to compute a summary of the weather data with the following outputs:

  • The average temperature over all days (rounded to two decimals).
  • The date on which the humidity was highest (if there are ties, choose the first occurrence in the array).
  • The total wind speed accumulated over all days (rounded to one decimal place).
  • </p>

    Note: The input is provided via stdin as a JSON string and your output should be printed to stdout in JSON format.

    inputFormat

    The input is a single JSON array (read from standard input) where each element is a JSON object with the following keys: date (string), temperature (number), humidity (integer) and wind_speed (number). You can assume that the array contains at least one element.

    outputFormat

    The output should be a JSON object (printed to standard output) containing the following keys:

    • average_temperature: the average of all temperatures rounded to two decimals (in LaTeX: \(\text{average} = \round(\frac{\sum temperature}{n}, 2)\)).
    • highest_humidity_day: the date corresponding to the highest humidity.
    • total_wind_speed: the sum of all wind speeds rounded to one decimal place (in LaTeX: \(\text{total} = \round(\sum wind\_speed, 1)\)).
    ## sample
    [
      {"date": "2023-01-01", "temperature": 10.5, "humidity": 80, "wind_speed": 5.5},
      {"date": "2023-01-02", "temperature": 12.3, "humidity": 78, "wind_speed": 6.1},
      {"date": "2023-01-03", "temperature": 8.8, "humidity": 82, "wind_speed": 4.0},
      {"date": "2023-01-04", "temperature": 7.5, "humidity": 85, "wind_speed": 3.8},
      {"date": "2023-01-05", "temperature": 9.0, "humidity": 80, "wind_speed": 4.5},
      {"date": "2023-01-06", "temperature": 11.2, "humidity": 79, "wind_speed": 5.2},
      {"date": "2023-01-07", "temperature": 10.0, "humidity": 81, "wind_speed": 5.0}
    ]
    {"average_temperature":9.9,"highest_humidity_day":"2023-01-04","total_wind_speed":34.1}