CopilotAdventures

The Celestial Alignment of Lumoria

Background

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.

Objective

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.

Specifications

  1. 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.

  1. 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.
  2. Output:
    • Your system should output a list of planets and the light intensity they receive: Full, Partial, None, or None (Multiple Shadows).

Constraints

Summary of High-Level Tasks to Perform

  1. Use a console application to render the output.
  2. Sort the list of planets based on their distance from the Lumorian Sun.
  3. Traverse the sorted list of planets.
  4. For each planet, check the planets that are closer to the Lumorian Sun to see if they cast a shadow on other planets.
  5. Output the light intensity each planet receives.

Tips to Get Started

  1. If you’re using a GitHub Codespace, you’re ready to go!
  2. If running locally, ensure that you have your target language/framework installed.
  3. Create a folder for your code.
    • JavaScript: Create a folder called lumoria and add a file named app.js.
    • Python: Create a folder called lumoria and add a file named app.py.
    • C#: Create a folder called lumoria and run dotnet new console.

GitHub Copilot Tips

First, you’re going to need to get the planets into a data structure that you can work with.

  1. Copy the Markdown table shown earlier.
  2. 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
    
  3. Paste the Markdown table under your comment and press ENTER
  4. 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

Use Copilot to improve efficiency

See if you can use Copilot to find out the complexity (BigO notation) of the code.

  1. 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.

  2. Ask Copilot Chat what the complexity of the code is.

  3. Ask Copilot Chat to make the code more efficient.

  4. Ask for the complexity again - is it better?

Use Copilot to generate code comments

  1. Highlight all of the code with Ctrl/Cmd+A.

  2. Press Ctrl/Cmd+I to open the inline chat.

  3. Type “/doc”

  4. Ask Copilot Chat to document the function.

Use Copilot to simplify your code

  1. Open GitHub Copilot Chat in the sidebar.

  2. Type “/simplify” and press Enter. You can also add any text you want after the “/simplify” to give Copilot more instructions.

  3. What did Copilot Chat suggest you do to make it simpler?

Got Errors?

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.