A few days ago I was trying to solve something in our codebase and I wasn't exactly sure how to do it, a had a few ideas, but I didn't know if they would really work or not.
So, for one of the proposals I wrote a minimal working solution, it was quite a good amount of code, when it was working I even refactored it a little bit improving a few failure cases, but nothing too extreme, just the simple cases.
In the end, I decided not to use that solution, it worked but was more complex than what I needed at the time. But it was hard to "feel" that complexity without having at least minimal code running, when I set up to write that code I knew that maybe it wouldn't be used, maybe it wouldn't work, maybe it wasn't the right solution, maybe it wouldn't perform good enough, maybe it would be too complex.
I had to see it in action first to know that answer, and it may seem like a waste of time, but I did gain experience from it, and the codebase improved by being able to use a simpler solution.
So the next time you're confronted with a challenging piece of code, don't worry about trying some solutions knowing that maybe they won't last for long or won't be used, but they are a step to find the right one (at least for the time being :D).