This question already has an answer here:

I want to write a program for mining, and my question is: anything that goes through hashes and gives an output with 18 zeros at the beginning is acceptable or the input must have a specific structure? and when I find the correct input where should I submit that to get bitcoin?

marked as duplicate by Nate Eldredge, Alin Tomescu, pebwindkraft, Adam, Mark S. Jan 28 '18 at 16:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.