What lessons can people learn from going to prison? originally appeared on Quora: The best answer to any question.

In the 1980s, I had a string of successful sales and marketing companies and lived in the sub-penthouse of a beachfront hi-rise with a wonderful wife. An idyllic life.

How do you go about destroying the fruits of success and freedom of choice some people never experience? Simple. Develop a late-blooming guilty conscience and a disenchantment that manifests as a black hole in your soul. Proceed to indulge your despair with alcohol and then narcotics.

It’s the nature of the illicit drug trade that people combine to buy large quantities of drugs so they can stay away from the street scene and obtain quality product. At the time, state governments were experimenting with prohibition style penalties that involved 25 years mandatory prison for quantities of substances that I used in less than half a day – in the end, not to get stoned, merely to not be sick.

Of course, I was finally caught. Remember, I was still running my companies and thought I had everyone fooled. My office desk had a conference keyhole, then the desk and a hutch. Every edge within my arms’ reach was charred by by the cigarette lighter that I used to smoke heroin on aluminium foil. It takes 100s of hits to smoke a few grams. There’s only so big a rock you can slow boil and inhale. Arrested and imprisoned on remand while awaiting trial for possession of an ounce of 80% pure rock heroin, I was facing 25 years – double what I would have gotten for a murder, five to ten times a manslaughter plea deal.

During 18 months on remand, the War on Drugs laws were repealed. A High Court challenge by pro bono lawyers backed by judges who resisted political interference was successful. Mandatory sentencing did not differentiate between a single mother selling enough drugs to support a habit and a gangster without an addiction, who sold large quantities of drugs for profit. Judges passionately believed it subverted discretion in sentencing. No mercy.

My judge said that since for 18 months I had faced the idea I was doing 25 years, had pled guilty ex officio, waived a trial, and had no prior convictions, he would count the remand time as “double time” and sentenced me to another three years.

There I was, in an old fashioned maximum security stone prison. Maximum security turned out to be a lot less hectic than remand. People settle and trouble only hits when it matters. My survival strategy was to become indispensable to everyone. I did other prisoners’ university assignments for them. Packets of tobacco and anything useful were legal tender. I charmed the guards and gained a free range “chook” pass – one of the most valuable things you can have in prison. Without movement, there is no economy.

Due to “good behavior” I was transferred to a shiny new prison, with clean amenities and no graffiti. Private, corporate-owned prisons were just beginning and the owners of the first facility in the country were anxious to gain economies of scale and build more.

The prison company invested in one-and-a-half-dozen computers, Apple ][+, Apple ][GS, and a few IBM XT clones to keep the prison population happy. I still had university assignments to do for other prisoners and thought it might be easier to do them on a computer than a typewriter.

In my spare time, I started to become curious about what else these machines might do. There was an old, legendary bank robber in charge of the "computer section" who had tired of people showing interest and then not making an effort.

When I asked him for help, he showed me how to kickstart Apple ProDOS and how to draw a line of text across the screen. He spent ten minutes explaining for/next loops, screen width, height in characters and poke. "Now make the line spiral in to the center."

At the end of the day, proud as hell, I showed him my first successful program. In three minutes with a lot of language, he made the code elegant then halved it to a few lines by nesting the loops. That day changed my life. Here was something that wasn't corrupt. It was pure and beautiful, and with it, you could create worlds.

“What do I do now?”

“Start writing a program that is so all encompassing that you’ll have to learn everything.”

Casinos were opening up all over the country and I had a romantic view of gambling. “Blackjack!” I thought.

There was no internet, no code libraries, and no other coders. My mentor had a policy, with rare exceptions, of “the best help is no help at all – except a hint or two.” With the help of a single Quick Basic manual, I set about learning how to code in isolation.

Within months I had a computer in my cell. The walls were soon covered in paper printouts of hand annotated code. The guards quickly decided it was simpler to leave me alone than call me up for muster.

I spent two years completing the program.

Most people in prison lose the remnants of businesses and cash. I lost my wife and family and was well aware that I needed something to get out with so, I refused parole in order to gain the time to complete the program.

I needed a better random generator and bubble sort so I started to learn C++. At the end of the project I had a program that not only simulated blackjack, but included structured lessons in basic strategy, card counting, and staking systems, and allowed any user to test any system against the one I had developed and make a better one if they could. Realtime graphs and system analysis. The code included an “interactive book” detailing high-roller benefits and tournaments at casinos across the country.

It’s another story how the program eventually sold, but let’s just say that when I was released, I did very well on the software in the first year.

I had a new life, new opportunities, and a new career.

What did I learn in prison? I learned to code. More importantly, I learned about myself and how to deal with my demons. I gained the tools to approach life with integrity.

It’s 30 years later now. I’ve never felt the need to use narcotics again.
Computers, total commitment, luck, and a genius of a bank robber saved my life.

This question originally appeared on Quora. Ask a question, get a great answer. Learn from experts and access insider knowledge. You can follow Quora on Twitter, Facebook, and Google+. More questions: