UBS quant interview question

  • Thread starter Thread starter kirylm
  • Start date Start date
let the number be abcd (i.e. 1000a + 100b + 10c + d)
therefore, the condition imposed means : (10a + b) + (10c + d) = (10b + c) ====> 10a + d = 9 ( b - c)
therefore, 10a + d should be a number (one or 2 digit) divisible by 9 ====> it can be 9, 18, 27, 36, 45, 54, 63, 72 and 81
while the corresponding b-c should be 1,2, 3, 4, 5, 6, 7, 8 and 9

now we can write the digits down using this information e.g. for ab= 18, the combinations are 1978, 1868, 1758, 1648, 1538, 1428, 1318, 1208

the total number of such answers = 1+2+...+9=45

(excluding 0000 of course)
 
I guess I'm a year too late, but as part of my interview preparation process I've been searching for difficult quant questions and brainteasers to attempt. So I'll have a 'go' at this question:

Let the number in question be N = 1000w + 100x + 10y + z, where, w, x, y and z are single digit non-negative integers.

=> 10w + x + 10y + z = 10x + y
=> 10w + z = 9(x - y) (1)

Note that 10w + z should be

- strictly positive
- divisible by 9
- less than 100

Thus
w + z = 9 (2)

Combining (1) and (2) to eliminate w gives

10(9 - z) + z = 9(x - y)
=> 90 - 9z = 9(x - y)
=> x - y + z = 10 (3)

I think equations (2) and (3) give the formula, for if I choose, for example, z = 2, then from equation (2), w = 7, moreover from equation (3), I require any pair of single digit non-negative integers, x and y, such that x - y = 8, so I have either x = 8, y = 0, giving me 7802, or x = 9, y = 1, giving me 7912.
 
Let N = 1000 a + 100 b + 10 c + d
The condition translates to the following equation
10 a + b + 10 c + d = 10 b +c

=> 10 (a - b + c ) = -b +c - d
=> (-b+c-d) is a multiple of 10
On the other hand -18 =< -b+c-d <= 9 (since 0<= b, c, d <=9)

Three possible solutions

  1. -b+c-d=0 => a-b+c=0 => a=d=0 and b=c => 0000, 0110, 0220, 0330, 0440, 0550, 0660, 0770, 0880, 0990
  2. -b+c-d=10 =>a-b+c=1 => -a-d=9 impossible since a, b >= 0
  3. -b+c-d=-10 =>a-b+c=-1 => a+d=9
    • a=0, d=9 => c=b-1 => 0109, 0219, 0329, 0439, 0549, 0659, 0769, 0879, 0989
    • a=1, d=8 => c=b-2 => 1208, 1318, 1428, 1538, 1648, 1758, 1868, 1978
    • a=2, d=7 => c=b-3 => 2307, 2417, 2527, 2637, 2747, 2858, 2967
    • a=3, d=6 => c=b-4 => 3406, 3516, 3626, 3736, 3846, 3956
    • a=4, d=5 => c=b-5 => 4505, 4615, 4725, 4835, 4945
    • a=5, d=4 => c=b-6 => 5604, 5714, 5824, 5934
    • a=6, d=3 => c=b-7 => 6703, 6813, 6923
    • a=7, d=2 => c=b-8 => 7802, 7912
    • a=8, d=1 => c=b-9 => 8901
 
If we were asked questions like this one, can we just propose a simple algorithm as response ?

for (int i=1000;i<10000;i++)
{
if(i/100+i%100==(i/10)%100)
cout<<i<<'\t';
}
 
Back
Top Bottom