15
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractions and improper fractions.
Given a mixed fraction, determine if it is equivalent to the improper fraction where the integer value and the numerator are concatenated together. For example, for input 1 3/4
, the improper fraction is 13/4
.
Test Cases
1 3/4 -> falsey
1 3/10 -> truthy
6 6/7 -> falsey
55 55/100 -> truthy
4 9/100 -> falsey
40 9/100 -> falsey
7 49/1000 -> falsey
9 1/2 -> falsey
999 999/1000 -> truthy
1 21/200 -> falsey
1 21/101 -> falsey
For input, you may take the integer part and the fraction part as separate inputs, but you may not take the fraction as input in two pieces, and you may not take it as a decimal value. You may drop the integer part (not take it as input) if you do not need to use it.
Should or can the fraction be simplified? Like the fourth test case would be false as
54/100
simplifies to27/50
– Jo King – 2018-07-24T22:45:58.6871Should output be two distinct, consistent values or any, possibly inconsistent, truthy/falsey values? – Luis Mendo – 2018-07-24T22:53:56.253
@JoKing no, and I will fix that one, should both be 55 – Stephen – 2018-07-24T23:15:12.167
@LuisMendo whatever meta defines as truthy falsey – Stephen – 2018-07-24T23:15:37.130
This is probably inherent in the definition of mixed fractions, but just to confirm: can we assume that the fraction part of the input will have its numerator less than the denominator? – sundar - Reinstate Monica – 2018-07-24T23:25:45.827
1By the way, fixing the 4th test case to have 55 wouldn't change the issue would it -
55/100
can also be simplified to11/20
, so the same question @JoKing raised arises there. – sundar - Reinstate Monica – 2018-07-24T23:44:00.243@sundar I think it was two separate statements: "No simplification involved" and "I made a typo, I'll fix that" – Οurous – 2018-07-24T23:46:48.573
So the second argument must be taken as a string? – dylnan – 2018-07-24T23:49:12.653
3"you may not take the fraction as input in two pieces" - err why? That is exactly what the
/
does :/ – Jonathan Allan – 2018-07-24T23:54:10.78711This seems to be equivalent to "given an input that doesn't matter and two numbers as a string separated by a slash, determine whether the second number equals 10 to the power of the length of the first number". – xnor – 2018-07-25T00:15:00.453
@sundar Yes, you can assume that, the fraction part will be proper. As Ourous said, no simplification involved. – Stephen – 2018-07-25T01:07:53.580
@JonathanAllan the idea is that you remove the space and see if it is still equal - yes you can basically do what xnor described in his comment, but I'm not going to just give you two integers – Stephen – 2018-07-25T01:09:56.357
This is probably also inherent in the definition of mixed fractions, but can we assume that the integer part is > 0? If not, most answers are probably invalid. – wastl – 2018-07-25T13:07:49.963
@wastl yes, you can make that assumption, you can also assume the numerator is > 0 – Stephen – 2018-07-25T13:13:41.210