Thursday, November 17, 2011

Obfuscated Sudoku Solving

While hunting on the internet, I found out a great site run by Reid Horuff who is a student at the Texas Tech University. I was astonished seeing him write a code to solve a sudoku grid within 20 lines.

Applying Obfuscated C Code concepts and some good old recursion, he achieved what programmers would go into orgasms after viewing.

I would like to provide the link for this site so that you could go into his site and watch the maestro's thoughts and works.

I am posting the C code down here so that you may try them out yourself.

-------------------------------------------------------------------------------------------------------------

int g[81][11];

int tile(int x)
{
 int a;
 for(a=1; a<10 && x<81 && !g[x][10]; a++)
  g[x][a] = 1;

 for(a=0; a<9 && x<81 && !g[x][10]; a++)
  g[x][g[x/9*9+a][0]] = g[x][g[x%9+9*a][0]] = g[x][g[x%9/3*3+x/27*27+a/3*9+a%3][0]] = 0;

 for(a=0; a<10 && x<81; a++)
  if(g[x][a])
  {
   g[x][0] = a?a:g[x][10];

   if(tile(x+1))
    return printf(x%9?"%d ":"%d \n",g[x][0])|1;
  }

 g[x][0] = g[x][10];
 return x>80;
}

int main()
{
 int x;
 char c[9];
 for(x=0; x<81 && (x%9 || scanf("%s",c)|1); x++)
  g[80-x][10] = g[80-x][0] = (c[x%9]-48);

 return tile(0);
}
Please check this out.

Adieu

Tuesday, November 1, 2011

New algorithm could substantially speed up MRI scans

Magnetic resonance imaging (MRI) devices can scan the inside of the body in intricate detail, allowing clinicians to spot even the earliest signs of cancer or other abnormalities. But they can be a long and uncomfortable experience for patients, requiring them to lie still in the machine for up to 45 minutes.

Now this scan time could be cut to just 15 minutes, thanks to an algorithm developed at MIT’s Research Laboratory of Electronics.

MRI scanners use strong magnetic fields and radio waves to produce images of the body. Rather than taking just one scan of a patient, the machines typically acquire a variety of images of the same body part, each designed to create a contrast between different types of tissue. By comparing multiple images of the same region, and studying how the contrasts vary across the different tissue types, radiologists can detect subtle abnormalities such as a developing tumor. But taking multiple scans of the same region in this way is time-consuming, meaning patients must spend long periods inside the machine.

In a paper to be published in the journal Magnetic Resonance in Medicine, researchers led by Elfar Adalsteinsson, an associate professor of electrical engineering and computer science and health sciences and technology, and Vivek Goyal, the Esther and Harold E. Edgerton Career Development Associate Professor of Electrical Engineering and Computer Science, detail an algorithm they have developed to dramatically speed up this process. The algorithm uses information gained from the first contrast scan to help it produce the subsequent images. In this way, the scanner does not have to start from scratch each time it produces a different image from the raw data, but already has a basic outline to work from, considerably shortening the time it takes to acquire each later scan.

To create this outline, the software looks for features that are common to all the different scans, such as the basic anatomical structure, Adalsteinsson says. “If the machine is taking a scan of your brain, your head won’t move from one image to the next,” he says. “So if scan number two already knows where your head is, then it won’t take as long to produce the image as when the data had to be acquired from scratch for the first scan.”

In particular, the algorithm uses the first scan to predict the likely position of the boundaries between different types of tissue in the subsequent contrast scans. “Given the data from one contrast, it gives you a certain likelihood that a particular edge, say the periphery of the brain or the edges that confine different compartments inside the brain, will be in the same place,” Adalsteinsson says.

However, the algorithm cannot impose too much information from the first scan onto the subsequent ones, Goyal says, as this would risk losing the unique tissue features revealed by the different contrasts. “You don’t want to presuppose too much,” he says. “So you don’t assume, for example, that the bright-and-dark pattern from one image will be replicated in the next image, because in fact those kinds of dark and light patterns are often reversed, and can reveal completely different tissue properties.”

So for each pixel, the algorithm calculates what new information it needs to construct the image, and what information — such as the edges of different types of tissue — it can take from the previous scans, says graduate student and first author Berkin Bilgic.

The result is an MRI scan that is three times quicker to complete, cutting the time patients spend in the machine from 45 to 15 minutes. This faster scan time does have a slight impact on image quality, Bilgic admits, but it is much better than competing algorithms.

The team is now working to further improve the algorithm by speeding up the time it takes to process the raw image data into a final scan that can be analyzed by clinicians, once the patient has stepped out of the MRI machine. Using standard computer processors, this final step currently takes considerably longer than with conventional MRI scans.

But the researchers believe they can reduce this calculation time down to the same as that of conventional MRI scans using recent advances in computing hardware from the gaming industry. “Graphics processing units, or GPUs, are orders of magnitude faster at certain computational tasks than general processors, like the particular computational task that we need for this algorithm,” Adalsteinsson says.

A student at the laboratory is now working to implement the algorithm on a dedicated GPU, he says.

Dwight Nishimura, the director of the Magnetic Resonance Systems Research Laboratory at Stanford University, says Adalsteinsson's group has done some very interesting algorithmic work. “This work is potentially of high significance because it applies to routine clinical MRI, among other applications,” he says. “Ultimately, their approach might enable a substantial reduction in examination time.”

Source : MIT News

Tuesday, October 25, 2011

A non-Nobel Story................

This article has been shamelessly taken over from The Telegraph....



Wade through any of the standard encyclopaedia or reference book published from London or New York running into 1,500 to 2,000 closely-printed pages and with possibly 25,000 entries or thereabouts. You are sure to find two separate entries, one for Enrico Fermi and another for fermion, the subatomic particle named after him. To satisfy curiosity, you turn back the pages until, yes, you do find an entry under ‘boson’; it is described as another subatomic particle with properties distinct from those of fermion; there may even be a reference to the fact that forces carrying such particles as photons, gluons and gravitons are all bosons. Almost as an afterthought, it will be mentioned that boson is named after an Indian physicist, Satyendra Nath Bose. It is though not considered worthwhile to accord him a separate entry, unlike in the case of Fermi. The reason is straightforward. The Italian-born physicist, besides having a role in putting together the first nuclear reactor in the United States of America, had won the Nobel Prize; Bose had not.
It is not for an encyclopaedia or a reference book to take into account the environment in which Bose tracked down bosons almost a decade ahead of Fermi’s discovery of fermions. A fledgling department of physics in a fledgling new university at Dhaka, even the minimal equipment were yet to be assembled in the laboratory, scientific journals from overseas were arriving in driblets, Satyendra Nath Bose’s most dependable capital asset was the precision with which he sorted out his mathematical thoughts, the only person he could quietly discuss with when stuck with a problem was himself.
He was, however, not allowed even that quiet. It is a lurid story, but deserves to be told to illustrate the kind of petty-mindedness that marked the relations between communities in the colonial era. Bengali Hindu nationalism reached its apotheosis in the swadeshi movement. It succeeded, in a manner of speaking: the 1905 decision to carve out of Bengal Presidency a separate province, East Bengal, which was to be joined with Assam, was abandoned in 1911 even as the country’s administrative centre was shifted from Calcutta to Delhi. While the ‘nationalists’ celebrated, Muslims in general were disappointed. It was important for the raj to assuage their hurt feelings. The foreign masters had a brainwave. The new township at Ramna, right across Dhaka city proper, had all the infrastructures needed for a university enclave, its new secretariat building, architecture half-Mughal and half-ersatz Gothic, with its winding, seemingly-unending corridors, provided assurance of more than adequate space for lecture and office rooms. Equally handy for meeting the residential requirements of the faculty were the indolent-looking bungalows intended for occupation by senior civil servants who were to be functionaries of the now-aborted provincial government. Acres and acres of khas land were also available for further construction activities. If the minority community were to be denied their province, why not gift them a university instead by availing of the physical facilities made ready for the provincial government that did not finally come up? A decision was quickly arrived at, and preparatory work on the new university started in earnest as soon as World War I ended. The intention was to create an institute of the highest academic excellence, something along the lines of Oxbridge, featuring halls of residence. A don from Cambridge was invited to be the first vice-chancellor, and he was encouraged to gather the best faculty from all over the country as well as from overseas. To help him in the matter, salary scales suggested for the faculty were alluringly high. For instance, a full professor was offered the time scale of Rs 1,000-2,000 and a reader that of Rs 800-1,500. Such high scales were unheard of in all other universities in British India and caused some heart-burning. The authorities were undeterred: they wanted to demonstrate to the Muslims that they, the foreign rulers, would always remain solicitous of the interests of the minority community, which is why a galaxy of first-rate scholars capable of generating an academic ambience that would be the envy of the rest of the country was being assembled.
There was, in fact, plenty of feeling of envy and resentment elsewhere in the country, most of all in Calcutta, particularly within the precincts of the Calcutta University, where Asutosh Mookerjee was the presiding deity. Mookerjee had opposed tooth and nail the establishment of a new university in Dhaka; and for two reasons. He was concerned that, with the setting up of this second university in the province, the educational empire he had built through his supreme overlordship of the Calcutta University was likely to come under severe threat. His second reason reflected the archetypal attitude of an upper-class Bengali Hindu: taking the message of higher education to the Muslim community, Asutosh Mookerjee was convinced, was like displaying pearls before animals of the lowest species.
He failed in his mission to prevent the founding of the University of Dhaka. And, of course, he was outraged by the luscious salaries for the faculty Dhaka proposed and which he could not compete with. He made it known that it would be considered an unfriendly act if any member of the Calcutta University teaching staff, or, for the matter, any alumnus of the university, joined the University of Dhaka. He was truly a holy terror in those times in Bengal’s academic circles. Most obeyed his writ. A few, nonetheless, either for financial reasons or in the hope of superior research opportunities, dared to defy. These few include the young scientists, Satyendra Nath Bose and Jnan Chandra Ghosh as well as the young historian, Ramesh Chandra Majumdar.
Bose joined at Dhaka as the new university started functioning from the academic year 1921-22. As reader in the department of physics, he drew a monthly salary of Rs 800 in the scheduled scale. The science faculty was located on the Curzon Hall premises, which were separated from the main university building by the sprawling sports complex. Curzon Hall, a beautiful colonial structure, was surrounded by trees and foliage; there was also a quadrangular water-body of ample dimension abutting one side of it. The milieu was as tranquil as it could be. There were only a handful of students in those inaugural years and relatively light teaching and laboratory assignments. Bose, then at the peak of his intellectual powers, plunged into unravelling the mysteries of particles.
Those burning with envy in the provincial capital had other designs. The Montagu-Chelmsford reforms, awarding a whiff of extremely restricted self-governance in the form of an executive council with some native representation to advise the governor, had meanwhile been ushered in. The member of the executive council in charge of finance was a successful barrister, B.C. Mitter, a former student of Asutosh Mookerjee. One of the first decisions he was prevailed upon to announce was a scaling down, supposedly on ground of acute financial stringency, of the salary scales for the staff of the University of Dhaka. A professor would no longer be entitled to the grand grade of Rs 1,000-2,000, the salary was henceforth to be pegged at Rs 1,000 with no yearly increment. The grade for the reader was lowered from Rs 800-1,500 to Rs 500-800. The governor chose not to intervene, and the circular went out notifying the reduced scales.
Satyendra Nath Bose’s research on the properties of a subatomic particle he had got a hunch of was rudely disturbed. An embarrassed vice-chancellor wrote to Bose to inform him about the lowering of his monthly salary from Rs 800 to Rs 500. This was of course in breach of contract. What was far more serious, it completely upset his personal financial calculations, which entailed maintaining separate establishments in Dhaka and Calcutta. For over a stretch of three months, he would tear himself away from mathematical formulae and sit down to compose, in longhand, letters to the vice-chancellor on the unfairness of what had been communicated to him. The vice-chancellor, who had all his sympathies for Bose and was desperately anxious not to lose the brilliant young physicist, could, in response to Bose’s letters only repeat his helplessness to reverse the government decision. Bose, in turn, would convey his inability to continue on the reduced salary. The correspondence went ding dong, dong dong; adieu to research.
All of a sudden, another turn of the wheel. Bose had sent a paper incorporating some of the early results he had obtained to Albert Einstein with a request to place it in a well-known German scientific journal. Einstein’s excitement knew no bounds on reading the paper, which answered several of the questions he himself was grappling with. Einstein scribbled a hurried postcard thanking and congratulating Bose for his contribution, which was a major breakthrough in man’s quest to learn what lies behind creation.
That postcard was instrumental in frustrating the machinations of those blinded by sectarian malice. Was it not from no less than a Nobel laureate? Had he not testified to the depth of Bose’s learning and the importance of his work? Satyendra Nath Bose was overnight made professor with a salary of Rs 1,000 per month.
Every bit of this episode from the annals of colonial faction-ridden India is based on hard fact, just as it is hard fact that Bose does not find a place in standard reference books because the Nobel committee had passed him over, and he needed the patronage of one whom the committee did not pass over to ensure his continuance at the University of Dhaka and find the tranquillity needed to explore further into the world of what subsequently got known as Bose-Einstein statistics.

Friday, August 19, 2011

Writing C/C++ code in Vi Editor

Vi Editor happens to be one of the oldest editors which is still shipped with all the flavors of Linux. It was written by Bill_Joy of the Sun Micro systems and Java fame. It was written using the favorite C language and now I am going to show you how to write and edit C code in the Vi editor and them compile it in the shell using the famous GCC compiler.

1. First you fire up your Linux machine. Open your terminal window

2. Type vi
If the file exists , it will be reopened and if the file does not exists it will be created and blank page will be open



3. Press 'i' or Insert button in your keyboard. SO that you are in writing mode from command  mode. Generally Vi Editor was designed to be used completely from the keyboard , hence Vi editor has loads commands. A list of such commands can be found here.

4. Also you can try out a book called Mastering Vi . You can get this book HERE.

5. After you have finished writing your C code. You can press ESC in your keyboard and return back to command mode. Write ":wq" (without quotes) in the command mode . the 'w' command is used to save the file and 'q' command is used to quit the editor and return to the shell. When both the commands are fused together, it will save the file and quit from the editor to the shell.



6. Type the command : "gcc " and press Enter. If your program has no syntax error , then you will end up with another prompt.



7. Then type "./a.out' and press Enter. You can see the output of your code ;)



EXCEPTIONS.....

If you are bored of continuously giving in ./a.out , then you can type :gcc -o and press Enter.

Then you can type filename.out in the prompt and get the output.


If your code is not bug free  then you type in "vi " into the shell which will again open up your vi editor and you can recheck your code and then follow the above procedure.

                                                                                                                 Adieu

HOW TO DESTROY AN ORGANIZATION????

Recently I am interested in knowing how to destroy a company or an organization. I am hell into searching to know how best can someone from the outside come and disrupt a company to bankruptcy and then end it totally....

Not in a way such as the person gets into an organization and then breaks it down but someone from the outside does it.

If YOU guys have any idea then please please please do inform me in this blog as a comment..

                ADIEU

Sunday, July 24, 2011

Algorithms shape the world

Recently I had an inspiring view of a video by Kevin Slavin..

Kevin Slavin is one of the founders of areaCode.. A gaming company which produces games based on numbers.

In a recent TED talk..... He said that "We are now writing algorithms without even having a clear understanding of the consequences"

Today we have algorithms control everything in our life.

Stock Markets , Financial Data , even the choice of our films (Netflix , an online DVD rental company uses Pragmatic Chaos algorithm to determine what kind of movie the viewer would like to watch next) and many more information is being run by clever algorithms. The catch is that now there are several algorithms on work and as well as they have increasing complexity. They sometimes contradict each other and result in catastrophe.

Like the FLASH CRASH of 2:45 in which the 9% of the financial data of the American Stock Market disappears and nobody knows to this day where the data is. Result of a disastrous algorithm clash.



A quantifying algorithm called STORY ALGORITHM has the ability to determine what is the valuation of your story if you are interested to convert it into a movie. Any Hollywood film director would want to put in his/her story and find out whether it is a $ 30 million or a $ 200 million movie. An algorithm which has the ability to bring out algorithmically our culture.  To determine our tastes and to evaluate a story on the basis of a concept  as subtle as a culture.

I wont write much here. All of the above things I wrote were to give you a boost to look into the video. I have provided with the link of the video :


Saturday, July 23, 2011

Enlightening TED Talks on Computer Science

TED is a nonprofit organization that has dedicated itself to the concept that good ideas are worth spreading. To promote these great ideas, TED (which stands for Technology, Entertainment, Design) has a yearly conference in Long Beach, California. While the conference is too expensive for most people to attend, at $6000 per person, TED has used the Internet to share talks from the conference since 2006.

These are free of charge to the public and an amazing resource for professionals in many fields. Computer scientists will find these 20 TED speeches (not ranked in any particular order) informative, challenging, and stimulating. Maybe an idea worth spreading will help you make the connection you’ve been looking for in your own computer science research.

Given below are list of 20 highly informative speeches Computer Science speeches by the stalwarts of Computer

1. George Dyson on birth of Computers

Have you ever heard the real stories about the dawn of computing? Sure, you have probably memorized important dates and can talk about things like vacuum tubes and punch cards, but do you really know what went on at the beginning? In this enlightening talk, computer historian George Dyson reveals fascinating and sometimes funny anecdotes about the beginning of computing.

2. Kwabena Boahen on a computer that works like a brain

Kwabena Boahen’s team at Stanford is working on computer technology that works less like a computer usually does, and more like the human brain does. He discusses the inefficiencies associated with traditional computing and ways that they might be overcome using reverse engineering of the human nervous system.

3. Jeff Han demos his breakthrough touchscreen | Video on TED.com

Jeff Han’s incredible speech from 2006 shows the future of touch-screen interfaces. His scalable, multi-touch, pressure-sensitive interface allows people to use the computer without the barriers of having to point and click all the time.

4. Paul Debevec animates a photo-real digital face | Video on TED.com

Paul Debevec explains the process behind his animation of Digital Emily, a hyper-realistic character. Digital Emily is based on a real person named Emily, and created using an advanced 360-degree camera setup.

5. Stephen Wolfram : Computing a theory of everything

In this mind-boggling speech, Stephen Wolfram, a world-renowned leader in scientific computing, discusses his life’s mission. He wants to make all of the knowledge in the world computational. His new search engine, Wolfram|Alpha, is designed to take all of the available information on the web and make instant computations of that information accessible to the world.

6. Dennis Hong: My seven species of robot 

As artificial intelligence technology continues to evolve, the quest continues to create robots that are truly useful on a scientific and on an ordinary, day-to-day level. Dennis Hong’s RoMeLa lab at Virginia Tech presents seven distinctly different robots in this talk. Make sure you watch all the way to the end to discover his secrets of creativity.
7. Gary Flake : Is PIVOT the turning point for web exploration??

Gary Flake believes that the whole of all data we have is greater than the sum of its parts. He and the staff at Microsoft Live Labs have created a fascinating new tool called Pivot that enables people to browse the web not by going from page to page, but by looking at large patterns all at once.

8. Margaret Wertheim on beautiful math of corals

Crochet would not ordinarily seem to be a topic that computer scientists should be concerned about. But as Margaret Wertheim explains, crochet was an ideal medium to represent the hyperbolic, non-Euclidean geometry that Nature puts on display daily in coral reefs. Her idea that mathematicians and scientists need to keep their minds open to “play” as a tool for encouraging creativity is one that computer scientists should heed.

9. Lalitesh Katragadda : Making Maps to fight disasters and build economies

In this brief talk, Lalitesh Katragadda discusses the value of new computer tools such as Google Mapmaker to make maps of the 70% of Earth still unmapped. He explains that after natural disasters, it can be difficult for aid to reach these unmapped areas. Using Google Mapmaker, people can take the initiative to map local areas for global access.

10. Henry Markram builds a brain in a super computer

Henry Markram is a computer scientist who is leading a team of scientists on a mission to build a brain. They want to design a complete, functioning supercomputer model of the human brain in order to improve diagnostics and better understand how the brain works.

11. David Hanson : A robot that shows emotion

In his brief speech, David Hanson introduces the audience to his new robots that are able to express emotion and respond to human emotion using complex software. By responding to the emotion of humans, the robots actually exhibit something that appears to be empathy.

12. Demo : Stunning Data visualisation in the allosphere

The AlloSphere is a three-story sphere created by Joann Kuchera Morin and a team of artists and computer scientists, located at the University of California-Santa Barbara. In this fascinating six-minute tour, Kuchera Morin shows the audience possible applications, from mapping the human brain to converting abstract concepts into sight and sound.

13. Paul Rothemund details DNA folding | Video on TED.com

Paul Rothemund uses the simple metaphor of origami to explain how he and his team have discovered the process of DNA folding. According to Rothemund, using this process, we can start to design tiny, self-replicating machines. The implications for computer science are enormous.

14. Torsten Reil builds better animation

Torsten Reil’s speech discusses the complex software his company has created to make animated characters in video games and movies more realistic. By adding a simulated nervous system and artificial intelligence to animations, they are able to achieve a much more believable result.

15. David Merrill shows Sift Tables

Remember those ABC blocks we all had when we were kids? What if they could change, so that they weren’t just ABC blocks, but they were equation blocks, or color blocks, or story blocks? That is what MIT graduate student David Merrill has invented with Siftables, interactive computer blocks that communicate with one another.

16. Alan Kay shares a powerful idea about ideas

Alan Kay has been a pioneer in computer science since the 1960s, helping companies like XeroxPARC, Apple, Atari, Disney, and HP change the way we use technology. This insightful and inspiring talk reveals new ways that we can use computers to educate the next generation.

17. Jeff Hawkins on how brain science will change computing

Jeff Hawkins created the Palm and Treo PDAs, but his passion lies in brain research. He believes that brains work as a kind of deep memory system instead of as a series of processes. In this talk, he discusses how the future of computers depends on being able to study, understand, and mimic the way the brain really works.

18. Peter Hirshberg on TV and the web | Video on TED.com

Peter Hirshberg has spent the last 25 years studying the emergence of the Internet and helping businesses adapt to the medium’s changing demands. In this engaging talk, he discusses the evolution of television alongside the evolution of computers. He also explores the reasons why the Web has made the computer so much more than a fancy replacement for TV.

19. Blaise Aguera y Arcas shows Photosynth

Microsoft software engineer Blaise Aguera y Arcas shows the audience at TED his new software Photosynth. Photosynth is a powerful new interface which allows photos from all over the Web to be linked together in a spatial manner.

20. Tim Berners Lee : The year data opened world wide

Any serious student of computer science knows that Tim Berners-Lee’s most well-known accomplishment is the invention of the World Wide Web. His continued mission is to inspire others to use it for good—that is, for governments, schools, and scientists to make as much raw data as possible available to the public. This TED talk explores some of the results from 2009.

Aptly said ............. "IDEAS WORTH SPREADING..."

                                                                                  Adeiu

PS : Source : Internet (Obviously) and TED