Saturday, 26 October 2013

Guess the number

1)  A 10 digit number.
From left side:
        1'st digit of this number is total number of 0's in this number.
        2'st digit of this number is total number of 1's in this number. 
        3'st digit of this number is total number of 2's in this number.
        4'st digit of this number is total number of 3's in this number.
        .....
        etc...
        .....
        10th digit of this number is total number of 9's in this number.

Sum of digits of the number is 10.

Most repeated digit is zero.

6210001000.

2) A 9 digit number    'abcdefghi'
  It contain digits 1 to 9 only one times.
  ab divisible by 2
  abc divisible by 3
  abcd divisible by 4
  abcde divisible by 5
  abcdef divisible by 6
  abcdefg divisible by 7
  abcdefgh divisible by 8
  abcdefghi divisible by 9
Hint 1
Hint 2
Hint 3
Answer

Sunday, 6 October 2013

ABC + DEF = GHI (abc def ghi math problem)


ABC + DEF = GHI and each letter represent number 1-9 and there is no repetition. Can you figure it out? There is how many sets of 3 digit number that satisfy the above condition?  How to find it?




Sum of A+B+C+D+...+F = 45 is an odd number.

Let x + y = z In addition (Without Carrying)



  • Rule 1: Sum of the digit of number x is odd and sum of the digit of number y is odd then sum of the digit of number z is even.
  • Rule 2: Sum of the digit of number x is even and sum of the digit of number y is odd then sum of the digit of number z is odd.
  • Rule 3: Sum of the digit of number x is odd and sum of the digit of number y is even then sum of the digit of number z is odd.
  • Rule 4: Sum of the digit of number x is even and sum of the digit of number y is even then sum of the digit of number z is even.





  • In our problem equation never satisfy in addition Without Carrying. Because Sum of A+B+C+D+...+F = 45 is an odd number. It never satisfy the above 4 rules.
    For example:
    Consider Rule 1:  Let sum of the digit of ABC is odd and sum of the digit of DEF is odd. We need a GHI with sum of the digit is even.
    But sum of the digit of ABC + sum of the digit of DEF is even.
    Sum of A+B+C+D+...+F = 45 is an odd.
    Therefore Sum of GHI is odd(45- even number is an odd number).
    Similarly in our problem did not satisfy the other 3 rules also.That means we need addition with carrying  to solve our problem.


    Set of number that gives carry

    In our problem there is no 0. To get carry sum of single digit number > 10.
    2: (2,9)
    3: (3,9),(3,8)
    4: (4,9),(4,8),(4,7)
    5: (5,9),(5,8),(5,7),(5,6)
    6: (6,9),(6,8),(6,7)
    7: (7,9),(7,8)
    8: (8,9)

    Consider set (2,9)
    2 + 9 = 1 with carry 1. sum of remaining numbers is 33, (3+4+5+6+7+8 = 33) + carry =34. That implies sum of G and H is 17. There is no such number in remaining set.

    Consider set (3,9)
    3 + 9 = 2 with carry 1. sum of remaining numbers is 31, (1+4+5+6+7+8 = 31) + carry =32. That implies sum of G and H is 16. There is no such number in remaining set.

    Consider set (3,8)
    3 + 8 = 1 with carry 1. sum of remaining numbers is 33, (2+4+5+6+7+9 = 33) + carry =34. That implies sum of G and H is 17. There is no such number in remaining set.

    Consider set (4,9)
    4 + 9 = 3 with carry 1. sum of remaining numbers is 29, (1+2+5+6+7+8 = 29) + carry =30. That implies sum of G and H is 15. There is such number in remaining set 8 and 7.

    Consider set (4,8)
    4 + 8 = 2 with carry 1. sum of remaining numbers is 31, (1+3+5+6+7+9 = 31) + carry =32. That implies sum of G and H is 16. There is such number in remaining set 7 and 9.

    Consider set (4,7)
    4 + 7 = 1 with carry 1. sum of remaining numbers is 33, (2+3+5+6+8+9 = 33) + carry =34. That implies sum of G and H is 17. There is such number in remaining set 8 and 9.

    Consider set (5,9)
    5 + 9 = 4 with carry 1. sum of remaining numbers is 27, (1+2+3+6+7+8 = 27) + carry =28. That implies sum of G and H is 14. There is such number in remaining set 6 and 8.

    Consider set (5,8)
    5 + 8 = 3 with carry 1. sum of remaining numbers is 29, (1+2+4+6+7+9 = 29) + carry =30. That implies sum of G and H is 15. There is such number in remaining set 6 and 9.

    Consider set (5,7)
    5 + 7 = 2 with carry 1. sum of remaining numbers is 31, (1+3+4+6+8+9 = 31) + carry =32. That implies sum of G and H is 16. There is no such number in remaining set.

    Consider set (5,6)
    5 + 6 = 1 with carry 1. sum of remaining numbers is 33, (2+3+4+7+8+9 = 33) + carry =34. That implies sum of G and H is 17. There is such number in remaining set 8 and 9.

    Consider set (6,9)
    6 + 9 = 5 with carry 1. sum of remaining numbers is 25, (1+2+3+4+7+8 = 25) + carry =26. That implies sum of G and H is 13.There is no such number in remaining set.

    Consider set (6,8)
    6 + 8 = 4 with carry 1. sum of remaining numbers is 27, (1+2+3+5+7+9 = 27) + carry =28. That implies sum of G and H is 14. There is such number in remaining set 5 and 9.

    Consider set (6,7)
    6 + 7 = 3 with carry 1. sum of remaining numbers is 29, (1+2+4+5+8+9 = 29) + carry =30. That implies sum of G and H is 15. There is no such number in remaining set.

    Consider set (7,9)
    7 + 9 = 6 with carry 1. sum of remaining numbers is 23, (1+2+3+4+5+8 = 23) + carry =24. That implies sum of G and H is 12.There is such number in remaining set 4 and 8.

    Consider set (7,8)
    7 + 8 = 5 with carry 1. sum of remaining numbers is 25, (1+2+3+4+6+9 = 25) + carry =26. That implies sum of G and H is 13. There is such number in remaining set 4 and 9.

    Consider set (8,9)
    8 + 9 = 7 with carry 1. sum of remaining numbers is 21, (1+2+3+4+5+6 = 21) + carry =22. That implies sum of G and H is 11.There is such number in remaining set 6 and 5.


    Set of number that gives carry and satisfy condition


    4: (4,9),(4,8),(4,7)
    5: (5,9),(5,8),(5,6)
    6: (6,8)
    7: (7,9),(7,8)
    8: (8,9)

    Consider set (4,9):
     The remaining numbers are 1,2,5 and 6. To get 8 we need to add 6 and 2. Therefore one of the solution for set (4,9) is 654 + 219 = 873

    Consider set (4,8):


     The remaining numbers are 1,3,5 and 6. To get 9 we need to add 6 and 3. Therefore one of the solution for set (4,8) is 654 + 318 = 972

    Consider set (4,7):


     The remaining numbers are 2,3,5 and 6. To get 9 we need to add 6 and 3. Therefore one of the solution for set (4,7) is 654 + 327 = 981

    Consider set (5,9):

     The remaining numbers are 1,2,3 and 7. To get 8 we need to add 7 and 1. Therefore one of the solution for set (5,9) is 735 + 127 = 864

    Consider set (5,8):


     The remaining numbers are 1,2,4 and 7. To get 9 we need to add 7 and 2. Therefore one of the solution for set (5,8) is 745 + 218 = 963

    Consider set (5,6):




     The remaining numbers are 2,3,4 and 7. To get 9 we need to add 7 and 2. Therefore one of the solution for set (5,6) is 745 + 236 = 981

    Consider set (6,8):

    The remaining numbers are 1,2,3 and 7. To get 9 we need to add 7 and 2. Therefore one of the solution for set (6,8) is 736 + 218 = 954

    Consider set (7,9):
    mudumaths

    The remaining numbers are 1,2,3 and 5. To get 8 we need to add 5 and 3. Therefore one of the solution for set (7,9) is 527 + 319 = 846

    Consider set (7,8):


    The remaining numbers are 1,2,3 and 6. To get 9 we need to add 6 and 3. Therefore one of the solution for set (7,8) is 627 + 318 = 945

    Consider set (8,9):


    The remaining numbers are 1,2,3 and 4. To get 6 we need to add 4 and 2. Therefore one of the solution for set (8,9) is 438 + 219 = 657



    From the above 10 set each of the set have so-many combination of number that satisfy the equation ABC + DEF = GHI. 

    Each set contain 1-3 solution set. The 4 types of solution set are given below.
      A1 = A, B1 = B, D1 = D, E1 = E, H1 = H, G1 = G.

           1)A1+D1= G1 and B1+E1+1 = H1
           2)A1+E1= H1 and B1+D1+1 = G1
           3)B1+D1= H1 and A1+E1+1 = G1
           4)B1+E1= G1 and A1+D1+1 = H1

     Each solution set gives 16 different combination(different values for A-I) of number.
     consider this example : 
                     


    First consider the set (4,9)
          Here there are 3 solution set.
                  1) 654 +        2) 654 +     3) 564 +
                      219                129            219
                     -------            ------            -------
                     873                783             783
         set (4,9) gives 16*3 = 48 different combination of number.

    First consider the set (4,8)
          Here there are 2 solution set.
                  1) 654 +        2) 654 +
                      318                138   
                     -------            ------    
                     972                792    
          set (4,8) gives 16*2 = 32 different combination of number.

    First consider the set (4,7)
          Here there are 3 solution set.
                  1) 654 +        2) 654 +    3) 564 +
                      327                237            327
                     -------            ------          ------
                     981                891             891
          set (4,7) gives 16*3 = 48 different combination of number.

    First consider the set (5,9)
          Here there is 1 solution set.
                  1) 735 +  
                      129   
                     -------  
                     864      
          set (5,9) gives 16*1 = 16 different combination of number.

    First consider the set (5,8)
          Here there  are 2 solution set.
                  1) 745 +     2) 475 +
                      218             218
                     -------         ------
                     963              693 
          set (5,8) gives 16*2 = 32 different combination of number.

    First consider the set (5,6)
          Here there is 1 solution set.
                  1) 745 +  
                      236   
                     -------  
                     981    
          set (5,6) gives 16*1 = 16 different combination of number.

    First consider the set (6,8)
          Here there are 2 solution set.
                  1) 736 +    2) 376 +
                      218            218
                     -------         ------
                     954             594
          set (6,8) gives 16*2 = 32 different combination of number.

    First consider the set (7,8)
          Here there is 1 solution set.
                 1) 627+  
                     318   
                     -------  
                     945    
          set (7,8) gives 16*1 = 16 different combination of number.

    First consider the set (7,9)
          Here there are 2 solution set.
                  1) 517 +        2) 157 +   
                      329                329        
                     -------            ------          
                     846                486     
          set (7,9) gives 16*2 = 32 different combination of number.

    First consider the set (8,9)
          Here there are 3 solution set.
                  1) 438 +        2) 438 +     3) 348 +
                      219                129            219
                     -------            ------            -------
                     657                567             567
          set (8,9) gives 16*3 = 48 different combination of number.



    Total 16*21 = 336 combination of number that satisfy the equation ABC + DEF = GHI. 


    Saturday, 2 March 2013

    100 student and 1000 door problem

    Description:There was 100 students and 1000 closed doors. The 1st student opens all 1000 doors, the 2nd student closes doors 2,4,6,8,10, etc., the 3rd student opens doors closed and closes doors opened on doors 3,6,9,12,15,etc.
    after going all of 100 students how many doors are still open?


    Answer is 524

    How to get it? what are these numbers? What are the properties of these numbers? Do you want to know it?
    1) 1 st consider first 100 doors.
         Only 10 doors are open after passing all students.
     door number       students number
         1                     (1)
         4                     (1, 2, 4)
         9                     (1, 3, 9)
        16                     (1, 2, 4, 8, 16)
        25                     (1, 5, 25)
        36                     (1, 2, 3, 4, 6, 9, 12, 18, 36)
        49                     (1, 7, 49)
        64                     (1, 2, 4, 8, 16, 32, 64)
        81                     (1, 3, 9, 27, 81)
       100                     (1, 2, 4, 5, 10, 20, 25, 50, 100)
     
        These are Square Number 

    • Student 1 can open all the doors.
    • The Students whose number is same as door's number they  are  close the doors. 
    • If the door number is prime it can't open by other students.Because it can't have other divisors. 
    • If the door number is composite number and it is not a square number then these doors are closed after passing all students. Because door number = M x N. If M is open the door then N is closed it. Let door number is 10. 10= 2 x 5, 2 open the door and 5 close that door. Let door number is 20 , 20 = 2 x 10,4 x 5. Here 2 open the door and 10 close that door, 4 open the door and 5 close that door.
    • If the door number is composite number and it is a square number then these doors are opened after passing all students. Because one pair of divisor is in the form of N x N.  Let door number is 25.  25 = 5 x 5. Here student 5 open the door. Let door number is 16.  16 = 2 x 8, 4 x 4. Here student 2 open the door student 8 close it and student 4 open it.
        Only 10 doors are open after passing all students.

    2) Consider doors 101 to 200
           All factors of door's number are less than 101. Here student 1 open all doors, and if another student    (number M)   can close the door there exist a student (number N) can open it. But in the case of              Square Numbers M=N therefore door remains closed.  96 doors are remains  open after passing all         students. Door number 121,144,169 and 196(square numbers) are remains closed.

        96 doors are remains  open after passing all students.

    3) Consider doors 201 to 300
          ->If door's number is odd, then all factors of door's number are less than 101. Here student 1 open all doors, and if another student  (number M)  can close the door there exist a student (number N)   can open it. But in the case of   Square Numbers M=N therefore door remains closed. 48 doors are remains  open after passing all  students. Door number 225 and 289(square numbers) are remains closed.
         ->If door's number is even, one of the factors of door's number is grater than 101. Here student 1open all doors, and student 2 closed all doors.  If another student  (number M !=2)  can open the             door there exist a student  (number N!=2)   can close it. But in the case of   Square Numbers M=N therefore door remains  open.  There was is only 1 square number 256. Only 1 door is remains  open after passing all  students.

          49 doors are remains  open after passing all  students.
    4)  Consider doors 301 to 400
            ->If door's number is not a multiple of 2 or 3, then all factors of door's number are less than 101. Here student 1 open  all doors, and if another student  (number M)  can close the door there exist a student (number N)   can open it. But in the case of   Square Numbers M=N therefore door remains closed. 32 doors are remains  open after passing all  students. Door number 361(square number) is remains closed.
         ->If door's number is multiple of 6, two of the factors of door's number is grater than 101(2 x N and 3 x N). Here student 1open all doors, student 2 closed all doors, and student 3 open all doors.  If another student  (number M !=2 or 3)  can close the   door there exist a student  (number N!=2 or 3)   can open it. But in the case of   Square Numbers M=N therefore door remains  close.  There is only 1 square number 324. 15 door is remains  open after passing all  students.
        ->If door's number is multiple of 2 and not multiple of 3, one of the factors of door's number is grater than 101(2 x N). Here student 1 open all doors, and student 2 closed all doors.  If another student  (number M !=2)  can open the   door there exist a student  (number N!=2)   can close it. But in the case of   Square Numbers M=N therefore door remains  open.  There is only 1 square number 400. Only 1 door is remains  open after passing all  students.
        ->If door's number is multiple of 3 and not multiple of 2, one of the factors of door's number is grater than 101(3 x N). Here student 1 open all doors, and student 3 closed all doors.  If another student  (number M !=3)  can open the   door there exist a student  (number N!=3)   can close it. But in the case of   Square Numbers M=N therefore door remains  open.  There is no such square number. all doors are remains  close after passing all  students.

    48 doors are remains  open after passing all  students.



    5)  Consider doors 401 to 500
            ->If door's number is not a multiple of 2 or 3 or 4, then all factors of door's number are less than 101. Here student 1 open  all doors, and if another student  (number M)  can close the door there exist a student (number N)   can open it. But in the case of   Square Numbers M=N therefore door remains closed. There is no such square number. 34 doors are remains  open after passing all  students. 
         ->If door's number is multiple of 2 and 3 not multiple of 4, two of the factors of door's number is grater than 101(2 x N and 3 x N). Here student 1 open all doors, student 2 closed all doors, and student 3 open all doors.  If another student  (number M !=2 or 3)  can close the   door there exist a student  (number N!=2 or 3)   can open it. But in the case of   Square Numbers M=N therefore door remains  close.  There is no such square number. 9 door is remains  open after passing all  students.
    ->If door's number is multiple of 2 and 4 not multiple of 3, two of the factors of door's number is grater than 101(2 x N and 4 x N). Here student 1 open all doors, student 2 closed all doors, and student 4 open all doors.  If another student  (number M !=2 or 3)  can close the   door there exist a student  (number N!=2 or 4)   can open it. But in the case of   Square Numbers M=N therefore door remains  close.  There is only 1 square number 484. 16 door is remains  open after passing all  students.
        ->If door's number is multiple of 2 and not multiple of 3 or 4, one of the factors of door's number is grater than 101(2 x N). Here student 1 open all doors, and student 2 closed all doors.  If another student  (number M !=2)  can open the   door there exist a student  (number N!=2)   can close it. But in the case of   Square Numbers M=N therefore door remains  open.  There is no such square number.
        ->If door's number is multiple of 3 and not multiple of 2, one of the factors of door's number is grater than 101(3 x N). Here student 1 open all doors, and student 3 closed all doors.  If another student  (number M !=3)  can open the   door there exist a student  (number N!=3)   can close it. But in the case of   Square Numbers M=N therefore door remains  open.  Door number 441(square number) is remains open.door remains  open after passing all  students.

    60 doors are remains  open after passing all  students.

    Apply above method to get all such numbers.
    6)  Consider doors 501 to 600
           53
    7)  Consider doors 601 to 700
            54
    8)  Consider doors 701 to 800
          53
    9)  Consider doors 801 to 900
            48
    10)  Consider doors 901 to 1000
           53
      
      What are the properties of these numbers?
       1. Prime test.
               All prime number between 100 to 1000 are include in this set.
       2. Square number.
               All square number less than 100  include in this set.
       3. Properties of single set(set contain 100 elements):
                 - >101 to 200  hset(),                                      sset(121,144,169,196)
                 - >201 to 300  hset(2),                                    sset(225,256,289)
                 - >301 to 400  hset(2,3),                                 sset(324,361,400)
                 - >401 to 500  hset(2,3,4),                              sset(441,484)
                 - >501 to 600  hset(2,3,4,5),                           sset(529,576)
                 - >601 to 700  hset(2,3,4,5,6),                        sset(625,676)
                 - >701 to 800  hset(2,3,4,5,6,7),                     sset(729,784)
                 - >801 to 900  hset(2,3,4,5,6,7,8),                  sset(841)
                 - >901 to 1000  hset(2,3,4,5,6,7,8,9),             sset(900,961)
         

       Let M be the door's number>100  ,    
            if M is open after passing all  students,
               
                    then 
    conditions:     

                              1) Odd number of elements in hset is factor of M and M is in sset.                               

                                        OR


                              2) Zero or even number of elements in hset is factor of M and M is not in sset






    List of all open door with students who open or close that door, And Python code to find these numbers is given below.

           
    # To store status of each door 1 stands for closed -1 stands for opened.
    status=[]
    #To store list of student who open or close each door.
    door=[]
    
    for d in range(1,1001):
     #Initially status of all door is closed.
     status.append(1)
     #Initially none of student open or closed the door.
     door.append(())
    for student in range(1,101):
     k=student
    
     while(k<=1000):
      #change status of the door
      status[k-1] = -(status[k-1])
      #Add the student to the list
      door[k-1]=door[k-1]+(student,)
      # Find multiplication of student's number
      k +=student
    #To count opened door after passing allstudent
    count=0
    ans = open("door.txt","w")
    for d in range(1,1001):
     if(status[d-1] == -1):
      #Filter the open doors
      #Increase count of open door by 1
      count +=1
      #Print the door number and students who open or closed the door.
      print >>ans,d,door[d-1]
    #print the total number of open doors
    print count