Hilarious Poems

सिक्के की औक़ात / अशोक चक्रधर
एक बार
बरखुरदार!
एक रुपए के सिक्के,
और पाँच पैसे के सिक्के में,
लड़ाई हो गई,
पर्स के अंदर
हाथापाई हो गई।
जब पाँच का सिक्का
दनदना गया
तो रुपया झनझना गया
पिद्दी न पिद्दी की दुम
अपने आपको
क्या समझते हो तुम!
मुझसे लड़ते हो,
औक़ात देखी है
जो अकड़ते हो!

इतना कहकर मार दिया धक्का,
सुबकते हुए बोला
पाँच का सिक्का-
हमें छोटा समझकर
दबाते हैं,
कुछ भी कह लें
दान-पुन्न के काम तो
हम ही आते हैं।

जंगल गाथा / अशोक चक्रधर

पानी से निकलकर
मगरमच्छ किनारे पर आया,
इशारे से
बंदर को बुलाया.
बंदर गुर्राया-
खों खों, क्यों,
तुम्हारी नजर में तो
मेरा कलेजा है?

मगर्मच्छ बोला-
नहीं नहीं, तुम्हारी भाभी ने
खास तुम्हारे लिये
सिंघाड़े का अचार भेजा है.

बंदर ने सोचा
ये क्या घोटाला है,
लगता है जंगल में
चुनाव आने वाला है.
लेकिन प्रकट में बोला-
वाह!
अचार, वो भी सिंघाड़े का,
यानि तालाब के कबाड़े का!
बड़ी ही दयावान
तुम्हारी मादा है,
लगता है शेर के खिलाफ़
चुनाव लड़ने का इरादा है.

कैसे जाना, कैसे जाना?
ऐसे जाना, ऐसे जाना
कि आजकल
भ्रष्टाचार की नदी में
नहाने के बाद
जिसकी भी छवि स्वच्छ है,
वही तो मगरमच्छ है.


एक नन्हा मेमना
और उसकी माँ बकरी,
जा रहे थे जंगल में
राह थी संकरी।
अचानक सामने से आ गया एक शेर,
लेकिन अब तो
हो चुकी थी बहुत देर।
भागने का नहीं था कोई भी रास्ता,
बकरी और मेमने की हालत खस्ता।
उधर शेर के कदम धरती नापें,
इधर ये दोनों थर-थर कापें।
अब तो शेर आ गया एकदम सामने,
बकरी लगी जैसे-जैसे
बच्चे को थामने।
छिटककर बोला बकरी का बच्चा-
शेर अंकल!
क्या तुम हमें खा जाओगे
एकदम कच्चा?
शेर मुस्कुराया,
उसने अपना भारी पंजा
मेमने के सिर पर फिराया।
बोला-
हे बकरी – कुल गौरव,
आयुष्मान भव!
दीर्घायु भव!
चिरायु भव!
कर कलरव!
हो उत्सव!
साबुत रहें तेरे सब अवयव।
आशीष देता ये पशु-पुंगव-शेर,
कि अब नहीं होगा कोई अंधेरा
उछलो, कूदो, नाचो
और जियो हँसते-हँसते
अच्छा बकरी मैया नमस्ते!

इतना कहकर शेर कर गया प्रस्थान,
बकरी हैरान-
बेटा ताज्जुब है,
भला ये शेर किसी पर
रहम खानेवाला है,
लगता है जंगल में
चुनाव आनेवाला है।

नेता जी लगे मुस्कुराने / अशोक चक्रधर
एक महा विद्यालय में
नए विभाग के लिए
नया भवन बनवाया गया,
उसके उद्घाटनार्थ
विद्यालय के एक पुराने छात्र
लेकिन नए नेता को
बुलवाया गया।

अध्यापकों ने
कार के दरवाज़े खोले
नेती जी उतरते ही बोले—
यहां तर गईं
कितनी ही पीढ़ियां,
अहा !
वही पुरानी सीढ़ियां !
वही मैदान
वही पुराने वृक्ष,
वही कार्यालय
वही पुराने कक्ष।
वही पुरानी खिड़की
वही जाली,
अहा, देखिए
वही पुराना माली।

मंडरा रहे थे
यादों के धुंधलके
थोड़ा और आगे गए चल के—
वही पुरानी
चिमगादड़ों की साउण्ड,
वही घंटा
वही पुराना प्लेग्राउण्ड।
छात्रों में
वही पुरानी बदहवासी,
अहा, वही पुराना चपरासी।
नमस्कार, नमस्कार !
अब आया हॉस्टल का द्वार—
हॉस्टल में वही कमरे
वही पुराना ख़ानसामा,
वही धमाचौकड़ी
वही पुराना हंगामा।
नेता जी पर
पुरानी स्मृतियां छा रही थीं,
तभी पाया
कि एक कमरे से
कुछ ज़्यादा ही
आवाज़ें आ रही थीं।
उन्होंने दरवाजा खटखटाया,
लड़के ने खोला
पर घबराया।
क्योंकि अंदर एक कन्या थी,
वल्कल-वसन-वन्या थी।
दिल रह गया दहल के,
लेकिन बोला संभल के—
आइए सर !
मेरा नाम मदन है,
इससे मिलिए
मेरी कज़न है।

नेता जी लगे मुस्कुराने

नन्ही सचाई / अशोक चक्रधर
एक डॉक्टर मित्र हमारे
स्वर्ग सिधारे।
असमय मर गए,
सांत्वना देने
हम उनके घर गए।
उनकी नन्ही-सी बिटिया
भोली-नादान थी,
जीवन-मृत्यु से
अनजान थी।
हमेशा की तरह
द्वार पर आई,
देखकर मुस्कुराई।
उसकी नन्ही-सचाई
दिल को लगी बेधने,
बोली—
अंकल !
भगवान जी बीमार हैं न
पापा गए हैं देखने।

Advertisements

Programming Problems 5

1. Distance in a dictionary

You have a dictionary of N words each of 3 chars. Given 2 words you have to find the optimum path between the 2 words. The optimum path contains the words in the dictionary each word at a distance of 1 from the previous word.
for eg source = cat , target = sun
path is
cat -> bat -> but -> bun -> sun
given all these words are in the dictionary

2. Nth number with m binary 1s

There is a series of numbers in ascending order. All these numbers have the same number of binary 1s in them. Given the number of 1 bits set in the numbers, write an algorithm/C program to find the nth number in the series.

3. kth largest in the array

You have an array of numbers; you need to find the nth largest in the array in 0(n)

4.Find the path in two nodes of a binary search tree

Suppose you have a tree. A binary tree (for something like simplicity :p). You are traversing it (using infix, postfix or prefix) to search for a node. You find your required node. You just realized that you need to know the path from this node back to the root node (and/or vice versa). Given the following description of the structure of the tree node that you “cant” change:

struct node{Data data; node *right,*left;};

what will you strategy be to tackle this problem.

To make it more intresting (or maybe just the application of the above problem) suppose you find the node A and a node B in consecutive searches. Now what will your strategy be to show a path from A to B. (not neccesarily from the root of the whole tree, but possibly).

5. Inplace merging in an array

If i have an array which contains partially sorted lists. Can you suggest and algorithm which can do an in-place merging of the sorted lists.

eg: 40, | 20, 30, | 10, 15, 75, 85
In the above example there are 3 partially sorted lists

Programming Problems 4

1. Power of 3

Given M, find if M = 3^x for some positive integer x efficiently. DO NOT think of log, pow etc.

2. Maximum Sum path in a Matrix

Given a M*N matrix A. Find a path from the top-left element (ie A[0][0]) to the bottom right element (ie A[M-1][N-1]) such that the sum of the elements in the path is maximum.  Length of path should be M + N – 1. Moves can be made towards the right and bottom only by 1 cell i.e. from A[i][j] only two possible steps are A[i+1][j] or A[i][j+1].

3. Longest Interval with Maximum Sum

We are given with two arrays A and B..each of size N…elements of array contains either 1 or 0. We have to find such an interval (p,q)(inclusive) such that the sum of all the elements of A (between this interval) and sum of all elements of B (between this interval ) is equal. i.e. a[p]+a[p+1]….+a[q]= b[p]+b[p+1]….+b[q].  Solution should be better than O(n^2)

4.Divide the array into groups

Divide a list of numbers into groups of consecutive numbers but their original order should be preserved.

Example:
<8,2,4,7,1,0,3,6>
Two groups:
<2,4,1,0,3> <8,7,6>

Better than O(n^2) is expected.

5. Sort on second key when array is sorted on first key

Assume that we are given as input n pairs of items, where

  1. the first item is a number
  2. the second item is one of three colors (red, blue, or yellow).

Further, assume that the items are sorted by number. Give an O(n) algorithm to sort the items by color (all reds before all blues before all yellows) such that the numbers for identical colors stay sorted.

For example: (1,blue), (3,red), (4,blue), (6,yellow), (9,red) should become (3,red), (9,red), (1,blue), (4,blue), (6,yellow).

Programming Problems 3

1. Zigzag

A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence.

For example, 1,7,4,9,2,5 is a zig-zag sequence because the differences (6,-3,5,-7,3) are alternately positive and negative. In contrast, 1,4,7,2,5 and 1,7,4,5,5 are not zig-zag sequences, the first because its first two differences are positive and the second because its last difference is zero.

Given a sequence of integers, sequence, return the length of the longest subsequence of sequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order.

2. Balanced Brackets

Given a number n, print all possible combinations of n pairs of braces that are balanced
Input:1
Output:
()

Input:2

Output:

(())
()()

Input:3
Output:
((()))
(()())
(())()
()(())
()()()

3. Find 2 missing numbers

Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers in O(n)

4. Find all missing numbers

Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren’t present.

5. Modified Maximum Sum subsequence

Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

Programming Problems 2

1.Print Siblings

Problem is to find print all the nodes at the same levels of a binary tree.Inputs given are root pointer and the pointer to the node (let it be A)whose level elements need to be printed

2. Pairwise Sum

If pairwise sums of ‘n’ numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1
Example:
i/p:
4
4 5 7 10 12 13

o/p:
1 3 4 9

3. Maximum Sum Sub-matrix

Given a integer matrix of size m*n. We need to find a sub matrix with the largest sum.

4. Sort the Stack

Given a stack S, write a C program to sort the stack (in the ascending order).

5. Tree Sum

Given a tree and a sum, write an algorithm to return TRUE if there is a path from the root node down to a leaf such that adding all values of the nodes along the path equals the given sum.

6. IsRotation in 1 statement

Given a string s1 and a string s2, write 1 statement to say whether s2 is a rotation of s1?

i.e. printf( (<code_here>?”YES\n”:”NO\n”);

7. Tricky Merge

Given a array of size M+N in which first M numbers are sorted and last N spaces are vacant. Another array of size N which is sorted. Now merge these two arrays without using any extra space so that the array of M+N size is sorted. Optimize it to hav complexity M+N.

Programming Problems 1

Any doubts or clarifications regarding the solution to these problems can be posted in comments.

1. Unlucky Numbers

There are few numbers considered to be unlucky(It contains only 4 and 7. ). Our goal is to find count of such numbers in the range of positive integers a and b.
For Example:
Input:: a = 10 b = 20
Output:: 0

Input:: a = 30 b = 50
Output:: 2 (44, 47)

2. Ideal String
An ideal string is a string where the 1-based index of the first occurrence of each letter is equal to the number of occurrences of that letter in the string. For example, the “BAOOOA” is an ideal string (quotes for clarity only). The letter ‘B’ appears 1 time, and its index is 1. The letter ‘A’ occurs 2 times and its first index is 2. The letter ‘O’ occurs 3 times and its first index is 3.

Given an int length, return the lexicographical smallest ideal string of that length containing only uppercase letters (‘A’-‘Z’). If there are no such ideal strings of that length, return an empty String instead.

PS: A possibly optimal solution to this problem has been provided here. Do post any comments/issues/improvements to it in the comments. Will try to post the code as well.

3. Next Palindrome
Find the next palindrome. Input is an integer and output should be the palindrome integer which is higher than the input.

Example:
Input: 12345
Output:12421
Input:111
Output: 121

4. Maximize the Time to see TV
There is a TV avid person. HE wants to spend his max time on TV. There are N channels with different program of different length and diff times. WAP so that the person cam spend his max time watching TV.
Precondition: If that person watches a program, he watches it completely.

Ex:
Channel1: prog1 – 8:00- 8:30
prog2: 9:00 – 10:00
prog3: 10:15 – 12:00

channel2: prg1 – 8:15 – 10:00
prg2: 10:30 – 12:00

So in this case max time will be if he watches:

ch2/prg1 + ch1/prg3

%d bloggers like this: