theory – DFA that accepts all the strings with exactly two a’s and more than two b’s

Thanks for contributing an answer to Computer Science Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

mysql – Why some DATETIME columns return numbers instead of UTC strings?

Given the following table,

  id int unsigned NOT NULL AUTO_INCREMENT,

when I SELECT * FROM test from the MySQL terminal, the date columns all show string dates as expected.

When I use the same select query in a Node backend using the MySQL xDevAPI, the created_at and completed_at columns return numbers while the updated_at column returns a UTC string.

Why does this happen?

I want to only use UTC strings, and only want to change the updated_at date on update statements but MySQL docs seem to not address what’s happening here so I don’t know if it’s MySQL or the xDevAPI.

Strings in python

How to find a specified letter follows an another letter or not.
the input is : ‘hi, how are you?’,’h’,’i’
then the output is true, because i followed by h at least one time .

What is the time complexity of sorting n words length wise and then alphabetically? Should we consider the length of the strings in the complexity?

Let’s assume I have a list of some words found in the English dictionary:
(“hat”, “assume”, “prepare”, “cat”, “ball”, “brave”, “help” …. )

I want to sort these words (which are n in number) in a way, such that they are ordered based on their length, but if 2 words have the same length, they are ordered alphabetically.

What is the time complexity of this sorting operation?

Would it be fair to say that the complexity is just O(nlogn) and not take into consideration the length of the strings? If the largest length is S, can the complexity also involve a factor of S?

Is it possible to assign a color to specific comments strings in Visual Studio Code

I’m looking for an existing solution (probably using an extension) for marking some specific strings in my code with a fixed color (defined by me in some configuration file) on Visual Studio Code.

E.g. Instead of showing the whole comment in green //The comment here is awesome, I would like to mark the word “here” with a red color text or red color background.

I’ve noticed VSCode have done it for the word TODO: (marked with orange background and white text color), I would like to define more strings like this.

Thanks 🙂

Construct a dfa and nfa for a set of strings on{0,1} : the left most symbol differs from the right most one and odd length string

Construct dfa and nfa for a set of string 0,1 such that left most and right most element are different and odd length string
Can you plss draw it

Is there a way to put strings with key and value in an array with PHP?

I got an array

["id":22,"name":"Birk","city":"Amu Gulang Baolige","gender":"Male","valid_to":"2019-12-10","note":"server"],
["id":24,"name":"Lemuel","city":"Kamionka Strumitowa","gender":"Male","valid_to":"2020-02-24","note":"client"]

and I wanna joint strings group by gender with php like below,



could show me how or teach me how to do!
thank you !

turing machines – Can an $NDTM$ simultaneously perform a set of operations on all strings of a given length?

Can an $NDTM$ perform a set of operations on all strings of a given length $b$, at the same time? Aka can it operate on all strings of a given length by doing something like: spawn $2^b$ branches then operate on each string of length b on each branch?

How could it do this tho if the branches can’t communicate? That’s what I’m having a hard time with. How does any given branch, if it doesn’t know what strings the other branches are running, know what string to run the operations on (so that all the strings are covered by $2^b$ branches)?

Why do most languages treat strings differently from character arrays?

In C, strings are just character arrays. But in most languages they’re not. Why? I see treating a string as a character array as a very simplistic approach, without any extra complications. It makes treating strings, one character at a time, optimally easy. So why is it that "Hello, world!" is fundamentally different from {'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'} in most other programming languages, even if C treats them basically the same? What’s the purpose of any distinction, other than unnecessary complications?

python – Aho-Corasick algorithm to scan through a list of strings

This is a follow-up to my previous question about finding min and max values of an iterable.
Aho-Corasick algorithm was suggested to solve the problem. Below is my solution with the use of ahocorapy library.

Short re-cap of the problem:

You are given 2 arrays (genes and health), one of
which have a ‘gene’ name, and the other – ‘gene’ weight (aka
health). You then given a bunch of strings, each containing values m and n, which denote the start and end of the slice to be applied
to the genes and health arrays, and the ‘gene’-string, for which
we need to determine healthiness. Then we need to return health-values
for the most and the least healthy strings.

I think there might be something off with the code, but not sure what. It works quite fine for small testcases, giving more or less same timing as previous versions of the solution showed, but when it comes to large testcases, my PC basically hangs.

Example of a small testcase:

genes = ('a', 'b', 'c', 'aa', 'd', 'b')
health = (1, 2, 3, 4, 5, 6)
gene1 = "1 5 caaab" (result = 19 = max) 
gene2 = "0 4 xyz" (result = 0 = min) 
gene3 = "2 4 bcdybc" (result = 11)

Large testcase (2 lists 100K elements each; testcase 41K+ elements): txt in my dropbox (2,80 MB) (too large for pastebin)

So, I have 2 questions: 1) What is wrong with my code, how can I impore its performace
2) How do I apply the Aho-Corasick without turning to any non-standard library (because, most likely, it cannot be installed on HackerRank server)

def geneshealth(genes, health, testcase):
    from ahocorapy.keywordtree import KeywordTree
    import math

    min_weight = math.inf
    max_weight = -math.inf

    for case in testcase:
        #construct the keyword tree from appropriately sliced "genes" list
        kwtree = KeywordTree(case_insensitive=True)
        fl, ceil, g = case.split()
        for i in genes(int(fl):int(ceil)+1):
        #search the testcase list for matches
        result = list(kwtree.search_all(g))

        hea = 0
        for gn, _ in result:
            for idx, val in enumerate(genes):
                if val == gn:
                    hea += health(idx)

        if hea < min_weight:
            min_weight = hea
        if hea > max_weight:
            max_weight = hea
    return(min_weight, max_weight)