5 kyu
Common Denominators
147 of 15,194g964
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 | 80315 |
Total Skips | 30964 |
Total Code Submissions | 149304 |
Total Times Completed | 15194 |
Java Completions | 1721 |
Ruby Completions | 713 |
C# Completions | 1002 |
Python Completions | 4665 |
Clojure Completions | 113 |
Haskell Completions | 498 |
JavaScript Completions | 3297 |
CoffeeScript Completions | 20 |
C++ Completions | 1266 |
PHP Completions | 257 |
Crystal Completions | 24 |
C Completions | 247 |
TypeScript Completions | 318 |
Rust Completions | 406 |
Swift Completions | 118 |
R Completions | 52 |
Shell Completions | 22 |
OCaml Completions | 27 |
Elixir Completions | 62 |
F# Completions | 40 |
Julia Completions | 40 |
Scala Completions | 147 |
PowerShell Completions | 19 |
Go Completions | 289 |
Nim Completions | 16 |
PureScript Completions | 6 |
Racket Completions | 25 |
Reason Completions | 3 |
Kotlin Completions | 122 |
Groovy Completions | 13 |
Dart Completions | 79 |
Lua Completions | 48 |
Pascal Completions | 10 |
Perl Completions | 8 |
Elm Completions | 4 |
D Completions | 5 |
COBOL Completions | 6 |
Erlang Completions | 5 |
Prolog Completions | 6 |
Total Stars | 1399 |
% of votes with a positive feedback rating | 85% of 1850 |
Total "Very Satisfied" Votes | 1399 |
Total "Somewhat Satisfied" Votes | 339 |
Total "Not Satisfied" Votes | 112 |