-2
$\begingroup$

There's a array:

array(1,2,3,...12,
1,2,3,...9,9,10,...12,
1,2,3,...12,
1,2,3,...12,
1,2,3,...6,6,7,8,...12,
1,2,3,3,4,...12,
...);

All numbers are in the range 1-12, one number maybe occur twice in the range,

The index of second number of the twice number will be such as array ( 22 => 9, 56 => 6, 66 => 3, ...);
If we get a number 16 we know the corresponding number is 4,
If we get a number 65 we know the corresponding number is 3,

How to do this in general?

The index is the when the duplicate number occur, 22 => 9 is the duplicate 9 is No. 22 ,1,2,3,...12,
1,2,3,...9,9 12+9 = 21 ,at NO.22 is the duplicate 9

  • 0
    I think I understand your question, but I absolutely do not understand the definition of your array. What do you mean by "the index of second number of the twice number will be such as array(…)"?2012-06-22
  • 0
    miket what is the definition of the array? For example what is its 10th row? Or its 43rd row?2013-06-08

2 Answers 2