Ask HN: What's the hardest problem you've ever solved?

85 points by levlandau ↗ HN
We've all toiled and eventually solved some problem. Would be awesome to see some of the toughest problems HN community members have solved. Could be from any domain though it's better if the problem is somewhat technical.

123 comments

[ 3.7 ms ] story [ 125 ms ] thread
I have been programming for a bit more than three years. Making a half decent app in Cordova for some classes was the hardest I have worked at problem solving stuff in programs. Looking back on it now the code is really, really bad.
Wow, Is cordova that bad ?
Nope Cordova over all is not that bad, I was that bad of a programmer though haha.

I think React Native is super cool right now if its going to make nice UI easier and have good multiplatform support.

Cordova is not bad, trying to program a mobile app in HTML5 is. (1) You have to build most of the UX interactions yourself (2) Performance is a bitch. You can spend months trying to optimize your code and it still sucks (3) Different versions of android have different levels of support for HTML5 api. In the end, you get to use the lowest common denominator. (4) Windows phone reloads your Javascript / HTML code every time someone starts the app giving an obvious "reload flicker".

Basically it is one of those unfortunate cases where the first weeks makes everything look really promising (single codebase and all) and it is only after hard work of several months that you realize that there is no way you are going to win this battle.

Hi, just wondering if you've looked at Intel Crosswalk? It's intended to help with issue 3.
Writing an implementation for parallel Travelling Salesman Problem w/ B&B using MPI and getting some god damn speedup
Setting up a web service that can transcode audio files (namely mp3) that are uploaded to a server using ffmpeg. In fact, I know I could still improve it but I haven't figured out all the things ffmpeg can do.
How to isolate and identify a human hand with the fingers spread and track it in real time on an iPad.

Edit: Whoops, I realized this was ambiguous. I was using an iPad camera to track it and displaying the result as well as using the detection to trigger a camera shutter.

Made Websockets working with reverse proxy(IIS) sitting in between the browser and a Golang app server.
NP-completeness for automatic fence placement between two specified instructions in the presence of arbitrary goto statements. Reduction is from negation free 2-SAT to control flow graphs for real programs.

Didn't make it into my first paper, hopefully will end up in my thesis :)

Making android lists scroll smooth
Built the head tracker for the Amazon Fire phone.
Was that challenging from a technical perspective, or from a "I can't quite believe I'm doing this" perspective?
It was challenging in every way imaginable. There was no existing algorithm that could deliver the accuracy and robustness we required. It had to run within the limited power budget of a phone. And it had to be done quickly before the hardware became uncompetitive.

At the time it was given to me it was a rough demo with no clear path forward to shipping. We had no metrics to tell how good it was, how good it had to be, or whether we were even making progress. We had no team of computer vision experts to work on core algorithms. We had no idea if the problem was solvable at any amount of power consumption. There were more than a few people within the company who thought it couldn't be done.

I want to be very clear about credit. I put this as the hardest thing I have ever done but I was only the manager in charge of the project. While I built the team and owned the problem, I did not write the code or design the algorithms. I had incredible people who did outstanding engineering work and researchers who advanced the boundaries of computer vision. It was a privilege to work with them and I am proud of them.

Designing a usable static type system for Forth-like (concatenative) programming languages.
Performance tweaking when I used to build Blackberry apps back in 2009. It sucked so much that it turned me off of Blackberry phones entirely, as a consumer and as a developer. Remember these were the days where Blackberry was -the- phone to use. BBPin was red-hot and the iphone was too expensive for 99% of people.

Tweak -> Compile -> build deployable package -> push to phone -> wait 6 minutes -> test on phone -> repeat....

When I was in initial years of programming my first hardest problem was implementing backpropagation in VB 6.0 http://paraschopra.com/tutorials/nn/ (2003)

Then the next hardest problem I found was implementing Genetic Programming in Python (year 2005) http://paraschopra.com/sourcecode/GP/index.php

It was fun but extremely hard for me (at that age!).

After that in 2008, I think the trickiest part for me was to write initial visual editor for Visual Website Optimizer. It involved reverse proxy and inserting JavaScript code into that reverse proxied page, letting the user visually edit the page contents.

Fun days. These days I hardly get to code, though last year I gifted my wife a website (http://wowsig.com) which was super fun.

Implementing a real-time GPU-based fluid simulation.
(comment deleted)
Implementing all-pairs similarity search on a few hundred million records. Naively approached, the complexity of this is O(N^2), so had to come up with novel ways to make it finish in a reasonable amount of time and with limited resources.
I'm sitting with a similar problem right now! Got any pointers?
This is exceptionally hard to answer because for every problem I solve I tend to end up looking at my solution and thinking "That wasn't so hard. Why did it take me so long? Am I bad at this stuff?"

To answer the question though, I think probably writing a robust web scraper to search events listings and turn them in to a sharable calendar. It'd be trivial these days but I did it in 1999 in Perl with regexs.

> "That wasn't so hard. Why did it take me so long? Am I bad at this stuff?"

Hah. Always. Hindsight bias and impostor syndrome are a fun mix! I remember writing a blog suite (with comments!) in Perl in the late 90s; back then, without S.O. and other knowledge-sharing beyond some Usenet forums, inventing the wheels as we went along... it was all hard.

I coded the same thing (actually an online magazine with comments on articles, a forum, and a form for signing up for email updates), around the same time. I used classic ASP. I shudder to think of all the security holes I must have had.
I remember a defining struggle in the late 90's, while I was in high school and teaching myself how to make webpages.

My problem was a lack of javascript logic firing and the answer was to wait for document load. Simple, I know, but I had nobody around me (physically) that could help me and explaining the problem to people in forums seemed impossibly abstract, primarily because I did not understand what the problem was. It was the context around my code that I had to fix, but I kept looking in the code itself.

That was probably one of my first big "ah ha!" moments and these moments are one of the reasons I still love programming. Tenacity, luck and skill became irrevocably connected that day.

I've solved many other problems over the years, far tougher than this one, but maybe never tougher for me in a relative scale. If I had never solved that problem, I sometimes believe my life path would have been totally different.

Limited access to informational resources can greatly hinder solution time. Some of my hardest challenges were implementing content for a MUD with a sparsely documented custom scripting language. Even with input from other devs there was a lot of trial and error and hacky workarounds.

Nowadays most of the problems I face have been solved by someone else in a slightly different context and searching for/implementing existing solutions is almost trivial.

I am part of a team created a system that took the complexity of the human metabolism and reduced it down to a few vital statistics that are then used to create a individualized formula that tells people how to sustainably improve their metabolism and lose weight and gain muscle. The amazing part is that it works for everyone because it is custom tailored to them. The hard part here was 30 years of testing, thankfully not done by me, but by the CEO who happens to be a bodybuilder.

The formula is how much protein, carbs, and fat to eat and the appopriate exercise of 3 half hour workout sessions a week. No supplements or anything else. Just food and small amounts of exercise to stimulate hormone response. This is way more complex than some tracker or calorie counter. It takes into account insulin spikes, metabolic damage assessments, glycogen storage, and much more. The hard part here was integrating ~10 different disciplines in various sciences. Everyone had a piece of the puzzle, but we had to put it together.

That is then fed into an app that can then pick foods for you based on your formula that is then constantly refined based on your results. We took 1000 people through test runs tweaking our code to get it right. Now it works for everyone that we put on it and actually uses the system.

Our next challenge is the psychology and habit forming parts of the app we have built.

Oh and of course competing with well funded competitors in the space, but at least nobody can claim our results because they just track things instead of allow people to really plan for health.

Edit: Since you asked, it's called mPact (for metabolism impact) and the corporate site is at http://mPact.io

For habit forming, look to beeminder - its interface is clunky and its termonolgy too geeky, but it is also the best way to make "some day" to day (some day I want to lose weight) and keep it up that I have found.
Thanks. That's one avenue we've looked at already. I have also looked at traditional gamification techniques and found them initially motivating for users, but then engagement falls off a cliff. This has less to do with the techniques I suspect and more to do with the fact that people eventually hit a goal weight and think they are suddenly "fixed" and can go back to what they were doing before. We actively work to encourage the better mindset of making a permanent change in lifestyle where our system then moves from educational and informative to simply a tool to continue to plan and keep on track.
About 10 years ago I built a Scanning Tunneling Microscope. It took me 2 years to complete it and to get it working.
Wow, that sounds really cool! What parts did you use (how much was "from scratch")? Any blog post or article about this? I'd love to read more.
Turning myself from a data driven nerd into an emphatic person who understands social interactions. Finally, I bring home girls :)
You can be emphatic and remain empirical. It's the difference between thinking nobody is wrong vs knowing someone is wrong but it not mattering under certain contexts.
Yes, that is part of it. I pretty much abandoned the thought of someone being wrong and someone being right. We all have this bias, that we are more intelligent then others. While on average, we are just average.
>I pretty much abandoned the thought of someone being wrong and someone being right.

Frankly, this sounds like taking a good idea too far. People around you will make assertions about objective reality that are beyond any reasonable doubt incorrect, sometimes dangerously so. Considering them wrong can be important to prevent harm to yourself, your family and your job or business. Beyond that, calling out people you care about on their being wrong can prevent harm to them and their respective families and jobs even if at first they hate you for it.

Empathizing with people who are wrong for understandable reasons but still being keenly aware that they are wrong seems to me like a much better long-term strategy.

You sound like his past self. Lol
“You keep using that word. I do not think it means what you think it means.”
It's probably best if you point out that "empathic" and "emphatic" are different.
(comment deleted)
Or, as others have pointed out, "empathetic".
Trying to figure out how to scale and secure Twitter. From a dozen people in a room to 2800 when I left, it was a challenge every day.
How did you like your Twitter experience?
This might not be the hardest bug I've tackled, but it certainly took the longest to solve.

It was the early days of SOAP, and I had been assigned the task of integrating my employer's software with a third party's, so that the applications could share data. This third party org was a wealthy, powerful mega-corporation; and my employer was, well, not. The third party produced a spec for the interface, expected us to follow it, and offered no help from there.

I built a solution. It worked on my machine. Solved the problem. All was right in the world.

I moved it to the test environment. It worked again. Demoed it for one of our customers, and everyone was pleased.

Deployed it to our first beta tester. One lonely employee working accounts receivable, tucked away in the corner of our customer's office.

It crashed.

I checked everything. I mean everything. There are still particulars of that little Windows 2000 workstation that I can describe vividly. Which programs were installed, which patches were installed, how Windows had been configured, how the firewall worked, I even got permission to install a packet analyzer. My employer only had a handful of customers, and the beta test machine was near our offices, so I was over there personally a lot over the following weeks.

We brought in the customer's network support people. They found nothing. They could see the packets leaving, and an error coming back, but couldn't offer more than that.

We brought in the best networking engineer in my company. He was stumped.

What really shook my confidence was knowing that competitors mine had gotten this interface working. This wasn't some half baked project that I could blame on someone else. Others had succeeded where I'd failed.

I practically had to walk across broken glass to get on the phone with the third party's development team, but with enough pestering I pulled it off.

The phone call involved me sitting at the beta test workstation and firing off a request so that they could view it hitting their servers live. The developer who I spoke with immediately spotted the problem.

You see, when you send a SOAP request, you send the date and time that you're making the request along with it. The clocks on the client and the server were too far out of sync, my requests appeared to be coming from the future, and so the server disregarded them with a blunt error. Interestingly, the workstation clocks at my company's office weren't too far out of sync, which is why it worked in one place and not another.

Stuff I learnt:

1. Third party interfaces require a point of contact at both organisations who can talk with one another. This is non-negotiable.

2. If you send an error message that reads "Error", you're a bad developer and should return your computer science degree to your university and demand a refund.

3. No matter how well written the spec is, something always gets left out.

4. Persistence maters more than anything.

Debugging a "hot CPU" boot failure issue. A custom motherboard design would only boot when the CPU was cold, like ICE cold (put it in a freezer, or hit it with cold spray).

Turns out the bias current node (external RBIAS resistor sets bias current) for PCIe was routed too close to an inductor for a power rail. When the CPU was warm, the power rail pulled more current, causing the inductor to ring more, causing the crosstalk on the bias net to screw up the PCIe subsystem and hang the CPU.

Found the issue accidentally on a layout change. Had to prove it by drilling out the via and re-routing the signal with wire.

I have a few little trophies I go back to every once in a while when I'm feeling like a crappy programmer.

- I worked out, on pen and paper, sorting networks on my own a few years before the Wikipedia article on them existed. I was looking for shortcuts in a Quicksort implementation. I hadn't read Art of Computer Programming yet, which is probably the only other place I would've been likely to read about it. It hadn't been covered in any of the other programming literature that I was devouring at the time.

- I wrote a variable interpolator in COBOL. COBOL has no string operators or anything resembling a string data type. This one was tricky. I was working as a programmer/operator at a school district at the time and the central hub of their IT was a Unisys mainframe that ran COBOL and WFL. There weren't any punch cards anymore, but everything ran as if there were; for any given job to run, say, report cards, you had to go into the WFL job and edit a two-digit school code in half a dozen places, in "digital punch cards", which would then be fed one after the other into COBOL programs. This was error-prone and I wanted a way to define a couple of variables at the top of the job file and then have everything work after that.

- I worked for a BigCo that used Remedy for its internal support systems. There were some latent training issues in the internal support department and support requests kept getting modified by unknown people, which would cause the requests to get mishandled and would irritate various other departments. I found a way to sneak some code into the Remedy forms system and I cobbled together a very rudimentary communications protocol between several forms so that all changes to any form got logged to another form, along with the user's id. Remedy had no loop logic at the time. That actually made it to a Remedy developer's group mailing list once and I was a big fish in a very tiny little puddle for a day.

- I reverse-engineered portions of the .dbf format that FoxPro uses, and wrote software that could convert .dbf files into MySQL tables. The date format was tricky. It was an 8 byte field where the first four bytes were a little-endian integer of the Julian date (so Oct. 15, 1582 = 2299161), and the next four bytes were the little-endian milliseconds since midnight. This is not documented anywhere.

Those are some of my favorites anyway. 30 years of programming, there's been some fun stuff along the way.

I liked experience writing Tomita LR parser generator in J - while learning both parsing and J :) . ~700 lines heavily commented code with tests... Of course now it doesn't seem all that hard.