7 kyu

Printer Errors

4,495 of 163,677g964

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 ato z.

Examples:

s="aaabbbbhaijjjm"
printer_error(s) => "0/14"

s="aaaxbbbbyyhwawiwjjjwwm"
printer_error(s) => "8/22"
Fundamentals

Similar Kata:

More By Author:

Check out these other kata created by g964

Stats:

CreatedNov 24, 2015
PublishedNov 24, 2015
Warriors Trained299991
Total Skips43768
Total Code Submissions453003
Total Times Completed163677
Ruby Completions4495
Python Completions58104
JavaScript Completions48722
CoffeeScript Completions55
C# Completions9710
Java Completions17065
Haskell Completions1287
Clojure Completions361
Elixir Completions516
TypeScript Completions2739
C++ Completions6648
PHP Completions3965
Crystal Completions43
F# Completions167
C Completions2677
Shell Completions444
OCaml Completions65
Groovy Completions130
NASM Completions26
Julia Completions115
Go Completions2639
R Completions243
Kotlin Completions1634
PowerShell Completions216
Nim Completions42
Reason Completions21
Racket Completions50
Rust Completions1914
Scala Completions431
Dart Completions878
Swift Completions1274
Haxe Completions17
Raku Completions17
Pascal Completions58
Perl Completions57
Elm Completions18
COBOL Completions12
D Completions17
Erlang Completions22
Total Stars1773
% of votes with a positive feedback rating89% of 13531
Total "Very Satisfied" Votes10909
Total "Somewhat Satisfied" Votes2384
Total "Not Satisfied" Votes238
Ad
Contributors
  • g964 Avatar
  • NaMe613 Avatar
  • ParanoidUser Avatar
  • romerojp Avatar
  • Chrono79 Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • wneumann Avatar
  • Voile Avatar
  • rxe Avatar
  • Souzooka Avatar
  • kroppt Avatar
  • kdmatrosov Avatar
  • monadius Avatar
  • hobovsky Avatar
  • xavierguihot Avatar
  • qwertyu123 Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • dfhwze Avatar
  • KayleighWasTaken Avatar
  • shirleyquirk Avatar
Ad