Is there a built-in way to remove a trailing slash from a list of URLs in scrapebox. I imported a list, but it contains trailing slashes and it’s breaking during a custom grab

# Tag: Removing

## Grammar still ambigous after removing left recursion LL(1)

I have following grammar it doesnt not have Epsilon-derivation problem I can only see left recursion:

`S -> a b S S -> S a b S -> c d S -> a d `

in production number 2 there is left recursion which I removed and I got:

`S -> a b S F S -> c d F S -> a d F F -> a b F | EPSILON `

But it is still ambigous?

## Removing “index.php?page=” in .htaccess entirely and once and for all

This question has been driving me nuts. There seem to be hundreds of answers online and on various StackExchange websites, but they either remove `index.php`

(keeping `?page=`

) like this:

`Options +FollowSymLinks -MultiViews RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$ 1 [L,QSA] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC] RewriteRule ^ %1 [R=301,L] `

…or like this:

`RewriteBase / RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC] RewriteRule ^index\.php(.*)$ $ 1 [R=301,NS,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$ 1 [QSA,L] `

…or remove both but cause the page to not work (not be recognized as a PHP file), like this:

`Options -MultiViews RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC] RewriteRule ^ /%1? [R=302,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ index.php?page=$ 1 [L,QSA] `

How the heck do I remove `index.php?page=`

and still get the remaining file/URL to be recognized as a proper PHP file?

## Need help optimizing an algorithm that’s supposed to maximize the greatest common divisor of n elements by removing at most one element

Alright, first here’s the text of the problem:

You’re given n bags of candies where the i-th bag contains a[i] candies and all numbers a[i] are in the segment [1,m]. You can choose a natural number x and each second remove x candies from one of the bags if it contains at least x candies. The goal is to empty all the bags *except at most one of them*. Find the greatest possible value of x that allows you to achieve this goal.

The desired time complexity is O(n* log m);

What I managed(I think) to do is write an O(n^2 * log m) algorithm (the two nested for loops are O(n^2) and Euclid’s algorithm is O(log m)).

The code written in c++ is below. The second for loop calculates the gcd of the numbers excluding the i-th number and I calculate the maximum by considering all values of i, but apparently it can be done linearly. Any ideas on how to optimize it to O(n* log m)?

`int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a%b); } int greatestPossibleGcd(int *arr, int n){ int maxgcd = 0; int current = 0; for(int i=0;i<n;i++){ maxgcd = gcd(maxgcd, arr[i]); } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(j == i) continue; current = gcd(current, arr[j]); } if(current > maxgcd) maxgcd = current; current = 0; } return maxgcd; } `

## Removing imperfections in circle with color gradient edge

I am trying to draw a red circle with a colour gradient fading into white on the edge. The way I am currently doing it is to first define a smooth step function and draw a rectangular block with a color gradient defined by the smooth step function:

`smoothstep[x_] := Piecewise[{{0, x <= -(1/2)}, {-20*(x + 1/2)^7 + 70*(x + 1/2)^6 - 84*(x + 1/2)^5 + 35*(x + 1/2)^4, -(1/2) < x < 1/2}, {1, x >= 1/2}}] img = Rasterize[DensityPlot[smoothstep[x], {x, 0, 4}, {y, -4, 4}, ColorFunction -> Function[{x, y}, Hue[1, x, 1]], Frame -> False, PlotRangePadding -> None] `

which seems to be successful

Then I applied this colour gradient to a circle as a texture

`ParametricPlot[{r*Cos[t], r*Sin[t]}, {r, 0, 1}, {t, 0, 2 Pi}, Mesh -> False, BoundaryStyle -> None, Axes -> False, Frame -> False, PlotStyle -> {Opacity[1], Texture[img]}] `

which is mostly successful, apart from 1) the white dot at the centre of the circle, and 2) the faint concentric red line outside.

How do I remove these imperfections in the resulting image? Should I change my approach?

## Finding an algorithm that after removing k edges we get an acyclic graph

Assuming there’s an algorithm that can decide belonging to ACYCLIC in polynomial time. How can I use this algorithm in another algorithm that upon the input of a directed graph and a positive number k, returns k edges that after removing them, the graph becomes acyclic(has no cycles). there are no weights in the graph, just regular directed graph.

ACYCLIC is for a directed graph that is acyclic.

What I am trying to do is something like this: For a directed graph G=(V,E), Assuming there exists an algorithm isacyclic that returns true or false whether given graph is acyclic or not:

1)select a vertex and begin traverse the graph

2)while number of edges > 3 and we did not finish traversing the graph(3 edges can form a cycle, and i need at least one more because k should be positive, meaning number of edges that upon removing i’ll obtain an acyclic graph)

2.1)if (number of edges traversed – 3) greater than k

2.2)if isacyclic returns false:

2.3)try eliminating last edge and rerun isacyclic, if returns true – add edge to a list/stack and continue traversing without it

if at the end of the algorithm there are no k edges in the list/stack – reject

else accept

The algorithm I wrote was general idea of what I am looking for. I assume that there exists an algorithm that can decide belonging to ACYCLIC in a polynomial time for the questions sake.

What I am looking for is an algorithm that for a directed graph g and a positive number k, can give me k edges that when I remove them, I get an acyclic graph

The algorithm should be polynomial in regards to its input size.

Thank you very much!

## Obtaining an acyclic graph by removing edges using an algorithm that decides ACYCLIC

i don’t understand the following:

If there’s an algorithm that can decide ACYCLIC in Polynomial time, then there’s an algorithm who returns a set of k edges, so that the graph obtained by deleting the k edges is without circles – in polynomial time.

The algorithm should get a directed graph and a natural k as an input, and output, if there are k edges as needed, a list of k edges, so that the graph obtained from erasing those k edges is circleless. if there are no such k edges, it simply outputs “no”.

Problematic part: I can only use an algorithm that decides ACYCLIC, but it is forbidden to use any other NP-Complete algorithms, and it’s running time must be polynomial in regards to its input size.

My attempt: well, to check/decide if a directed graph is ACYCLIC or not, we’ll visit it topologically using DFS, then using a stack, we’ll traverse edges to see if any edge in the digraph leads back to an edge already visited. if already visited – there’s a cycle, if not – there’s no cycle.

The algorithm: on an input of a directed graph, to check ACYCLIC:

1)finding an vertex that has only outgoing nodes – if such node doesn’t exist – return “graph has cycles”

2)on that node, run DFS and traverse the digraph; add each edge found to a stack. if a vertex is shown twice – return “graph has cycles”.

3)if no cycles found, accept.

But, I am not sure how to do it in regards to the algorithm required in the problem(first two paragraphs of the questions – basically, returning a set of k edges, so that by removing them, the graph will be circleless.

would really appreciate knowing how to do it.

thank you very much

## Mechanical implication of removing raw stats from Dungeon World

I started to look at DW to see how well the move and general rules work out in real life. Looks good, but one thing bothers me : Why do the stats need a 3-18 value if 9 out of 10 moves and/or rules only care about the modifier (or so it seems from my reading of the rulebook so far)? The main uses for raw stats appear to be Encumbrance and HP computation. The later being done only on character creation.

## So here’s the main question

If we assume I would be fine to house rule or eyeball the Encumbrance move to not require raw Strength and that I would use the raw stat once at character creation to compute HP:

What other problems would arise from removing the raw stat? Or what does the game need those stats for?

*A personnal note : My original curiosity and question would have been “What was the designers’ intend with the 3-18 stat concept?” (but that is off-topic).* I am still curious to know if the concept exists in other PbtA engines and why is it necessary there. So I would be interested in an answer acknowledging this even thought it is not the main question.

## If I have an MST, and I add any edge to create a cycle, will removing the heaviest edge from that cycle result in an MST?

Let’s say that I have an MST, $ T$ . I pick an edge not in $ T$ and change its weight, and add it to $ T$ to create a cycle. Will removing the heaviest edge from that cycle result in an MST?

MST means minimum spanning tree of a graph. I came across these two posts:

- https://stackoverflow.com/questions/13437702/how-to-get-the-new-mst-from-the-old-one-if-one-edge-in-the-graph-changes-its-wei
- https://sudeepraja.github.io/MST/

and I follow both until the case where $ w_{old}>w$ and $ e\notin T$ . They both say that deleting the heaviest edge will guarantee an MST, but I don’t see how to prove that. The cycle property just says that IF you have an MST, it can’t have an edge which is the heaviest edge in a cycle of the original graph $ G$ ; it is NOT saying that IF you have a tree that doesn’t contain an edge that happens to be the heaviest edge of some cycle in the original graph $ G$ , you are an MST.

To make the question more explicit in terms of the problem it was trying to solve, I will copy a part of the first link:

If its weight was reduced, add it to the original MST. This will create a cycle. Scan the cycle, looking for the heaviest edge (this could select the original edge again). Delete this edge.

I don’t understand why this guarantees that we find an MST. Sure, we get a spanning tree but why does deleting this heaviest edge yield a MINIMUM spanning tree?

## Time complexity of removing duplicates in lists

## Question

I am wondering what is the minimum time complexity of get the unique value of a array in two conditions: keep the order or not.

I think time complexity of not keeping the order is $ O(n)$ using a hashtable. Keeping order has a time complexity $ O(n^2)$ .

So, Am I right? Can someone give a detailed prove the time complexity of the best in each condition?

## For more infomation:

I use Python, I find 2 python code for drop dumplicates in a list.

- How do you remove duplicates from a list whilst preserving order?
- removing duplicates in lists