trial and error
An attempt to accomplish something by trying various means until the correct one is found. for example, The only way to solve this problem is by trial and error. The error here alludes to the failed means or attempts, which are discarded until the right way is found. [c. 1800]