The Friendship Algorithm
The Big Bang Theory Season 2 Episode 13 (01/19/09)
In order to get time on the super computer at work that he needs for his experiment, Sheldon must befriend Kripke who is in charge of the device. Kripke initially rejects Sheldon as a friend and he goes on a quest to figure out how to make friends. He starts off by asking each of his friends (and Penny) why they like him using a 200+ question test and essay.
When no one takes his exam seriously, Sheldon heads to the bookstore to find a book on making friends. Turns out all the books are for little kids and he checks out a children's book from which he creates an flow chart for making friends. He tries out his new research on Kripke and they arrange to do an activity which Sheldon finds the least offensive, rock climbing.
At rock climbing, Sheldon passes out halfway up the wall due to his fear of heights. Kripke takes him back to his place where the guys are eating dinner. While sharing a meal, Kripke says that him and Sheldon are friends now so he asks to use the computer. Kripke says he has no control over who gets to use it and their friendship is over.