I so relate to this. I worked for months trying to conjure a unique finger printing system for a fun project that I was working on. After months of trying, I eventually came upon a system. Only to find that Cantor had already solved it. A couple hundred years ago! Months of effort could have been saved. Only if I knew math history better. But the feeling of exhilaration at the discovery is exactly what you describe here!