In the mechanical town of Tempora, everything operates on clockwork and precise timing. At the heart of the town is the Grand Clock Tower, responsible for keeping time for all the town's activities. However, over the years, some smaller clocks in the town have started to drift away from the accurate time.
Your task is to create a system that checks all the clocks in the town and synchronizes them with the Grand Clock Tower. You'll be given a list of times from various clocks around the town, and you must determine how many minutes each clock is ahead or behind the Grand Clock Tower's time.
-
Clock Data:
- The clock times are provided in a 24-hour format.
- The Grand Clock Tower is at 15:00.
- Clock times around town:
- Clock 1: 14:45
- Clock 2: 15:05
- Clock 3: 15:00
- Clock 4: 14:40
-
Time Analysis and Output:
- You need to determine how many minutes each clock is ahead or behind the Grand Clock Tower.
- The result should be an array of integers representing the time difference in minutes. Positive values indicate the clock is ahead, and negative values indicate it's behind.
- Use GitHub Copilot and write the simulation in any language you'd like.
- Focus on clear and concise code. Ask GitHub Copilot/Chat, "How can I make this code more readable and maintainable?".
- Creating a visual representation for the clocks is optional but encouraged if you have time.
- Use a console application to render the output.
- Parse the time data for each clock and the Grand Clock Tower.
- Calculate the difference in minutes between each clock and the Grand Clock Tower.
- Output the list of time differences.
- If you're using a GitHub Codespace, you're ready to go!
- If running locally, ensure that you have your target language/framework installed.
- Create a folder for your code.
- JavaScript: Create a folder called
tempora
and add a file namedapp.js
. - Python: Create a folder called
tempora
and add a file namedapp.py
. - C#: Create a folder called
tempora
and rundotnet new console
.
- JavaScript: Create a folder called
See if you can use Copilot to find out the complexity (BigO notation) of the code.
-
Open the GitHub Copilot Chat view in the sidebar if it's not already open. Make sure your solution file is still open as well.
-
Ask Copilot Chat what the complexity of the code is.
-
Ask Copilot Chat to make the code more efficient.
-
Ask for the complexity again - is it better?
-
Highlight all of the code with Ctrl/Cmd+A.
-
Press Ctrl/Cmd+I to open the inline chat.
-
Type "/doc"
-
Ask Copilot Chat to document the function.
-
Open GitHub Copilot Chat in the sidebar.
-
Type "/simplify" and press Enter. You can also add any text you want after the "/simplify" to give Copilot more instructions.
-
What did Copilot Chat suggest you do to make it simpler?
Copilot Chat can help with that too! Just copy the error message and paste it into Chat. Often that's all Copilot needs to resolve your issue.