[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible ruby solution/pic  attached

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

attachment: digsum_output.png

[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible solution in ruby  (sry if this is double-posted -- i did not
see it come up the first time)

[image: digsum_output.png]

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

digsum_output.png

[algogeeks] i cannot solve this written test question

2011-10-09 Thread wujin chen
Given a positive number N, find a minimum number M greater than N, M  has
the same length with N and the sum of the bits are equal.

example:
N=134 , M=143,  // 1+3+4=1+4+3
N=020, M = 101, //2=1+1

the length of N is less than 1000.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] i cannot solve this written test question

2011-10-09 Thread Ankur Garg
Is it sum of bits or sum of digits ?

On Sun, Oct 9, 2011 at 1:39 PM, wujin chen wujinchen...@gmail.com wrote:

 Given a positive number N, find a minimum number M greater than N, M  has
 the same length with N and the sum of the bits are equal.

 example:
 N=134 , M=143,  // 1+3+4=1+4+3
 N=020, M = 101, //2=1+1

 the length of N is less than 1000.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] i cannot solve this written test question

2011-10-09 Thread Aamir Khan
Answer won't be possible in for each N. What would be answer for N=999 ?

On Sun, Oct 9, 2011 at 4:22 PM, Ankur Garg ankurga...@gmail.com wrote:

 Is it sum of bits or sum of digits ?


 On Sun, Oct 9, 2011 at 1:39 PM, wujin chen wujinchen...@gmail.com wrote:

 Given a positive number N, find a minimum number M greater than N, M  has
 the same length with N and the sum of the bits are equal.

 example:
 N=134 , M=143,  // 1+3+4=1+4+3
 N=020, M = 101, //2=1+1

 the length of N is less than 1000.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] i cannot solve this written test question

2011-10-09 Thread wujin chen
@Ankur ,
as example:
N=134 , M=143,  // 1+3+4=1+4+3
N=020, M = 101, //2=1+1

I mean the sum of digits.

2011/10/9 Ankur Garg ankurga...@gmail.com

 Is it sum of bits or sum of digits ?

 On Sun, Oct 9, 2011 at 1:39 PM, wujin chen wujinchen...@gmail.com wrote:

 Given a positive number N, find a minimum number M greater than N, M  has
 the same length with N and the sum of the bits are equal.

 example:
 N=134 , M=143,  // 1+3+4=1+4+3
 N=020, M = 101, //2=1+1

 the length of N is less than 1000.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] i cannot solve this written test question

2011-10-09 Thread wujin chen
@Aamir , yes, for some N, it will be no ans, then return -1.

2011/10/9 Aamir Khan ak4u2...@gmail.com

 Answer won't be possible in for each N. What would be answer for N=999 ?


 On Sun, Oct 9, 2011 at 4:22 PM, Ankur Garg ankurga...@gmail.com wrote:

 Is it sum of bits or sum of digits ?


 On Sun, Oct 9, 2011 at 1:39 PM, wujin chen wujinchen...@gmail.comwrote:

 Given a positive number N, find a minimum number M greater than N, M  has
 the same length with N and the sum of the bits are equal.

 example:
 N=134 , M=143,  // 1+3+4=1+4+3
 N=020, M = 101, //2=1+1

 the length of N is less than 1000.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Aamir Khan | 3rd Year  | Computer Science  Engineering | IIT Roorkee


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.