In the vast expanse of the Galaxia Nebulae, a rare phenomenon is about to occur in the Lumoria star system. The planets, revolving around the Lumorian Sun, are aligning in a celestial dance that happens only once every few millennia. This alignment has a unique effect on how the light from the Lumorian Sun reaches each planet.
Your task is to calculate the intensity of light each planet receives during this alignment. Given the distances of the planets from the Lumorian Sun and their relative positions, determine which planets might experience a decrease in light intensity due to other planets casting shadows on them.
- Planetary Data:
Planet Name | Distance (AU) | Size (km) |
---|---|---|
Mercuria | 0.4 | 4879 |
Earthia | 1 | 12742 |
Marsia | 1.5 | 6779 |
Venusia | 0.7 | 12104 |
The planets aren't sorted by their distance from the Lumorian Sun so you'll need to handle that.
- Light Dynamics:
- If a smaller planet is behind a larger planet (relative to the Lumorian Sun), it will be in the shadow and will receive no light (
None
). - If a larger planet is behind a smaller planet (relative to the Lumorian Sun), it will have
Partial
light. - If a planet is in the shadow of multiple planets, it will be marked as
None (Multiple Shadows)
. - If two planets are of similar size and are near each other in alignment, they might partially eclipse each other, but for simplicity, you can consider them both to receive full light.
- Output:
- Your system should output a list of planets and the light intensity they receive:
Full
,Partial
,None
, orNone (Multiple Shadows)
.
- Your system should output a list of planets and the light intensity they receive:
- Use GitHub Copilot and write the simulation in any language you'd like.
- Focus on clear and concise code that handles planet checks efficiently. Ask GitHub Copilot/Chat, "How can I make this code more readable and maintainable?".
- Creating a visual SVG representation for the planets is optional but encouraged if you have time.
- Use a console application to render the output.
- Sort the list of planets based on their distance from the Lumorian Sun.
- Traverse the sorted list of planets.
- For each planet, check the planets that are closer to the Lumorian Sun to see if they cast a shadow on other planets.
- Output the light intensity each planet receives.
- 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
lumoria
and add a file namedapp.js
. - Python: Create a folder called
lumoria
and add a file namedapp.py
. - C#: Create a folder called
lumoria
and rundotnet new console
.
- JavaScript: Create a folder called
First, you're going to need to get the planets into a data structure that you can work with.
-
Copy the Markdown table shown earlier.
-
Open the GitHub Copilot Chat view and enter the following text. Substitute your language of choice for "JavaScript".
turn this markdown list into a JavaScript array of objects
-
Paste the Markdown table under your comment and press ENTER
-
Insert the generated planets array into your code.
// light intensity array
// traverse the sorted array
// create an object to track the count of Larger and Smaller planets that are closer to the sun than the current planet
// for all the planets that come before this planet in the planets array, increment Larger if they are larger than the current planet or Smaller if they are smaller than the current planet
// if count.larger === 0 and count.smaller === 0 push planet name and "Full" to lightIntensity
// if count.smaller > 0 and count.larger === 0 push planet name and "Partial" to lightIntensity
// if count.larger === 1 push planet name and "None" to lightIntensity
// if count.larger > 1 push planet name and "None (Multiple Shadows)" to lightIntensity
// print the lightIntensity array
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.