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

Stats:

CreatedFeb 8, 2015
PublishedFeb 8, 2015
Warriors Trained80602
Total Skips31076
Total Code Submissions149929
Total Times Completed15284
Java Completions1725
Ruby Completions715
C# Completions1006
Python Completions4699
Clojure Completions113
Haskell Completions501
JavaScript Completions3310
CoffeeScript Completions20
C++ Completions1275
PHP Completions260
Crystal Completions24
C Completions252
TypeScript Completions321
Rust Completions411
Swift Completions119
R Completions52
Shell Completions23
OCaml Completions28
Elixir Completions62
F# Completions40
Julia Completions40
Scala Completions147
PowerShell Completions19
Go Completions292
Nim Completions16
PureScript Completions6
Racket Completions26
Reason Completions3
Kotlin Completions126
Groovy Completions13
Dart Completions83
Lua Completions48
Pascal Completions10
Perl Completions9
Elm Completions4
D Completions5
COBOL Completions6
Erlang Completions5
Prolog Completions6
Total Stars1404
% of votes with a positive feedback rating85% of 1853
Total "Very Satisfied" Votes1402
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