Printer Errors
Description:
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:
s="aaabbbbhaijjjm"
printer_error(s) => "0/14"
s="aaaxbbbbyyhwawiwjjjwwm"
printer_error(s) => "8/22"
Similar Kata:
Stats:
Created | Nov 24, 2015 |
Published | Nov 24, 2015 |
Warriors Trained | 299991 |
Total Skips | 43768 |
Total Code Submissions | 453003 |
Total Times Completed | 163677 |
Ruby Completions | 4495 |
Python Completions | 58104 |
JavaScript Completions | 48722 |
CoffeeScript Completions | 55 |
C# Completions | 9710 |
Java Completions | 17065 |
Haskell Completions | 1287 |
Clojure Completions | 361 |
Elixir Completions | 516 |
TypeScript Completions | 2739 |
C++ Completions | 6648 |
PHP Completions | 3965 |
Crystal Completions | 43 |
F# Completions | 167 |
C Completions | 2677 |
Shell Completions | 444 |
OCaml Completions | 65 |
Groovy Completions | 130 |
NASM Completions | 26 |
Julia Completions | 115 |
Go Completions | 2639 |
R Completions | 243 |
Kotlin Completions | 1634 |
PowerShell Completions | 216 |
Nim Completions | 42 |
Reason Completions | 21 |
Racket Completions | 50 |
Rust Completions | 1914 |
Scala Completions | 431 |
Dart Completions | 878 |
Swift Completions | 1274 |
Haxe Completions | 17 |
Raku Completions | 17 |
Pascal Completions | 58 |
Perl Completions | 57 |
Elm Completions | 18 |
COBOL Completions | 12 |
D Completions | 17 |
Erlang Completions | 22 |
Total Stars | 1773 |
% of votes with a positive feedback rating | 89% of 13531 |
Total "Very Satisfied" Votes | 10909 |
Total "Somewhat Satisfied" Votes | 2384 |
Total "Not Satisfied" Votes | 238 |