## Strings and suffix

How can we find the sum of sizes of common prefix that a suffix of length r has with all suffices of length greater than r? We have to find this answer for all r. I tried this using suffix trees and got an O(n^2) algorithm where n is the length of the string. The main problem I could not handle was the restriction that only suffice of length greater than r were to be considered.

## Building Suffix Array from Suffix Tree. Inorder visit when node has more than two children

From the notes:

It is not difficult to observe that the suffix array $$\texttt{SA}$$ of the text $$\texttt{T}$$ can be obtained from its suffix tree $$\texttt{ST}$$ by performing an in-order visit: each time a leaf is encountered, the suffix-index stored in this leaf is written into the suffix array $$\texttt{SA}$$; each time an internal node u is encountered, its associated value is written into the array $$\texttt{lcp}$$.

How do you do the inorder visit when a node has more than two children?

Let’s say you visit the leftmost child, then the node, then the other leftmost child. Then do you visit again the node?

SA in an array of pointer to suffixes, ordered lexicographically.

lcp contains the longest common prefix between two consecutive suffixes $$\text{suff}_{SA[i]} \text{ and } \text{suff}_{SA[i+1]}$$.

The $represents a char that’s smaller than every other char. The value associated to each node is the length of the prefix spelled so far. The leaves represents indices of suffixes. If T = banana$ , the leaf 3 represents nana$(T[3,7]) In the image there’s what is supposed to be a suffix tree, but I think there’s an error since the edges should be sorted according to their label and the leaf 7 with the edge labeled "$ " should be the leftmost leaf and edge.

When simulating the algorithm, first you visit the node 7 ( using the fixed version of the tree ), then the root, so you have

SA = [7, ...] lcp = [0, ...] 

Then let’s say you keep going on with an inorder visit of u. When you go back to the root, do you insert the value 0 again in the lcp? Or do you do it just the first time you visited the root?

In other words, do I visit child-root-child-root… or child-root-child-child…

## two-factor authentication suffix code in the password

In many sites where 2FA is enabled, the login flow is:

2. If credentials are valid a new form asks for the verification code.

However, there are some implementations in where the verification codes are suffixed into the password so the flow is only a single form asking for username and password+verification_code.

Which approach offers better security?

## Constructing Generalised Suffix Tree from a large set of strings

Is there a published method to construct a generalised suffix tree from a large set of strings (~ 500 000) without the need of concatenating them?

I would like to use the resulting suffix tree for a pattern search problem.

## How can I find a SHA-256 hash with a given suffix using hashcat?

Recently we competed in the X-MAS 2019 CTF and many of the challenges included a proof of work (PoW) check to avoid Denial of Service (DoS) attacks against their servers. The most common was we were given a 6 character suffix and asked to find anything where the hash ended in that suffix:

Provide a hex string X such that sha256(X)[-6:] = abcdef 

The suffix abcdef would change every time you connected to the server. An example of a correct response:

hash = e38450c7008711d86a4d6c2039c8633a1ed637281b96888d7d9ff257aaabcdef x = 4cbab1bbb03b4a10aef586b6 

Can this be done using hashcat?

## Placing full name, including prefix and suffix, on one line in a form?

I am working on a form page that has a name field, including Prefix, First Name, Middle Name (NOT Initial), Last Name and Suffix. The client would like to have all these fields on one line. So here’s the challenge, our width is limited to 960px and we are locked into a 16px font.

The project is pretty far along, but I’d really like to figure this out as it would make the client very happy. However I’d like to do it without making it too complicated.

I considered placing this as a form that they complete and then it collapses just displaying the name in it’s entirety. Then having an edit button to the right of the field in case they need to go back and change it. This would look cool, but it is extra steps.

Is this something that is even worth pursuing? Has anyone seen it done better/similar? Thoughts?

Added a screenshot. It follows the pattern of the remainder of the site, but this is the only place where I’m having an issue. The biggest problem is the font size and the restricted width. Trying to fit this all one line, I tried a couple of things. The first was to have this as an open module and upon completion, collapsing it to a display field of one line going across, leaving an edit button in case it should need to be changed. The second was the google contact method where the user enters all the information one one line then clicks a button to distribute the entered information to the correct fields. Neither of which the client liked. Hence my posting the question here.

## Add suffix to price in Minicart

We have a client that wants to add a suffix to price in minicart whcih depends on a value of custom product attribute (named pack_type).

I have already done that for Product and Cart pages by surrounding price in a div element of class depending of value of that custom attribute and then use css to add text “per card” or “per share” after the price dom element

As it is a very live store, custom plugins could break site one way or another

What is the best and less risky way to add such a suffix to price in minicart?

## Magento 2: Product URL Suffix problem with search (2.3.1)

We removed the values for url suffix from the configuration (removed .html). After rebuilding cache and reindexing from CLI the store works correct but the search function for some reason doesn’t. The search results still go to .html urls and therefore get an 404 page. Also tried to remove all static content and rebuild but that doesn’t work.

How to fix this?

## Proving a language comprised of 2 languages is regular(with suffix and prefix)

I am having hard time proving that the following language,comprised from two regular languages $$L_1,L_2$$(over the same $$\Sigma$$)is indeed regular:

$$L^\frown = \{ w\in \Sigma^* | w=u\sigma_1\mu_1…\sigma_n\mu_nv\}$$

• $$u,v \in \Sigma^*$$

• $$0\leq n$$, for every i($$1\leq i \leq n$$): $$\sigma_i,\mu_i \in \Sigma$$

• $$\sigma_1…\sigma_n \in L_1$$

• $$\mu_1…\mu_n \in L_2$$

I don’t understand how to prove if because of the suffix and prefix(u,v accordingly).

If it weren’t for u,v what I think I would’ve done is building an automaton(Deterministic finite automaton): $$A=\left(Σ,Q1xQ2x\left\{1,2\right\},\left(q01,q02,2\right),F1xF2x2,δ\right)$$, Ending in accepting iff both automatons that accept each language end in an accepting state, and $$L_2$$ needs to be after $$L_1$$ from the language’s description. However, I don’t know how to deal with the u,v in the beginning and in the end. I am not sure how to configure it correctly to prove $$L^\frown$$ is regular.

Would very much appreciate your assistance with it.

## Suffix array and counting distinct substrings of specific length

I am trying to use the suffix array, and the LCP array to count all distinct substrings of a specified length.

I started with the algorithm for counting ALL distinct substrings. I solved it after this explanation: https://www.geeksforgeeks.org/count-distinct-substrings-string-using-suffix-array/ . The problem right now is that I can’t figure out how to only count the substrings of my given length, and not all possibilities.

I also computed the array which tells me how many suffixes are lexicographically smaller than suffix_array[i].

Any ideas what I could use to do it?