Discrete Maths/Logic question


Maybe this falls a bit out of ambit of Codechef, but, a colleague at my university has a certain problem he was shown and he hasn’t been able to find any solution for it so far…

We have to design a discrete function f(N), where N goes from 1 to 12582909 (very specific upper limit, maybe its a hint), that for each N will associate a vector of 10 elements that respects the conditions:

  1. first entry goes from 1 to 9;

  2. Second and remaining entries go from 0 to 4;

  3. If value at the nth position is 0, all further entries are also 0;

So 1040000000 is not a valid vector, for example…

I wonder is hashing, some strange transform or domain reduction can be used somehow…Any ideas?



Why not represent it as (first digit)+20*(number of 0s at the end)+200*(the remaining digits -1 in base 3)? It’s at most something like 10+2010+2003**9, which fits comfortably.

So for example 58 would be: 5+20x8+200x21 = 4265? Or am I missing something? Because this violates property 2