// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract ArraysExercise { // Declare state variables to store arrays of numbers, timestamps, and senders uint[] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Array of numbers initialized with values uint[] timestamps; // Dynamic array to store timestamps address[] senders; // Dynamic array to store sender addresses uint256 constant Y2K = 946702800; // Constant representing the Unix timestamp for the year 2000 // Function to retrieve the array of numbers function getNumbers() external view returns (uint[] memory) { // Create a memory array to hold the numbers uint[] memory results = new uint[](numbers.length); // Copy the numbers from the state array to the memory array for(uint i=0; i Y2K) { counter++; } } // Initialize memory arrays to hold timestamps and senders after Y2K uint256[] memory timestampsAfterY2K = new uint256[](counter); address[] memory sendersAfterY2K = new address[](counter); // Initialize index for inserting elements into memory arrays uint256 index = 0; // Iterate through timestamps and senders arrays to extract elements after Y2K for (uint i = 0; i < timestamps.length; i++) { if (timestamps[i] > Y2K) { timestampsAfterY2K[index] = timestamps[i]; sendersAfterY2K[index] = senders[i]; index++; } } // Return timestamps and senders after Y2K return (timestampsAfterY2K, sendersAfterY2K); } // Function to reset the senders array function resetSenders() public { delete senders; } // Function to reset the timestamps array function resetTimestamps() public { delete timestamps; } }