Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

# Classified ```elixir Mix.install([ {:jason, "~> 1.4"}, {:kino, "~> 0.9", override: true}, {:youtube, github: "brooklinjazz/youtube"}, {:hidden_cell, github: "brooklinjazz/hidden_cell"} ]) ``` ## Navigation [Return Home](../start.livemd)<span style="padding: 0 30px"></span> [Report An Issue](https://github.com/DockYard-Academy/curriculum/issues/new?assignees=&labels=&template=issue.md&title=) ## Classified You have been hired to hide confidential information in certain documents. Confidential information should be replaced with `REDACTED`. Confidential information includes: * The words: `Peter Parker`, `Bruce Wayne`, `Clark Kent`. * Any phone number in the format: `999-999-9999`. * Any email in the format: `string@string.string`. * Any four digit codes: i.e. `4444` or `1234`. For example, <!-- livebook:{"force_markdown":true} --> ```elixir Classified.redact("Spiderman is Peter Parker.") "Spiderman is REDACTED." Classified.redact("Batman is Bruce Wayne.") "Batman is REDACTED." Classified.redact("Superman is Clark Kent.") "Superman is REDACTED." Classified.redact("Call 555-555-5555 for the secret info.") "Call REDACTED for the secret info" Classified.redact("Email super@secret.shh for the private data.") "Email REDACTED for the private data." Classified.redact("The password is 4525") "The password is REDACTED" ``` Enter your solution below. ```elixir defmodule Classified do @doc ~S""" Replaces confidential information with REDACTED in the given `string`. ## Examples iex> Classified.redact("Spiderman is Peter Parker.") "Spiderman is REDACTED." iex> Classified.redact("Call 555-555-5555 for the secret info.") "Call REDACTED for the secret info." iex> Classified.redact("Email super@secret.ssh for the private data.") "Email REDACTED for the private data." iex> Classified.redact("The password is 4525.") "The password is REDACTED." """ def redact(string) do end end ``` ## Mark As Completed <!-- livebook:{"attrs":{"source":"file_name = Path.basename(Regex.replace(~r/#.+/, __ENV__.file, \"\"), \".livemd\")\n\nprogress_path = __DIR__ <> \"/../progress.json\"\nexisting_progress = File.read!(progress_path) |> Jason.decode!()\n\ndefault = Map.get(existing_progress, file_name, false)\n\nform =\n Kino.Control.form(\n [\n completed: input = Kino.Input.checkbox(\"Mark As Completed\", default: default)\n ],\n report_changes: true\n )\n\nTask.async(fn ->\n for %{data: %{completed: completed}} <- Kino.Control.stream(form) do\n File.write!(progress_path, Jason.encode!(Map.put(existing_progress, file_name, completed)))\n end\nend)\n\nform","title":"Track Your Progress"},"chunks":null,"kind":"Elixir.HiddenCell","livebook_object":"smart_cell"} --> ```elixir file_name = Path.basename(Regex.replace(~r/#.+/, __ENV__.file, ""), ".livemd") progress_path = __DIR__ <> "/../progress.json" existing_progress = File.read!(progress_path) |> Jason.decode!() default = Map.get(existing_progress, file_name, false) form = Kino.Control.form( [ completed: input = Kino.Input.checkbox("Mark As Completed", default: default) ], report_changes: true ) Task.async(fn -> for %{data: %{completed: completed}} <- Kino.Control.stream(form) do File.write!(progress_path, Jason.encode!(Map.put(existing_progress, file_name, completed))) end end) form ``` ## Commit Your Progress Run the following in your command line from the curriculum folder to track and save your progress in a Git commit. Ensure that you do not already have undesired or unrelated changes by running `git status` or by checking the source control tab in Visual Studio Code. ``` $ git checkout solutions $ git checkout -b classified-exercise $ git add . $ git commit -m "finish classified exercise" $ git push origin classified-exercise ``` Create a pull request from your `classified-exercise` branch to your `solutions` branch. Please do not create a pull request to the DockYard Academy repository as this will spam our PR tracker. **DockYard Academy Students Only:** Notify your instructor by including `@BrooklinJazz` in your PR description to get feedback. You (or your instructor) may merge your PR into your solutions branch after review. If you are interested in joining the next academy cohort, [sign up here](https://academy.dockyard.com/) to receive more news when it is available.
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More