Season 2, Episode 13 - The Friendship Algorithm
Aired January 19, 2009
Sheldon wants to use the university's grid computer for his research, but access to the computer is controlled by Barry Kripke who apparently favors his friends. Sheldon decides to befriend Kripke, but struggles from a lack of experience in making friends. Treating this like any other scientific inquiry, Sheldon studies up and develops a friendship algorithm.