Showing posts with label Suresh Ranga. Show all posts
Showing posts with label Suresh Ranga. Show all posts

Saturday, March 27, 2021

 6174 is known as Kaprekar's constant. My friend Ayaz, had shared this with me. I thought of writing a program in python to check and find out the number with the max interations to reach 6174. The program is here. You can read more about Karekar's constant in the wiki article. Click here



def allnums(n):

    res = [int(x) for x in str(n)]

    if (res[0]==res[1] & res[1]==res[2] & res[2]==res[3]):

        return (0)


def kaprekar(m):

    lp=0

    n=m

    while (n != 6174):

        integers = [int(x) for x in str(n)]

        integers.sort(reverse=True)

        strings = [str(integer) for integer in integers]

        a_string = "".join(strings)

        a = int(a_string)

        if a < 1000:

            a=a*10

        integers.sort()

        str2 = [str(integer) for integer in integers]

        str3 = "".join(str2)

        b = int(str3)   

        n=a-b

        lp=lp+1

    return(lp)

######################################## program starts here

mx=0

mxn=1000

for x in range(1000,9999):

    if allnums(x)!=0:

        y=kaprekar(x)

        if (y > mx):

            mx=y

            mxn=x

print(mx,mxn)




==========================================================================

Run the program and the output is

7 1004

1004 is the first number that needs 7 iterations to reach 6174.


Friday, July 29, 2011

Mind Mapping

Mind mapping has been a favourite topic for me. In my trainings I usually incorporate this. I also teach the participants the benefit of it. And how to apply in their day to day work. While going through technical manuals with hundreds of abbreviations, and countless features mind mapping comes as a great relief.

Mind map is not connecting electrical wires to the head. It is a diagram. You can read a good piece of information here.

Now one way to put it in practice is using paper and pen. But with software things can be more easy. There are paid version. But me being opensource supporter, have found a good free tool. It is called the Free Mind project. You can get the details here. So take some time, download and use the software. I am looking for some Android version as well. Free ofcourse.

Friday, October 02, 2009

Gandhi Jayanti

image

2nd Oct is the birth day of Gandhiji. He was born in the year 1869 in Porbandar. Gujarat has produced a wide array of brilliant people in India. Gandhiji wrote a book called My Experiments with Truth. It can be read from here. All should read it. Gandhiji lived truth. We all think truth as a verb. Something that has to be practiced. What happens when you practice something? Imagine 10+20 operation. We instantly know it is 30. We don't calculate. Because when you do something so many times over and over again, it starts to become natural. Gandhiji practiced truth so much that truth started to follow him. Instead of he telling the truth, what he told became the truth.