5 kyu
Common Denominators
3,292 of 15,167g964
Description:
Common denominators
You will have a list of rationals in the form
{ {numer_1, denom_1} , ... {numer_n, denom_n} }
or
[ [numer_1, denom_1] , ... [numer_n, denom_n] ]
or
[ (numer_1, denom_1) , ... (numer_n, denom_n) ]
where all numbers are positive ints. You have to produce a result in the form:
(N_1, D) ... (N_n, D)
or
[ [N_1, D] ... [N_n, D] ]
or
[ (N_1', D) , ... (N_n, D) ]
or
{{N_1, D} ... {N_n, D}}
or
"(N_1, D) ... (N_n, D)"
depending on the language (See Example tests) in which D is as small as possible and
N_1/D == numer_1/denom_1 ... N_n/D == numer_n,/denom_n.
Example:
convertFracs [(1, 2), (1, 3), (1, 4)] `shouldBe` [(6, 12), (4, 12), (3, 12)]
Note:
Due to the fact that the first translations were written long ago - more than 6 years - these first translations have only irreducible fractions.
Newer translations have some reducible fractions. To be on the safe side it is better to do a bit more work by simplifying fractions even if they don't have to be.
Note for Bash:
input is a string, e.g "2,4,2,6,2,8"
output is then "6 12 4 12 3 12"
Fundamentals
Algorithms
Mathematics
Similar Kata:
Stats:
Created | Feb 8, 2015 |
Published | Feb 8, 2015 |
Warriors Trained | 80162 |
Total Skips | 30937 |
Total Code Submissions | 149104 |
Total Times Completed | 15167 |
Java Completions | 1717 |
Ruby Completions | 711 |
C# Completions | 1000 |
Python Completions | 4655 |
Clojure Completions | 112 |
Haskell Completions | 496 |
JavaScript Completions | 3292 |
CoffeeScript Completions | 19 |
C++ Completions | 1262 |
PHP Completions | 255 |
Crystal Completions | 24 |
C Completions | 245 |
TypeScript Completions | 317 |
Rust Completions | 404 |
Swift Completions | 117 |
R Completions | 51 |
Shell Completions | 21 |
OCaml Completions | 26 |
Elixir Completions | 61 |
F# Completions | 39 |
Julia Completions | 39 |
Scala Completions | 146 |
PowerShell Completions | 18 |
Go Completions | 287 |
Nim Completions | 15 |
PureScript Completions | 5 |
Racket Completions | 24 |
Reason Completions | 2 |
Kotlin Completions | 121 |
Groovy Completions | 12 |
Dart Completions | 78 |
Lua Completions | 47 |
Pascal Completions | 9 |
Perl Completions | 7 |
Elm Completions | 3 |
D Completions | 4 |
COBOL Completions | 5 |
Erlang Completions | 4 |
Prolog Completions | 5 |
Total Stars | 1397 |
% of votes with a positive feedback rating | 85% of 1848 |
Total "Very Satisfied" Votes | 1397 |
Total "Somewhat Satisfied" Votes | 339 |
Total "Not Satisfied" Votes | 112 |