Fastest algorithm to decide whether a (always halting) TM accepts a general string

Given a TM $ M$ that halts on all inputs, and a general string $ w$ , consider the most trivial algorithm to decide whether $ M$ accepts $ w$ :

Simply simulate $ M$ on $ w$ and answer what $ M$ answers.

The question here is, can this be proven to be the fastest algorithm to do the job?

(I mean, it’s quite clear there could not be a faster one. Or could it?)

How to decide dashboard’s general buttons when having multiple clients with different colors each?

I have this project, where I have to implement text, raised and ghost buttons depending on the different sections. It’s kind of a wizard-style app, with a dashboard with steps to complete and submit.

So this app serves to different clients, and with each client, comes the main color which is the brand color of the same before. It is used mostly in the header of the app to generate loyalty with the customer’s brand.

There are exceptions, of course, as the icons colors. i.e. Red for ‘caution’, ‘error’ or ‘delete’.

My question is, how I choose color rules for the buttons when the customer’s color may vary depending on the occasion?

For example, what do I do when the main color of the customer is red? (in terms of usability) or in an extreme case, light yellow?

The main background of the dashboard is white and light gray for the body.

Image example: enter image description here


How do you decide to group components in software architectures?

I am aware that this might be a question with only subjective responses, but i keep coming back to this thought.
When you are designing a software’s architecture, do you group components by their kind of task or their “theme”?

For the lack of a better example, if you have a lot file exports to do in your application where one is part of dealing with “billing” but you also have many other components who deal with this theme. Do you group them by the kind of work (which would be exporting here) or by their “theme” (which would be billing)?

Is there any objective way to determine when the one makes more sense than the other in certain scenarios? Not based on taste.

Decide if a string is in a language without simulating the automata accepting the languge

Is it possible for a Turing machine with input of a DFA that accepts a finite language and a string to decide whether the string is in the language?

More formally, is there a TM $ M$ that can, without fully simulating any string, decide the language:

$ L=$ {$ <D,w>$ | $ D$ is a DFA that accepts a finite language and $ D$ accepts $ w$ }?

I was thinking it is not possible, though I am not sure because maybe one can deduce from the encoding of the DFA without simulating the DFA what is the language.

I can’t see how this can be done but not sure how to prove it can’t be done.

When travelling, how do I decide what’s interesting enough to be photographed

I’m a total amateur. I went to Verona, Italy a couple of weeks ago. I was just taking photos of random stuff that I thought might be interesting and especially to improve my composition. So I wasn’t necessarily shooting memories.. But when I took the photos off of my camera it turned out that I don’t like any of the photos I took. Not to think about my lousy composition but I realised that subjects I decided to shoot were just plain dull.

And it turns out I take a mix of pictures. Some landscapes, some architecture and some portraits… Chaos I know. I’ve read many guides about composition and I’ve improved even though I often get it completely wrong.

My wife is also some small magazine editor and I can say in general that she doesn’t like my photos at all. And hence I became more and more demanding of myself. But still. I don’t really know what am I doing wrong.

So help me

How should I decide what’s worth taking a picture? And how much time is worth spending on capturing a shot that will be worth keeping?


These are two photos that I at least like. First one because of the composition and the kind of doors I’d like to have at home, and the second one because the colourful wall is interesting. Of course both are post processed.

Verona door

Giullieta wall

And this one is completely unaltered. Somehow interesting but the subject doesn’t really stand out.

Venice mask

And one (original + altered) that I don’t like at all. I wanted to capture the city hall with the old arena and then I got so easily distracted by this coach… Put it in the middle, because I started shooting fast because I obviously didn’t have much time… Anyway. A completely unaltered one with a rotated + cropped + curves post processed photos:

enter image description here enter image description here


I edited the Venetian mask as suggested. I overexposed mask by 1/2 and underexposed background by 1/2. Added some light on left+up pointing surfaces and added some shadow on the opposite site. Also blurred background a bit more. This was fast done, but you can get judgemental.

original underneath for comparison

Venice mask take 2 Venice mask original

How can I decide which emails go through SMTP relay?

I am using postfix configuration that use SMTP relay on Sendgrid service like this:

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous smtp_tls_security_level = encrypt header_size_limit = 4096000 relayhost = []:587 

And it works fine for all emails that are sent from my domain. But there is another scenario that we use:

Users in my domain can are using email forwarding instead of POP3 to push emails they receive in to their accounts. And I don’t want those email to go through Sendgrid, but rather to be forwarded directly to gmail.

To summarize – I want emails that have to field set to * to be sent directly and all other emails to go through SMTP relay on Sendgrid service, but in current configuration they all go through Sendgrid.

Can I configure it to work this way?

Should a method decide whether to execute or not?

I couldn’t find a question on SE but it has probably been asked elsewhere already (in case, please mark it).

A method containing code to run just with specific external conditions can:

  • decide whether to execute after checking those conditions, or
  • just blindly run, sticking to the Single Responsibility Principle; and let the calling code check the conditions, deciding to call the method or not.

I am trying to understand what is more proper and when.

What are the pros and cons of the two approaches?


  • check if a DOM element has a CSS class and return if it doesn’t have it
  • check if an array parameter is empty and in case return, sparing the loop on it
  • lazy loading a value and return if it is already initialised

In general I tend to make my methods know as much as possible and take care of everything that concerns them, but that is not necessarily correct.

I suppose in functional programming a highest atomicity would be preferred (so not check the conditions and just do your job, eventually wasting cycles or incurring in an error). If it makes a difference, in my case the style is more OOP.


I am probably talking about Guard Clauses.