Thursday 20 June 2013

Scrabble Cheater using PYTHON

#enjoy.. Fun with scrabble cheater
# sowpods.txt is the list of words in the official SOWPODS Scrabble word list.


#dictionary that stores the letters as the keys and the values as their scores.
scores = {"A": 1, "C": 3, "B": 3, "E": 1, "D": 2, "G": 2,
         "F": 4, "I": 1, "H": 4, "K": 5, "J": 8, "M": 3,
         "L": 1, "O": 1, "N": 1, "Q": 10, "P": 3, "S": 1,
         "R": 1, "U": 1, "T": 1, "W": 4, "V": 4, "Y": 4,
         "X": 8, "Z": 10}

my_file = open("sowpods.txt", "r") #open file in read mode.
li = my_file.readlines()                   # li is the list that stores the of words.
my_file.close()                                #closes sowpods.txt file.  
for i in range(0,len(li)):                  # for loop that strips new line characters 
    li[i] = li[i].strip()                         #from the words

import sys

rack = sys.argv[1]                       # get the Scrabble rack from the command line.
valid_words = []
for word in li:                               
    candidate = True                    
    rack_letters = list(rack)          #rack is stored as a list in racks_letters 
    for letter in word:
        if letter not in rack_letters:  #checking if the rack forms the word.
            candidate = False
        else:   
            rack_letters.remove(letter)
    if candidate == True:                 #if candidate is true calculate score.
        total = 0
        for letter in word:
            total = total + scores[letter]
        valid_words.append([total, word])
        
valid_words.sort()                            #sorts list of valid words that could be
                                                         #formed by the rack
for entry in valid_words:
    score = entry[0]
    word = entry[1]
    print(str(score) + " " + word)       #prints score space word.       
       
            

Tuesday 11 June 2013

Passport Seva Kendra (PSK) Ghaziabad

Passport is needed if you wish to travel some foreign country. I do not have a passport yet. So I applied on-line by signing up through http://passportindia.gov.in/AppOnlineProject/welcomeLink. First, It is a very tedious job to get an appointment. second, if anyhow you manage to get an appointment there are two categories to get it, Tatkaal and Normal. You can get appointment through any category. if you manage to get an appointment in Tatkaal category and you want Normal category, you can convert it in to the Normal category by reaching  PSK,Ghaziabad on the date of your appointment. no worries.. 

Now, you need to visit to the PSK on the date of an appointment. My
city Muzaffarnagar comes under Ghaziabad PSK, so I need to visit there. I had no idea about the address of the PSK Ghaziabad, so tried to get it from the website. You can view the address of your PSK by clicking on the link Locate Nearest Passport Seva Kendra on the right hand side in services pane and I selected Ghaziabad and get the address as follows:

Passport Seva Kendra, Block-A Ground Floor, Pacific Business Park, Plot No 37/1, Site IV, Sahibabad Industrial Area, Ghaziabad - 201010

Right, it is the correct address.  But, when you click on the view google map button on the left hand side on the same page you will find PSK at:

 Screen shot after zooming 8 times:
but when you navigate the map around Shaibabad railway station you got on the link road where the persent PSK is situated, as depicted in the screenshot below. That is very near to the Kaushambhi metro station.

 We can clearly see that it is not pointed as the PSK, Ghaziabad. 

I board on train on Tuesday, 28-May-2013 at 7.10 am from Muzaffanagar and get down at 9.15 am at Ghaziabad junction instead I should have get down at Sahibabad junction. :(

Because of the mis-guidance on google map, I had to face the difficulty in reaching PSK on time i.e. 10.30 am. 

I would suggest to the www.passportindia.gov.in website maintainers to not to misguide people if they cannot update things on time. Everybody's time and money are important.