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

More By Author:

Check out these other kata created by g964

Stats:

CreatedFeb 8, 2015
PublishedFeb 8, 2015
Warriors Trained80162
Total Skips30937
Total Code Submissions149104
Total Times Completed15167
Java Completions1717
Ruby Completions711
C# Completions1000
Python Completions4655
Clojure Completions112
Haskell Completions496
JavaScript Completions3292
CoffeeScript Completions19
C++ Completions1262
PHP Completions255
Crystal Completions24
C Completions245
TypeScript Completions317
Rust Completions404
Swift Completions117
R Completions51
Shell Completions21
OCaml Completions26
Elixir Completions61
F# Completions39
Julia Completions39
Scala Completions146
PowerShell Completions18
Go Completions287
Nim Completions15
PureScript Completions5
Racket Completions24
Reason Completions2
Kotlin Completions121
Groovy Completions12
Dart Completions78
Lua Completions47
Pascal Completions9
Perl Completions7
Elm Completions3
D Completions4
COBOL Completions5
Erlang Completions4
Prolog Completions5
Total Stars1397
% of votes with a positive feedback rating85% of 1848
Total "Very Satisfied" Votes1397
Total "Somewhat Satisfied" Votes339
Total "Not Satisfied" Votes112
Ad
Contributors
  • g964 Avatar
  • jhoffner Avatar
  • dnolan Avatar
  • bkaes Avatar
  • kebien6020 Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • Voile Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • solitude Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
Ad