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

More By Author:

Check out these other kata created by g964

Stats:

CreatedFeb 8, 2015
PublishedFeb 8, 2015
Warriors Trained80315
Total Skips30964
Total Code Submissions149304
Total Times Completed15194
Java Completions1721
Ruby Completions713
C# Completions1002
Python Completions4665
Clojure Completions113
Haskell Completions498
JavaScript Completions3297
CoffeeScript Completions20
C++ Completions1266
PHP Completions257
Crystal Completions24
C Completions247
TypeScript Completions318
Rust Completions406
Swift Completions118
R Completions52
Shell Completions22
OCaml Completions27
Elixir Completions62
F# Completions40
Julia Completions40
Scala Completions147
PowerShell Completions19
Go Completions289
Nim Completions16
PureScript Completions6
Racket Completions25
Reason Completions3
Kotlin Completions122
Groovy Completions13
Dart Completions79
Lua Completions48
Pascal Completions10
Perl Completions8
Elm Completions4
D Completions5
COBOL Completions6
Erlang Completions5
Prolog Completions6
Total Stars1399
% of votes with a positive feedback rating85% of 1850
Total "Very Satisfied" Votes1399
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