5 kyu
Common Denominators
1,725 of 15,284g964
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 | 80602 |
Total Skips | 31076 |
Total Code Submissions | 149929 |
Total Times Completed | 15284 |
Java Completions | 1725 |
Ruby Completions | 715 |
C# Completions | 1006 |
Python Completions | 4699 |
Clojure Completions | 113 |
Haskell Completions | 501 |
JavaScript Completions | 3310 |
CoffeeScript Completions | 20 |
C++ Completions | 1275 |
PHP Completions | 260 |
Crystal Completions | 24 |
C Completions | 252 |
TypeScript Completions | 321 |
Rust Completions | 411 |
Swift Completions | 119 |
R Completions | 52 |
Shell Completions | 23 |
OCaml Completions | 28 |
Elixir Completions | 62 |
F# Completions | 40 |
Julia Completions | 40 |
Scala Completions | 147 |
PowerShell Completions | 19 |
Go Completions | 292 |
Nim Completions | 16 |
PureScript Completions | 6 |
Racket Completions | 26 |
Reason Completions | 3 |
Kotlin Completions | 126 |
Groovy Completions | 13 |
Dart Completions | 83 |
Lua Completions | 48 |
Pascal Completions | 10 |
Perl Completions | 9 |
Elm Completions | 4 |
D Completions | 5 |
COBOL Completions | 6 |
Erlang Completions | 5 |
Prolog Completions | 6 |
Total Stars | 1404 |
% of votes with a positive feedback rating | 85% of 1853 |
Total "Very Satisfied" Votes | 1402 |
Total "Somewhat Satisfied" Votes | 339 |
Total "Not Satisfied" Votes | 112 |