Some sort of algorithm. The position where the 2's and 4's spawn are random, so I doubt you can ensure it will always work. You have good chances in succeeding though.
A guideline Tetris metaphor: In Ultra (score as many points as possible within ~2 minutes), you can freestyle - or you can use techniques like ZT stacking or infinite T-Spin Triples. Latter is more efficient (more efficient use of T pieces). Chapeau to everybody who manages to get 2048 points with freestyling!