Showing posts with label suresh. Show all posts
Showing posts with label suresh. Show all posts

Saturday, March 27, 2021

6174 : Kaprekar's Constant and some programming

 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.


Saturday, January 14, 2012

For all PC Windows users, CCCleaner

One good thing of PC is the ability to install and uninstall software. Install, try we like, use it and sometime later we remove.

All applications are not disciplined enough to clean back the registry entries, during uninstall. They leave out a lot of unwanted stuff. The average user may not not what rubbish is left. A simple and decent software is CCCleaner. It is free. You can download the software from here.  Once you download and install it.

Part 1: Run it.

image

Click on Analyze.

image

Your list will look different. (Close all browsers before running)

Click Run Cleaner. (It might ask if entries listed needs to be deleted, Confirm it if asked).

Click on Analyze again. And you should see a clean screen.

 

Part 2: Click on Registry on the left. Select “Scan for Issues”.

image

Select “Fix Selected Issues”, and If asked, select to delete entries.

Part 3: Select Tools and you can uninstall unneeded programs.

image

 

Part 4: Now for this you need to be CAREFUL. Certain times lots of programs like to start automatically when the machine starts. Some of the programs like to keep their updater to run all the time. These programs un-necessarily occupy RAM and slow down your PC.

image

Click on Startup and disable the entries. If you see something you are not very sure then do a quick search on google.

 

So that is the end of the post. Keep your desktops and laptops within your control.

Saturday, May 07, 2011

Apache on Ubuntu. Install/Uninstall

=> i like to change to root, though this is not recommended. please use sudo.

skranga@ubuntu:~$ sudo bash

[sudo] password for skranga:

=> get the version of ubuntu

root@ubuntu:~# cat /etc/issue

Ubuntu 10.10 \n \l

=> install apache now (please add sudo before the command if you are running as root. Please be patient it can take time to install the software, on a slow connection.

root@ubuntu:~# apt-get install apache2

Reading package lists... Done

* Starting web server apache2 [ OK ]

Setting up apache2 (2.2.16-1ubuntu3.1) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

=> Open a browser and enter http://localhost

If Apache is installed successfully you should see something like this

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

=> How to start, stop and check status of the Apache Server.

root@ubuntu:~# /etc/init.d/apache2 status

Apache2 is running (pid 13872).

root@ubuntu:~# /etc/init.d/apache2 stop

* Stopping web server apache2 ... waiting [ OK ]

root@ubuntu:~# /etc/init.d/apache2 start

* Starting web server apache2 [ OK ]

root@ubuntu:~#

=> How to uninstall Apache. I selected no in the below example. You should select Yes if you wish to uninstall it.

root@ubuntu:~# apt-get remove apache2

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages were automatically installed and are no longer required:

apache2-mpm-worker libapr1 libaprutil1-ldap apache2-utils apache2.2-common libaprutil1-dbd-sqlite3

apache2.2-bin libaprutil1

Use 'apt-get autoremove' to remove them.

The following packages will be REMOVED:

apache2

0 upgraded, 0 newly installed, 1 to remove and 323 not upgraded.

After this operation, 36.9kB disk space will be freed.

Do you want to continue [Y/n]? n

Abort.

Wednesday, July 08, 2009

Google OS

Google announced yesterday that it is serious on launching an OS by the middle of next year. It will be called Chrome OS. By the way some facts.

- Chrome is a browser from Google. Available since feb this year.

- Google already has Android, an OS running on Handhelds. But they claim there will no overlapping.

In my opinion, though it looks like a small piece of IT news, but there will be lot of shake up. Seeing GMail, Google Earth, we all know that Google is capable of delivering lightweight, efficient piece of software. To be honest, I am waiting for the OS.

Read more here.

image

Sunday, May 31, 2009

Microsoft Small Basic

There are some fans of BASIC language out there (like me), here is some good news for you. Microsoft has a .Net based small basic.

The syntax is like the BASIC earlier but it is object oriented. Learning is fun. Hobby Programming.

Comes with the interpreter plus IDE.

Visit this site, download, get the docx/pdf learning guide and have fun this summer.

image

Saturday, January 10, 2009

Windows 7

Yesterday the beta of windows 7 has been released. This has generated lots of interest, gossip, expectations and of course predictions. Since XP, Windows OS are moving seriously. The previous versions whether Me, 98, 95 etc have DOS Kernel based.

10 years back, the requirement of users was not that tough. Computers and OS were still evolving. Today we need everything in the OS, including a coffee maker and microwave. And so are the OS become obese.

Lets us good sense prevails and users become more matured.

image image
image image
image image
image image
image image
image image
image image