From 9fa3f0252b177dddb48cba98bd1fc076006702eb Mon Sep 17 00:00:00 2001 From: Jim Infield Date: Tue, 10 Aug 2021 13:35:56 -0500 Subject: [PATCH] add README --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8204c0a --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +## Printer Errors + +In a factory a printer prints labels for boxes. For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from `a` to `m`. + +The colors used by the printer are recorded in a control string. For example a *"good"* control string would be `aaabbbbhaijjjm` meaning that the printer used three times color a, four times color b, one time color h then one time color a... + +Sometimes there are problems: lack of colors, technical malfunction and a *"bad"* control string is produced e.g. `aaaxbbbbyyhwawiwjjjwwm` with letters not from `a` to `m`. + +You have to write a function printer_error which given a string will return the error rate of the printer as a string representing a rational whose numerator is the number of errors and the denominator the length of the control string. Don't reduce this fraction to a simpler expression. + +The string has a length greater or equal to one and contains only letters from `a` to `z`. + +**Examples:** + +```rust +s = "aaabbbbhaijjjm" +printer_error(s) => "0/14" + +s = "aaaxbbbbyyhwawiwjjjwwm" +printer_error(s) => "8/22" +```