When working on a mobile app developed with Xamarin Forms ( if you aren’t, you’re missing all the fun! ) you might have your own awesome separate library project of custom controls, effects, behaviors, value-converters, constants: You’ve might not been very happy ( to put it nicely ) how you're using your library objects in your app’s XAML, having to deal with all the different XML namespaces and prefixes: So many prefixes and namespaces to handle! Yikes! The issue is not just about declaration of prefixes. Having separate prefixes bloats the XAML a lot because you have to use a separate prefix for every object you reference from the corresponding namespace. In my example there are 4 prefixes to deal with! As a solution to get rid of all the namespaces, a dark thought might have crossed your mind: remove all the CLR namespaces in the library’s code and just have one namespace! But you love your C# namespaces, they give class scope and separation, it’s...
solution:
ReplyDeletelet the number be like this:
xn..x2x1x0y
where xn .. x2, x1, x0 are the number digits
Sum (xi * 10^i) + 9999 = Sum (xi * 10^(i+1)) + y, where i = 0..n
this gives:
9 * Sum(xi * 10^i) + y = 9999
now, y can be 0,1,2, .. 9
which means that
Sum(xi * 10^i) = 9999 / 9, 9998 / 9, 9997 / 9, ... 9990 / 9
but Sum must be integer since xi is integer also, hence
999z / 9, z = 0..9 must be integral
so we need to check all 9 ratios
actually its simpler(aratare!) if u divide
ReplyDelete9 * Sum(xi * 10^i) + y = 9999
by 9
and u get
Sum(xi * 10^i) + y/9 = 1111
y can be 0 or 9 ;)
Problem #2:
ReplyDeleteThe bridge
Three people (A, B, and C) need to cross a bridge. A can cross the bridge in 10 minutes, B can cross in 5 minutes, and C can cross in 2 minutes. There is also a bicycle available and any person can cross the bridge in 1 minute with the bicycle. What is the shortest time that all men can get across the bridge? Each man travels at their own constant rate.
I didn't solve this problem.
Hint: if you know that d = v * t then everything is easy :|
Solution to problem #2
ReplyDelete----------------------
The bicycle can be left at any place on the bridge and can be used in both directions on the bridge.
The steps are:
B and C walk by foot and A take the bicycle.
A at one place (y) can leave the bicycle and finish the way by foot.
C can take the bicycle, drives it back to a point (x), leaves it and continues to walk by foot.
B takes the bicycle and drives it all the way.
The equations are:
A: 1*y + 10*(1-y)
B: 5*x + 1*(1-x)
C: 2*y + (y-x) + 2*(1-x)
The system becomes:
10 - 9y = -3x + 3y + 2 = 4x + 1
Solve each equality:
10 - 9y = -3x + 3y + 2 -> 3x - 12y = -8
10 - 9y = 4x + 1 -> 4x + 9y = 9
After solving the equations:
x = 12/25, y=59/75.
It meas that it takes 73/25 = 2.92 minutes to cross the bridge.
A speed = 1/10
B speed = 1/5
C speed = 1/2
(bicycle speed is 1)
Problem #3:
ReplyDeleteYou have 2 buckets with water, 7 and 4 litre.
How can you measure 1 litre using these buckets ?
Solution to problem #3
ReplyDelete----------------------
Fill the 4 litre bucket then fill the 7 litre bucket with it completely.
Now you have 3 litre left in the 7 litre bucket.
Again, fill the 4 litre bucket and fill the remaining 3 litre from the 7 litre bucket.
What you have left in the 4 litre bucket is 1 litre.
problem #4:
ReplyDeleteexchange 2 variables without using any intermediate value.