> For the complete documentation index, see [llms.txt](https://elixir.petrolidas.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://elixir.petrolidas.com/exhort/day-18.md).

# Day 18

## Exercises

* [x] [Captain's Log](#captains-log)

### Captain's Log

[Exercise on Exercism](https://exercism.org/tracks/elixir/exercises/captains-log) **|** [View my solution](https://exercism.org/tracks/elixir/exercises/captains-log/solutions/petros)

#### Solution

<details>

<summary>Expand to see code (spoiler alert)</summary>

{% code lineNumbers="true" %}

```elixir
defmodule CaptainsLog do
  @planetary_classes ["D", "H", "J", "K", "L", "M", "N", "R", "T", "Y"]

  @spec random_planet_class() :: String.t()
  def random_planet_class(), do: Enum.random(@planetary_classes)

  @spec random_ship_registry_number() :: String.t()
  def random_ship_registry_number(), do: "NCC-#{Enum.random(1000..9999)}"

  @spec random_stardate() :: float
  def random_stardate(), do: 41000.0 + (42000.0 - 41000.0) * :rand.uniform()

  @spec format_stardate(Float.t()) :: String.t()
  def format_stardate(stardate), do: :io_lib.format("~.1f", [stardate]) |> List.to_string()
end

```

{% endcode %}

[View gist on GitHub](https://gist.github.com/petros/f3ea94dce96faf70c87c38e6528d14f4)

</details>

#### Notes

Part of this exercise is showing you how to use Erlang libraries and functions for functionality that doesn't exist in Elixir. However, the Erlang documentation for those functions is not as digestible as Elixir's documentation.

## Overall progress

<figure><img src="/files/vodJjyd3tYEAjjXOaqfJ" alt="An image showing my progress on Exercism. It&#x27;s 20.5% as of Thursday, 25 August 2022."><figcaption><p>Progress</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://elixir.petrolidas.com/exhort/day-18.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
