Code a self-documenting pangram in any programming language of your choice
Source: #-Link-Snipped-#
A pangram is a sentence which contains every letter of the alphabet. A self-documenting pangram is one which follows the general format of:
This sentence contains a's, b's, c's, ...
For example:
Only a fool would check that this sentence contains exactly six 'a's, one 'b', six 'c's, three 'd's, thirty-four 'e's, five 'f's, two 'g's, ten 'h's, thirteen 'i's, one 'j', two 'k's, five 'l's, one 'm', twenty-two 'n's, seventeen 'o's, one 'p', one 'q', seven 'r's, thirty-two 's's, twenty-six 't's, three 'u's, seven 'v's, eight 'w's, six 'x's, seven 'y's, and one 'z'.
Challenge: Code a self-documenting pangram in any programming language of your choice.
PS: A well commented code is expected.![[IMG]](proxy.php?image=http%3A%2F%2Fwww.crazyengineers.com%2Fforum%2Fimages%2Ficons%2Ficon14.gif&hash=3feb3cc32d20db15210fb0dad9085448)
A pangram is a sentence which contains every letter of the alphabet. A self-documenting pangram is one which follows the general format of:
This sentence contains
For example:
Only a fool would check that this sentence contains exactly six 'a's, one 'b', six 'c's, three 'd's, thirty-four 'e's, five 'f's, two 'g's, ten 'h's, thirteen 'i's, one 'j', two 'k's, five 'l's, one 'm', twenty-two 'n's, seventeen 'o's, one 'p', one 'q', seven 'r's, thirty-two 's's, twenty-six 't's, three 'u's, seven 'v's, eight 'w's, six 'x's, seven 'y's, and one 'z'.
Challenge: Code a self-documenting pangram in any programming language of your choice.
PS: A well commented code is expected.
![[IMG]](proxy.php?image=http%3A%2F%2Fwww.crazyengineers.com%2Fforum%2Fimages%2Ficons%2Ficon14.gif&hash=3feb3cc32d20db15210fb0dad9085448)
Replies
-
sumitjamidoes this mean we have to write a program which counts the no of a`s ,b`s ,c`s........in it`s source code and in the end prints a line
"This sentence containsa's, b's, c's, ... "
??????????????????? -
Ashutosh_shuklaAm i supposed to code a program that starts with "Only a fool would check that"
and finish up with your sentence ? Please can you make it clear? 😕 -
shalini_goel14Hello Mr. Ashutosh,
We are supposed to write a program that starts with any given sentence (Lets say "Only a fool would check that this sentence contains exactly " )followed by'a's , 'bs'........so on.The tricky part lies in that should be in words and count of alphabets in those words should also be included.
If you see the example given
Only a fool would check that this sentence contains exactly six 'a's, one 'b', six 'c's, three 'd's, thirty-four 'e's, five 'f's, two 'g's, ten 'h's, thirteen 'i's, one 'j', two 'k's, five 'l's, one 'm', twenty-two 'n's, seventeen 'o's, one 'p', one 'q', seven 'r's, thirty-two 's's, twenty-six 't's, three 'u's, seven 'v's, eight 'w's, six 'x's, seven 'y's, and one 'z'.
There are total 5 'f's we will be given only sentence 'Only a fool would check that this sentence contains exactly' rest part of the sentence we have to generate with our code.
I think now you would have got what we are supposed to code for?😀
-
Ashutosh_shuklaSo i guess my program starts with a given statement that "Hi my name is ashutosh and this sentence contains exactly" & rest generated by program.I will try to write the code now as soon as i get time to do it.
-
sean_26
Thanks for your informative posting.shalini_goel14Hello Mr. Ashutosh,
We are supposed to write a program that starts with any given sentence (Lets say "Only a fool would check that this sentence contains exactly " )followed by'a's , 'bs'........so on.The tricky part lies in that should be in words and count of alphabets in those words should also be included.
If you see the example given
There are total 5 'f's we will be given only sentence 'Only a fool would check that this sentence contains exactly' rest part of the sentence we have to generate with our code.
I think now you would have got what we are supposed to code for?😀
-
shalini_goel14Hi All,
I was trying to code for it.It is just like solving one of the other puzzles posted by our Big Boss 😉. I am stucked in a situation
When I am counting the letters for e.g. I count the letters 'e' and suppose I get its count as 13(thirteen) total in pangram excluding its own(2 'e's).
Now I increment the count of letters accordingly t+h+i+r+t+e+e+n
t by 1+1
h by 1
i by 1
r by 1
e by 1+1
n by 1
Now suppose i get count of 't' as 20(twenty). Again the count of e will change which will ultimately change the count of 't',then how should i deal with such a cyclic counting .Can anyone give any ideas?? 😔 -
Ashutosh_shuklaHi all I seem to be visiting quite often these days anyways coming back to this thread I would like to suggest a logic that i thought of
You can have a string passed as an argument to a function.Now you will require an array to store the count of alphabets. Also you pass the string first time as original one say "Only a foll would check that this sentence contains only" and the function would find the counts and store in array.
Now the next time the string passed would be Only a fool would check that this sentence containsa's and so on.
You keep calling the function until the array contents before and after the function call are same.This is a logic that i thought of using the basic control structures and the recursive function calls if someone has any other idea he/she is welcome to share it.
I wanted to code this one but due to lack of time i could not.
I hope this helps you people and someone tries to code this one. -
shalini_goel14You are right, even I have also tried in the same way ,but in any case you will face the situation I described earlier(cyclic count dependency). Do you have any idea how to overcome it?😔
-
Ashraf HZHmm, pretty interesting! Good luck people 😀
(tries to boot up Python..) -
Ashutosh_shuklaI think if you keep calling the function then at a certain stage you will get the answer I guess once we should work it out ourselves on paper and then code to give it to computer.First check whether our logic is really working then code.and ya please send me code if possible I would like to see what you have done.
😔 -
sumitjamii am rearly eager to see the code coz i am just not able to figure out the actual logic.....
You are reading an archived discussion.
Related Posts
hi , i am doing third year mechanical. there is a mini project this year... so anyone can help me out with ideas😕
is it possible to design a simple household burglar alaram in mechanical...... if possible how?😕
hi ppl
im a mechanical engineer.( studying )
my interests r in the field of mechatronics / robotics..
need some help & guidance 2 make a career out of it....
You have won Key chains
You have won T Shirts
But have you ever won Hard Cash? 😁
India’s first Social Messenger - presents “Student Brand Ambassador Program” for...
hey guys can anyone help me out here with this meter problem im getting?? i have a digital electricity meter ,now there is a port on the front of the...