19
1
Mixed Number to an Improper Fraction
In this challenge you will be converting a mixed number to an improper fraction.
Because improper fractions use fewer numbers, your code will need to be as short as possible.
Examples
4 1/2
9/2
12 2/4
50/4
0 0/2
0/2
11 23/44
507/44
Specification
You may assume the denominator of the input will never be 0. The input will always be in the format x y/z
where x,y,z are arbitrary nonnegative integers. You do not need to simplify the output.
This is code-golf so shortest code in bytes wins.
1Related. Related. Related. (More or less. These are all about mixed fractions.) – Martin Ender – 2015-12-17T18:10:22.717
5You should add the tag "parsing". I'm sure most answers will spend more bytes on parsing the input and formatting the output than on doing the math. – nimi – 2015-12-17T18:31:32.517
3Can the output be a rational number type or does it have to be a string? – Martin Ender – 2015-12-17T18:33:00.807
@nimi Parsing isn't the primary goal of the challenge though. – Alex A. – 2015-12-17T18:33:40.077
2@AlexA.: ... but a large part of the challenge. According to it's description the tag should be used in such cases. – nimi – 2015-12-17T18:38:26.003
7Can
x
,y
andz
be negative? – Dennis – 2015-12-17T19:21:28.913@Dennis no, it can't – Downgoat – 2015-12-17T22:50:14.163
Is it okay to output
0
for the third test case? – LegionMammal978 – 2015-12-17T23:10:05.2901Is the output format strict, or is the numerator on one line and the denominator on another line acceptable (i.e., instead of a
/
between, it's a newline)? – AdmBorkBork – 2015-12-18T13:39:56.547Can we take the input as an array of ASCII values? (This is basically what strings are in C). – Esolanging Fruit – 2017-07-13T06:14:08.097
@Challenger5 If your language is natively uses pointers for strings, you can take it in as a null-terminated string (array of ascii-values) – Downgoat – 2017-07-13T06:15:13.230
@Downgoat Well it's not actually a C submission, I just added that as justification for why it should be allowed. – Esolanging Fruit – 2017-07-13T06:16:06.087
@Challenger5 If your language is JS/Python/Java/one which has a native string datatype a string is a string so you can't take an array of integers for example in those languages. – Downgoat – 2017-07-13T06:16:57.077
@Downgoat Mine has no string datatype, only arrays and numbers. – Esolanging Fruit – 2017-07-13T06:33:07.120
@Downgoat Actually, can I assume it's null terminated anyways? (This is a stretch but it's helpful for golfing) – Esolanging Fruit – 2017-07-13T07:11:36.713
2Based on the challenge I'm assuming it is, but is the input format "x y/z" mandatory, or can the space be a new-line, and/or the
x,y,z
be separated inputs? Most answers are assuming the input format is indeed mandatory to bex y/z
, but some aren't, hence this question to have a definitive answer. – Kevin Cruijssen – 2018-06-15T13:04:22.037@KevinCruijssen Well, the question body does mention The input will always be in the format
x y/z
, so I think it's mandatory (although that's not very recommended). – Erik the Outgolfer – 2018-06-16T23:01:02.067