Skip to main content

Posts

Showing posts from February, 2014

Very interesting algorithm...

Wracked my brains for over half a day on this one to arrive at some definitive conclusion.... The problem statement is to find the Nth prime above a certain threshold number. For example, find the 306th prime no. Here is the solution : //Find the Nth prime number above 50... int nc=0; int j = 50; while (true) { j += 1; if ((j % 2) == 0) { continue; } else if (((j % 3) == 0)) { continue; } else if (((j % 5) == 0)) { continue; } else if (((j % 7) == 0)) { continue; } else if (((j % 11) == 0)) { continue; } else if (((j % 13) == 0)) {

Very interesting algorithm...

Wracked my brains for over half a day on this one to arrive at some definitive conclusion.... The problem statement is to find the Nth prime above a certain threshold number. For example, find the 306th prime no. Here is the solution : //Find the Nth prime number above 50... int nc=0; int j = 50; while (true) { j += 1; if ((j % 2) == 0) { continue; } else if (((j % 3) == 0)) { continue; } else if (((j % 5) == 0)) { continue; } else if (((j % 7) == 0)) { continue; } else if (((j % 11) == 0)) { continue; } else if (((j % 13)

Save the Children...

We need to address the needs of our children regardless of color, caste or creed. Here is a testimony that I am a supporter of a good cause....

Save the Children...

We need to address the needs of our children regardless of color, caste or creed. Here is a testimony that I am a supporter of a good cause....

Good One !

This is an elegant problem...The idea is to find the Nth term in the series where n + R(n) is divisible by 13 and R(n) is the inverted number n. eg) 150 becomes 015. The solution in C# is simple enough..if you think a little... //Reversed Multiples int cn = 0; int lc = 0; while (true) { lc += 1; char[] a = lc.ToString().ToCharArray(); string xa = new string(a.Reverse().ToArray()); if (((lc + double.Parse(xa)) % 13) == 0) { cn += 1; if (cn == 10000) break; } } MessageBox.Show(lc.ToString());

Good One !

This is an elegant problem...The idea is to find the Nth term in the series where n + R(n) is divisible by 13 and R(n) is the inverted number n. eg) 150 becomes 015. The solution in C# is simple enough..if you think a little... //Reversed Multiples int cn = 0; int lc = 0; while (true) { lc += 1; char[] a = lc.ToString().ToCharArray(); string xa = new string(a.Reverse().ToArray()); if (((lc + double.Parse(xa)) % 13) == 0) { cn += 1; if (cn == 10000) break; } } MessageBox.Show(lc.ToString());

Try this algorithm...really cool

Found another good problem...the idea is to find all 6 digit numbers where the sum of the first 3 digits is equal to the sum of the last 3 digits and calculate the total N of these. Here is a function in C# that does the work... public string GetLuckyNos() { string si = String.Empty; ArrayList ar = new ArrayList(); for (int i = 999999; i>=100000 ; i--) { try { int sa = 0; string a = i.ToString().Substring(0, 3); for (int h = 0; h < a.Length; h++) { sa += int.Parse(a[h].ToString()); } int sb=0; string b = i.ToString().Substring(3, 3); for (int h = 0; h < b.Length; h++) { sb += int.Parse(b[h].ToStr

Try this algorithm...really cool

Found another good problem...the idea is to find all 6 digit numbers where the sum of the first 3 digits is equal to the sum of the last 3 digits and calculate the total N of these. Here is a function in C# that does the work... public string GetLuckyNos() { string si = String.Empty; ArrayList ar = new ArrayList(); for (int i = 999999; i>=100000 ; i--) { try { int sa = 0; string a = i.ToString().Substring(0, 3); for (int h = 0; h < a.Length; h++) { sa += int.Parse(a[h].ToString()); } int sb=0; string b = i.ToString().Substring(3, 3); for (int h = 0; h < b.Length; h++) { sb

Another problem - develop an algorithm

The problem statement is to get the largest three digit number that contains as many 1's in it's binary representation as a given three digit number. GetIntBinaryString is a custom function that i found on the net that converts an integer into it's binary string equivalent. public string GetIntBinaryString(int n) { char[] b = new char[32]; int pos = 31; int i = 0; while (i < 32) { if ((n & (1 << i)) != 0) { b[pos] = '1'; } else { b[pos] = '0'; } pos--; i++; } return new string(b); } Here is the core logic developed by me : int cn = 0; int sn = 0; string si = String.Empty; string sit = String.Empty; ArrayList ar = new

Another problem - develop an algorithm

The problem statement is to get the largest three digit number that contains as many 1's in it's binary representation as a given three digit number. GetIntBinaryString is a custom function that i found on the net that converts an integer into it's binary string equivalent. public string GetIntBinaryString(int n) { char[] b = new char[32]; int pos = 31; int i = 0; while (i < 32) { if ((n & (1 << i)) != 0) { b[pos] = '1'; } else { b[pos] = '0'; } pos--; i++; } return new string(b); } Here is the core logic developed by me : int cn = 0; int sn = 0; string si = String.Empty; string sit = String.Empty;

Aphorism for the day

“If a man is called to be a street sweeper, he should sweep streets even as Michelangelo painted, or Beethoven composed music, or Shakespeare wrote poetry. He should sweep streets so well that all the hosts of heaven and earth will pause to say, here lived a great street sweeper who did his job well.” Martin Luther King

Aphorism for the day

“If a man is called to be a street sweeper, he should sweep streets even as Michelangelo painted, or Beethoven composed music, or Shakespeare wrote poetry. He should sweep streets so well that all the hosts of heaven and earth will pause to say, here lived a great street sweeper who did his job well.” Martin Luther King

Science Debates : Should children be debarred from watching horror movies?

Children are generally prohibited from watching horror flicks. Is this prudent in the light of current scientific analysis? Here is the rationale... The frontal lobes of the brain that deal with the rationalization of scary situations are also less developed in very young children. This means they may struggle to make sense of their automatic fear responses. Cortisol released during flight-or-fight responses reinforces memories of the event and, without appropriate frontal lobe controls, this can result in the feeling of fear recurring long afterwards. This might explain why children will often have recurring nightmares after watching a scary movie.

Science Debates : Should children be debarred from watching horror movies?

Children are generally prohibited from watching horror flicks. Is this prudent in the light of current scientific analysis? Here is the rationale... The frontal lobes of the brain that deal with the rationalization of scary situations are also less developed in very young children. This means they may struggle to make sense of their automatic fear responses. Cortisol released during flight-or-fight responses reinforces memories of the event and, without appropriate frontal lobe controls, this can result in the feeling of fear recurring long afterwards. This might explain why children will often have recurring nightmares after watching a scary movie.

Apollo, Zeus et al

Try out the greek mythology quiz at Greek myth quiz My result snapshot is as below :

Apollo, Zeus et al

Try out the greek mythology quiz at Greek myth quiz My result snapshot is as below :

Programming problem - develop an algorithm

Came across this problem on one of the programming websites. The idea is to find the largest sub-string from the given string where the letters are in alphabetical order. Here is the solution in C# : int cn = 1; ArrayList ar = new ArrayList(); string s = "stringtofind"; byte[] asciiBytes = Encoding.ASCII.GetBytes(s); for (int i = 0 ; i < asciiBytes.Length; i++) { try { if (int.Parse(asciiBytes[i].ToString()) <= int.Parse(asciiBytes[i + 1].ToString())) { cn += 1; } else { ar.Add(cn); cn = 1; } } catch { } } MessageBox.Show(FindMax(ar).ToString()); The idea is to

Programming problem - develop an algorithm

Came across this problem on one of the programming websites. The idea is to find the largest sub-string from the given string where the letters are in alphabetical order. Here is the solution in C# : int cn = 1; ArrayList ar = new ArrayList(); string s = "stringtofind"; byte[] asciiBytes = Encoding.ASCII.GetBytes(s); for (int i = 0 ; i < asciiBytes.Length; i++) { try { if (int.Parse(asciiBytes[i].ToString()) <= int.Parse(asciiBytes[i + 1].ToString())) { cn += 1; } else { ar.Add(cn); cn = 1; } } catch { } } MessageBox.Show(FindMax(ar).T

Aphorism for the Day

Reflect...

Aphorism for the Day

Reflect...

Science Debates : Will we ever have cybernations and cybergovernments?

I have decided to shed some light on thought provoking issues in contemporary science.. Just pause to reflect.. As the internet continues to grow exponentially would citizens of the world organize themselves into cybernations administered by cybergovernments ? May be this could be the dawn of a new form of more inclusive governance (and maybe more just?). Please advise.

Science Debates : Will we ever have cybernations and cybergovernments?

I have decided to shed some light on thought provoking issues in contemporary science.. Just pause to reflect.. As the internet continues to grow exponentially would citizens of the world organize themselves into cybernations administered by cybergovernments ? May be this could be the dawn of a new form of more inclusive governance (and maybe more just?). Please advise.

New Quiz - Sports this time - Really cool

Check out the sports quiz at Sports Quiz . You have to register on the site to take the quiz...but worth it. See my result..

New Quiz - Sports this time - Really cool

Check out the sports quiz at Sports Quiz . You have to register on the site to take the quiz...but worth it. See my result..

Electronics For You

I found a very simple electronics problem online and am posting it for your reference. Link to Problem My solution : Principle 1.A diode presents less impedance than a lamp. 2.Current follows the path of least resistance. 3.A diode can conduct only when forward biased. 4.If the frequency of the source is sufficiently high then the eye sees the flashing lights as a continuous source. (persistence of vision). Answers Applying 1,2,3,4. 1.Lamp L2 is ON. 2.Lamp L1 is ON. 3.Both appear to be ON.(though actually they alternate).

Electronics For You

I found a very simple electronics problem online and am posting it for your reference. Link to Problem My solution : Principle 1.A diode presents less impedance than a lamp. 2.Current follows the path of least resistance. 3.A diode can conduct only when forward biased. 4.If the frequency of the source is sufficiently high then the eye sees the flashing lights as a continuous source. (persistence of vision). Answers Applying 1,2,3,4. 1.Lamp L2 is ON. 2.Lamp L1 is ON. 3.Both appear to be ON.(though actually they alternate).

Which bollywood actor are you?

This is truly the baap of all quizzes... Which bollywood actor are you? Bollywood Personality Quiz

Which bollywood actor are you?

This is truly the baap of all quizzes... Which bollywood actor are you? Bollywood Personality Quiz

English vocabulary quiz

How familiar are you with the English Language? Take the 100 question quiz to find out... at Vocab Quiz Here are my results :

English vocabulary quiz

How familiar are you with the English Language? Take the 100 question quiz to find out... at Vocab Quiz Here are my results :

Cute animal quiz

Took a quiz to find out which cute animal I resemble. Here are the results : You Are A: Chipmunk ! Everyone adores these cute woodland animals, known for the stripe that runs down their back. Famously timid, chipmunks will quickly scurry to the safety of their burrows if danger approaches. As a chipmunk, you eat mostly seeds and nuts, but you may sample bird eggs and insects from time to time. You were almost a: Groundhog or a Mouse You are least like a: Duck or a Monkey Cute Animals Test Interesting..huh

Cute animal quiz

Took a quiz to find out which cute animal I resemble. Here are the results : You Are A: Chipmunk ! Everyone adores these cute woodland animals, known for the stripe that runs down their back. Famously timid, chipmunks will quickly scurry to the safety of their burrows if danger approaches. As a chipmunk, you eat mostly seeds and nuts, but you may sample bird eggs and insects from time to time. You were almost a: Groundhog or a Mouse You are least like a: Duck or a Monkey Cute Animals Test Interesting..huh

Ultimate Quiz

Took the ultimate quiz on allthetests.com at Link to Quiz Here are the results :

Ultimate Quiz

Took the ultimate quiz on allthetests.com at Link to Quiz Here are the results :

Political Philosophy Test

Just took a quiz on allthetests.com and got the following result : Got 50%. Here is the link Certificate: Test results Political Philosophy Quiz For 50 % you are: You are a Liberal! Your political idols include Franklin D. Roosevelt and Abraham Lincoln. 56.8454 % of 4178 Quiz participants had this profile! Profile A You could also get this result: For 30 % you are: You are a Communist! Your political idols include Karl Marx and Vladimir Lenin. Profile B Or even this one: For 10 % you are: You are an Anarchist! Your political idols include William Goodwin and Henry David Thoreau. Profile C Or even this one: For 10 % you are: You are a Fascist! Your political idols include Adolf Hitler and Josef Stalin. Profile D Or even this one: For 0 % you are: You are a Conservative! Your political idols include Margaret Thatcher of Ronald Reagan. Profile E   Take this quiz: Political Philosophy Quiz

Political Philosophy Test

Just took a quiz on allthetests.com and got the following result : Got 50%. Here is the link Certificate: Test results Political Philosophy Quiz For 50 % you are: You are a Liberal! Your political idols include Franklin D. Roosevelt and Abraham Lincoln. 56.8454 % of 4178 Quiz participants had this profile! Profile A You could also get this result: For 30 % you are: You are a Communist! Your political idols include Karl Marx and Vladimir Lenin. Profile B Or even this one: For 10 % you are: You are an Anarchist! Your political idols include William Goodwin and Henry David Thoreau. Profile C Or even this one: For 10 % you are: You are a Fascist! Your political idols include Adolf Hitler and Josef Stalin. Profile D Or even this one: For 0 % you are: You are a Conservative! Your political idols include Margaret Thatcher of Ronald Reagan. Profile E   Take this quiz: Political Philosophy Quiz

Heart Quiz

How well do you know your heart? Take this quiz and find out... Heart Quiz My result :-

Heart Quiz

How well do you know your heart? Take this quiz and find out... Heart Quiz My result :-

Astro(nomy) not (logy) quiz

Found this cheeky astronomy quiz to stimulate the central nervous system... Results are as per the graphic:

Astro(nomy) not (logy) quiz

Found this cheeky astronomy quiz to stimulate the central nervous system... Results are as per the graphic:

Try out the expert mode Folks...

Played against the computer on chess.com in the expert mode. Result : Draw &nbsp&nbspNot that bad really....

Try out the expert mode Folks...

Played against the computer on chess.com in the expert mode. Result : Draw &nbsp&nbspNot that bad really....

Doc Post....

Took a medical quiz on lovetoknowquiz.com. Got one wrong. :-( Here is a snapshot of the result

Doc Post....

Took a medical quiz on lovetoknowquiz.com. Got one wrong. :-( Here is a snapshot of the result

Moved up one notch (in chess...)

Today I played the program on chess.com at the medium level...and won. Not so easy if you really give it a thought...

Moved up one notch (in chess...)

Today I played the program on chess.com at the medium level...and won. Not so easy if you really give it a thought...

Maths is fun too...

After several attempts cleared an easy quiz on maths (in KBC format) : Link to Quiz

Maths is fun too...

After several attempts cleared an easy quiz on maths (in KBC format) : Link to Quiz

Easy chess

Some chess programs are easy to beat. Keeps the spirits high.

Easy chess

Some chess programs are easy to beat. Keeps the spirits high.

Guten Tag !

Tried out a very basic German test. Here are the results : Hello You have just accomplished the test 'Test your German' on http://www.allthetests.com with the following results: UNBELIEVABLE! Your knowledge of German is very impressive! You will survive in Germany... if you want to go there. You have correctly answered 9 of 10 questions. On average, 1798 of users who took the quiz gave 7.48 right answers.

Guten Tag !

Tried out a very basic German test. Here are the results : Hello You have just accomplished the test 'Test your German' on http://www.allthetests.com with the following results: UNBELIEVABLE! Your knowledge of German is very impressive! You will survive in Germany... if you want to go there. You have correctly answered 9 of 10 questions. On average, 1798 of users who took the quiz gave 7.48 right answers.

Potential US Citizen :-)

We know a lot about India. But how much do we know about the US? Take the quiz at http://www.history.com/interactives/the-road-to-citizenship-quiz-game Here is my result : PS : I took the quiz twice...

Potential US Citizen :-)

We know a lot about India. But how much do we know about the US? Take the quiz at http://www.history.com/interactives/the-road-to-citizenship-quiz-game Here is my result : PS : I took the quiz twice...

Tips for Othello

Here are my list of do's and dont's for Othello Capture squares at the periphery Capture the corner squares Avoid the second outer row cells parallel to the periphery Just like chess... Capture the center etc.

Tips for Othello

Here are my list of do's and dont's for Othello Capture squares at the periphery Capture the corner squares Avoid the second outer row cells parallel to the periphery Just like chess... Capture the center etc.

Othello - try it out

Cool game...lots of fun to be had...

Othello - try it out

Cool game...lots of fun to be had...