puzzles/edge-telemetry/challenge.md

1.3 KiB

THIS CHALLENGE GENERATED BY CHATGPT

Edge Telemetry

Problem Overview:

You are developing software for an edge device that collects power usage data from sensors at periodic intervals. The device has limited memory, so you need to design a system that efficiently stores recent data, compresses it, and manages memory effectively. The goal is to minimize the amount of memory used while ensuring that the telemetry data is still accessible and compressed.

Requirements:

Data Structure: You will be given a list of telemetry readings, each consisting of a timestamp and power usage value. You need to store the readings in a compressed form, using Run-Length Encoding (RLE).

Memory Management: The device has a limited memory capacity of N readings. If the number of readings exceeds this limit, the oldest readings should be discarded to make room for the new data.

Compression: Use Run-Length Encoding (RLE) to compress consecutive identical readings. This will reduce the amount of memory needed for storing repeated values.

API:

add_reading(timestamp, power_usage): Adds a new telemetry reading and compresses the data using RLE.

get_compressed_data(): Returns the compressed data as a list of tuples, where each tuple contains the power usage value and the count of consecutive occurrences.

END LLM GENERATED CONTENT