Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "backtracking"
-
I was on vacation when my employer’s new fiscal year started. My manager let me take vacation because it’s not like anything critical was going to happen. Well, joke was on us because we didn’t foresee the stupidity of others…
I had to update a few product codes in the website’s web config and deploy those changes. I was only going to be logged in for 30 minutes to complete that.
I get messaged by one of our database admins. He was doing testing and was unable to complete a payment on the website. That was strange. There was a change pushed by our offsite dev agency, but that was all frontend changes (just updating text) and wouldn’t affect payments.
We don’t want to enlist the dev agency for debugging work, especially when it’s not likely that it’s a code issue. But I was on vacation and I couldn’t stay online past the time I had budgeted for. So my employer enlists the dev agency for help. It’s going to be costly because the agency is in Lithuania, it was past their business hours, and it was emergency support.
Dev agency looks at error logs. There are Apple Pay errors, but that doesn’t explain why non Apple Pay transactions aren’t going through. They roll back my deployment and theirs, but no change. They tell my employer to contact our payment processor.
My manager and the Product Manager contact Payroll, who is the stakeholder for our payment gateways. Payroll contacts our payment gateway and finds out a service called Decision Manager was recently configured for our account. Decision Manager was declining all payments. Payroll was not the person who had Decision Manager installed and our account using this service was news to her.
Payroll works with our payment processor to get payments working again. The damage is pretty severe. Online payments were down for at least 12 hours. Our call center had logged reports from customers the night before.
At our post mortem, we had to find out who ok’d Decision Manager without telling anyone. Luckily, it was quick work. The first stakeholder up was for the Fundraising Dept. She said it wasn’t her or anyone on her team. Our VP of Analytics broke it to her that our payment processor gave us the name of the person who ok’d Decision Manager and it was someone on the Fundraising team. Fundraising then starts backtracking and says that oh yes she knew about it but transactions were still working after the Decision Manager had been configured. WTAF.
Everyone is dumbfounded by this. How could you make a big change to our payment processor and not tell anyone? How did our payment processor allow you to make this change when you’re not the account admin (you’re just a user)?
Our company head had to give an awkward speech about communication and how it’s important. The web team can’t figure out issues if you don’t tell us what you did. The company head was pissed because it was a shitty way to start off the new fiscal year. Our bill for the dev agency must have been over $1000 for debugging work that wasn’t helpful.
Amazingly, no one was fired.4 -
I tried to do a sudoku solver, but it didn't work...
I wanted it to succeed without backtracking or bruteforce, so I tried solving it in a human way.
I ended up with some if-else AI that couldn't do anything at all5 -
Unpopular Opinion: When Satya came to Microsoft leadership, Microsoft was a whole lot better company
Forget Windows and shit, Azure was the only open Microsoft on Ballmer days, then Satya, who were part of Azure decided to give the entire MSFT the Azure experience. Look where we are now
not saying Microsoft is no longer bad, its just more tolerable as a company now. Nice to see it backtracking and bracing stuff unlike its first leaderships12 -
Algorithms real life implementation
On the way to your college canteen? -> A* search
Waiting in line in the canteen? -> Queue
Notice that girl standing in front? -> Linear search
Searching for her dad in the phone book? -> Binary search
Stupid! Google it! -> Trie
Search for her on Facebook! -> Depth-first search
Found her! Friend request? Accepted! Send a Hi! -> Graph
Writing her a secret love letter? -> Caesar cipher
Uploading your first date pic on fb? -> Image compression algorithms
Looking through her Whatsapp messages? -> KMP algorithm
She found out and had your first fight? -> Start over with some gifts! Backtracking
Got her list of items to buy? -> Array
Too many items! Low on cash, maybe? -> Priority queue
Making her play treasure hunt for her gifts? -> Linked list
Wait! Go back! Is that a ring? -> Stack
Girl’s family not agreeing to your proposal? -> Divide and conquer
Got married? Congrats! Going for your honeymoon? -> Travelling salesman problem
Your mom packing luggage for you? -> 0/1 Knapsack problem
She packed your favorite pickles? -> Hash table
Driving to the airport? -> Breadth-first search1 -
Just got a basic HTML parser written in c++. Uses state machines. Should be pretty efficient considering the lack of backtracking or looking forwards. Still lacks a bunch of features, but works, so I am pretty darn stoked.
Pic attached is output, not input. I also wrote an HTML pretty-printer.18 -
! rant
Sorry but I'm really, really angry about this.
I'm an undergrad student in the United States at a small state college. My CS department is kinda small but most of the professors are very passionate about not only CS but education and being caring mentors. All except for one.
Dr. John (fake name, of course) did not study in the US. Most professors in my department didn't. But this man is a complete and utter a****le. His first semester teaching was my first semester at the school. I knew more about basic programming than he did. There were more than one occasion where I went "prof, I was taught that x was actually x because x. Is that wrong?" knowing that what I was posing was actually the right answer. Googled to verify first. He said that my old teachings were all wrong and that everything he said was the correct information. I called BS on that, waited until after class to be polite, and showed him that I was actually correct. Denied it.
His accent was also really problematic. I'm not one of those people who feel that a good teacher needs a native accent by any standard (literally only 1 prof in the whole department doesn't), but his English was *awful*. He couldn't lecture for his life and me, a straight A student in high school, was almost bored to sleep on more than one occasion. Several others actually did fall asleep. This... wasn't a good first impression.
It got worse. Much, much worse.
I got away with not having John for another semester before the bees were buzzing again. Operating systems was the second most poorly taught class I've ever been in. Dr John hadn't gotten any better. He'd gotten worse. In my first semester he was still receptive when you asked for help, was polite about explaining things, and was generally a decent guy. This didn't last. In operating systems, his replies to people asking for help became slightly more hostile. He wouldn't answer questions with much useful information and started saying "it's in chapter x of the textbook, go take a look". I mean, sure, I can read the textbook again and many of us did, but the textbook became a default answer to everything. Sometimes it wasn't worth asking. His homework assignments because more and more confusing, irrelavent to the course material, or just downright strange. We weren't allowed to use muxes. Only semaphores? It just didn't make much sense since we didn't need multiple threads in a critical zone at any time. Lastly for that class, the lectures were absolutely useless. I understood the material more if I didn't pay attention at all and taught myself what I needed to know. Usually the class was nothing more than doing other coursework, and I wasn't alone on this. It was the general consensus. I was so happy to be done with prof John.
Until AI was listed as taught by "staff", I rolled the dice, and it came up snake eyes.
AI was the worst course I've ever been in. Our first project was converting old python 2 code to 3 and replicating the solution the professor wanted. I, no matter how much debugging I did, could never get his answer. Thankfully, he had been lazy and just grabbed some code off stack overflow from an old commit, the output and test data from the repo, and said it was an assignment. Me, being the sneaky piece of garbage I am, knew that py2to3 was a thing, and used that for most of the conversion. Then the edits we needed to make came into play for the assignment, but it wasn't all that bad. Just some CSP and backtracking. Until I couldn't replicate the answer at all. I tried over and over and *over*, trying to figure out what I was doing wrong and could find Nothing. Eventually I smartened up, found the source on github, and copy pasted the solution. And... it matched mine? Now I was seriously confused, so I ran the test data on the official solution code from github. Well what do you know? My solution is right.
So now what? Well I went on a scavenger hunt to determine why. Turns out it was a shift in the way streaming happens for some data structures in py2 vs py3, and he never tested the code. He refused to accept my answer, so I made a lovely document proving I was right using the repo. Got a 100. lol.
Lectures were just plain useless. He asked us to solve multivar calculus problems that no one had seen and of course no one did it. He wasted 2 months on MDP. I'd continue but I'm running out of characters.
And now for the kicker. He becomes an a**hole, telling my friends doing research that they are terrible programmers, will never get anywhere doing this, etc. People were *crying* and the guy kept hammering the nail deeper for code that was honestly very good because "his was better". He treats women like delicate objects and its disgusting. YOU MADE MY FRIEND CRY, GAVE HER A BOX OF TISSUES, AND THEN JUST CONTINUED.
Want to know why we have issues with women in CS? People like this a****le. Don't be prof John. Encourage, inspire, and don't suck. I hope he's fired for discrimination.11 -
I remember debugging a large C++ application a while back. I had been doing quite a bit of backtracking when I found myself looking at a line of code commented with "this is the code you are looking for". Scary.1
-
I don't like when
you have a couple of years of experience with some language and you're like "I should read a good book about it, and have some proper solid foundation instead of playing by ear".
So you get a book and what follows is a very jarring experience.
Because for the first 8 chapters they get into the basics of the language.
You're occasionally like "interesting, I did not know that".
But for the most part you're like "yes, for fucking christ I know that, everybody knows that",
or you complain about the author being redundant,
or about the outdatedness of the book, since most documentation is now in the interwebs
or you reach flawed conclusions out of frustration like "this isn't making me any money, I could get on upwork, or do some bounties instead of wasting time on this"
then you start to skim through the pages like "I know this, and this, and this" until you realize you're in some page you have no fucking idea what it's talking about, as if you ended up on the wrong side of town
so you start backtracking (frustration is going critical at this point)
but backtracking is annoying because it's not well defined where you stopped getting it, as if in page 33 you were getting it 100%, but 0% on page 34, it's more like a gradual, irregular decrease,
so you have no idea where to start re reading from.
you just shove that shit into the wall at that point.
Some of these are learning discipline problems.
I guess there are ways to mitigate them, such as writing down questions of things not understood, co reading, etc.
But the one thing I don't think I can't get past is when authors write like shit,
like being redundant, using different words to say the same shit
or using confusing sentences that can mean different things at the same time,
or using the incorrect terminology, eg: if I were teaching OOP, saying shit like "classes create objects" but later on saying something like "classes create instances".
They usually nail the definitions the first time, but then use different terms for the same thing. It's shit.
And I think that's a writing culture that I hate.
From school you are taught to bot repeat words.
To say the same shit in different ways.
To be descritive, but vague.
That's absolutely shitty for programming in my opinion.2 -
Someone figured out how to make LLMs obey context free grammars, so that opens up the possibility of really fine-grained control of generation and the structure of outputs.
And I was thinking, what if we did the same for something that consumed and validated tokens?
The thinking is that the option to backtrack already exists, so if an input is invalid, the system can backtrack and regenerate - mostly this is implemented through something called 'temperature', or 'top-k', where the system generates multiple next tokens, and then typically selects from a subsample of them, usually the highest scoring one.
But it occurs to me that a process could be run in front of that, that asks conditions the input based on a grammar, and takes as input the output of the base process. The instruction prompt to it would be a simple binary filter:
"If the next token conforms to the provided grammar, output it to stream, otherwise trigger backtracking in the LLM that gave you the input."
This is very much a compliance thing, but could be used for finer-grained control over how a machine examines its own output, rather than the current system where you simply feed-in as input its own output like we do now for systems able to continuously produce new output (such as the planners some people have built)
link here:
https://news.ycombinator.com/item/...5 -
Today I‘ve been investigating a freeze in our app. It took me many hours to narrow it down to the textfield validation regex. And it turned out to be a "catastrophic backtracking" issue.
I‘m a regex noob so I don‘t have a clue how it occurs exactly. But I‘m a bit perplexed about what a seemingly innocent regex can cause.
For me it became another argument against regex now.
I‘ve rewritten the regex into readable code and the freeze is gone.
I could try to fix the regex but… nah. The code is better anyway.7 -
In my early programming days when i had just started learning, I challenged myself to write a sudoku puzzle solver. Wrote a really naive backtracking solution, but i was really excited to have finished it.
-
How do you learn to write a backtracking algo without having an existential crisis? I feel like whenever I see a problem that could use backtracking, I’m like “Looks like a case for backtracking!” *writes seven functions to try to piece it apart, gets no closer to solution, dies inside*5
-
Successfully wrote a Prolog DSL in Python with no prior knowledge of interpreting Prolog. Backtracking is implemented using the inspect module.
-
Phps love of nested arrays is similar to that of structured programing and goto statements. You will do a lot of backtracking in both of them to see where things start. God bless PHP.3
-
Never underestimate the power of a misplaced static in your Java to totally fuck you over.
I was busy with my computer science project for the semester where we have to implement a Sudoku solver without backtracking by using graph theory.
So there I was writing my data structure for the grid when for some reason all the cells were initialized with the value 8.
After a whole night of debugging I was about to start over when I realized I had made my array static.
And boom, it works. WTF!!!!!!!3 -
More like a confession.
Had a task that involved invalidating a string if it contained more than five digits (anywhere in the string.)
"No problem", I thought. That sounds like a simple regex!
^(\D*\d?\D*){5}$
Turns out catastrophic backtracking had other ideas, and I revert to my usual "atomic grouping fudge that will hopefully work without me really understanding what's going on" of:
^(?>\D*\d?\D*){5}$
...anyone else shamefully follow this mantra, or am I the only one that hasn't skilled up properly on regexes...7