Friday, July 22, 2011
Similarities between IIT Guwahati and Hogwarts
1. Both have lakes, hills and variety of flora and fauna, making the walks in the campus pleasurable.
2. The headmaster in Hogwarts and the director in IIT are revered by many and also hated by many. Both are kind to students.
3. The ministry in the magical world and MHRD in India both interfere in the respective institutes a lot, sometimes with comments in newspapers and sometimes with policy changes.
4. Students in Hogwarts searched for secrets passages to get out of the castle. Students at IIT fish for loopholes in computer network to download movies and do other stuff.
5. Hogwarts has houses. IIT has hostels much to similar effect. Competition in high during annual festivals in both.
6. The best one -- while the outside world thinks that students are doing magic or making up cool stuff, they are just scrapping through the syllabus to get the grades.
2. The headmaster in Hogwarts and the director in IIT are revered by many and also hated by many. Both are kind to students.
3. The ministry in the magical world and MHRD in India both interfere in the respective institutes a lot, sometimes with comments in newspapers and sometimes with policy changes.
4. Students in Hogwarts searched for secrets passages to get out of the castle. Students at IIT fish for loopholes in computer network to download movies and do other stuff.
5. Hogwarts has houses. IIT has hostels much to similar effect. Competition in high during annual festivals in both.
6. The best one -- while the outside world thinks that students are doing magic or making up cool stuff, they are just scrapping through the syllabus to get the grades.
Wednesday, May 18, 2011
Monday, March 14, 2011
Flattening abitrarily nested lists in Python
Lists are one of the three most important data structures in Python, other being dict and str, (tuple is the younger cousin of list). The lists can be arbitrarily nested with any kind of data inside them, e.g.
['a', [1, 2], (3, 4, 5, [7, 8, ['gnu', 'linux']]), ['a', 'b', 'c'], [['d', 'e', 'f'], 12, [13, [14, [15,]]]]]
The objective is flatten nested lists of this kind to a single list. It can be simply stated as to remove all square brackets (and parenthesis) and retain only square brackets at the end, while maintaining the order of the items as they appear in the nested list. One of the simple solution can be:
Run this on the example and you get:
['a', 1, 2, 3, 4, 5, 7, 8, 'gnu', 'linux', 'a', 'b', 'c', 'd', 'e', 'f', 12, 13, 14, 15]
Can this be made more Pythonic and efficient. Any ides?
['a', [1, 2], (3, 4, 5, [7, 8, ['gnu', 'linux']]), ['a', 'b', 'c'], [['d', 'e', 'f'], 12, [13, [14, [15,]]]]]
The objective is flatten nested lists of this kind to a single list. It can be simply stated as to remove all square brackets (and parenthesis) and retain only square brackets at the end, while maintaining the order of the items as they appear in the nested list. One of the simple solution can be:
def flatten(l):
'''Flatten a arbitrarily nested lists and return the result as a single list.
'''
ret = []
for i in l:
if isinstance(i, list) or isinstance(i, tuple):
ret.extend(flatten(i))
else:
ret.append(i)
return ret
'''Flatten a arbitrarily nested lists and return the result as a single list.
'''
ret = []
for i in l:
if isinstance(i, list) or isinstance(i, tuple):
ret.extend(flatten(i))
else:
ret.append(i)
return ret
Run this on the example and you get:
['a', 1, 2, 3, 4, 5, 7, 8, 'gnu', 'linux', 'a', 'b', 'c', 'd', 'e', 'f', 12, 13, 14, 15]
Can this be made more Pythonic and efficient. Any ides?
Tuesday, December 14, 2010
mplayer: volume trick
When you want to view a movie or listen to a song which has a squeaky audio the easy option is to use VLC player to set the volume to the max of 400%.
MPlayer by default gives no option for the volume boost. However you can simply make the volume go to any level you want. You just need to set the following options in the ~/.mplayer/config file or the config file in the mplayer install directory on Windows:
Here 400 signifies that maximum volume can be 400%. You can specify any value for this so have custom control over maximum value of the volume.
MPlayer by default gives no option for the volume boost. However you can simply make the volume go to any level you want. You just need to set the following options in the ~/.mplayer/config file or the config file in the mplayer install directory on Windows:
softvol=yes
softvol-max=400
Here 400 signifies that maximum volume can be 400%. You can specify any value for this so have custom control over maximum value of the volume.
Monday, November 22, 2010
A Better Education System
Right now our education system is a class/standard based education system. Means for for the given year a student has to study the given number of subjects and if he/she doesn't pass one of the subjects he/she has to repeat the year. Also the students are graded on the basis of the cumulative percentage of the marks they get.
In this big range of figures what is hidden is that a student might not be interested/weak/slow-learner for a given subject. This takes toll from other subjects which he is good at. Its better that he gives exams when he thinks he is ready. Rather giving it at fixed time of the year.
Another opposite of the above is that a given student is good/strong/fast-learner at a given subject and still he has to stick with rest of the class and wait for the final exams.
Why not students have a choice to give the exams when they are ready. This might look like a havoc on the system. But if we consider that not all students will be giving the exams at the same time, for a given time it will be some fraction, (consider GRE, TOEFL etc.)
Consider another option students have to stick with the class/standard based system even if he is good enough to solve the problems of a given subject from higher classes/standard. Rather than having some subjects required to pass to move to the next class/standard its better if we have class/standard associated with each subject and a student has to clear the exams of that subject to be awarded certificate of learning that subject.
Consider the case of colleges asking for the students to have passed class 10+2 with some subjects. Presently students has to pass the whole 10+2. Why not simply the college asking for certificate of 10+2 for the required subjects.
Here is an infographic:
In this big range of figures what is hidden is that a student might not be interested/weak/slow-learner for a given subject. This takes toll from other subjects which he is good at. Its better that he gives exams when he thinks he is ready. Rather giving it at fixed time of the year.
Another opposite of the above is that a given student is good/strong/fast-learner at a given subject and still he has to stick with rest of the class and wait for the final exams.
Why not students have a choice to give the exams when they are ready. This might look like a havoc on the system. But if we consider that not all students will be giving the exams at the same time, for a given time it will be some fraction, (consider GRE, TOEFL etc.)
Consider another option students have to stick with the class/standard based system even if he is good enough to solve the problems of a given subject from higher classes/standard. Rather than having some subjects required to pass to move to the next class/standard its better if we have class/standard associated with each subject and a student has to clear the exams of that subject to be awarded certificate of learning that subject.
Consider the case of colleges asking for the students to have passed class 10+2 with some subjects. Presently students has to pass the whole 10+2. Why not simply the college asking for certificate of 10+2 for the required subjects.
Here is an infographic:
![]() |
| Subjects in pipeline |
Subscribe to:
Posts (Atom)


