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.
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.
None
).Partial
light.None (Multiple Shadows)
.Full
, Partial
, None
, or None (Multiple Shadows)
.lumoria
and add a file named app.js
.lumoria
and add a file named app.py
.lumoria
and run dotnet new console
.First, you’re going to need to get the planets into a data structure that you can work with.
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
// 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.