## How can we formulate an anti-knight Sudoku as an exact cover problem?

Formulating standard Sudoku as an exact cover problem is easy and well documented. All of the constrained groups contain every digit which makes it natural to express the problem this way. Wikipedia claims without citation that:

Although other Sudoku variations have different numbers of rows, columns, numbers and/or different kinds of constraints, they all involve possibilities and constraint sets, and thus can be seen as exact hitting set problems.

How would one formulate other variants as exact cover problems with an incidence matrix? I’m focusing on the anti-knight variant, but with the goal of learning about expressing arbitrary variants.

The anti-knight Sudoku variant includes all of the standard rules, and additionally requires that no two squares which are a knight’s move (in chess) apart may contain the same digit. I don’t know how to approach this because a constraint between two squares cannot be expressed as requiring all digits to be present in some permutation. I can imagine a version of Algorithm X that solves this by removing additional rows by manual application of the anti-knight rule, but I believe Wikipedia is claiming this constraint should be expressible in the matrix alone without modifying the algorithm.

Is Wikipedia’s claim that all variants can be expressed this way correct, and how would one approach the anti-knight example?

## Why is this language *not* pumpable? (language = arbitrary word followed by exact same arbitrary word)(pumping lemma for context-free-languages)

language = arbitrary word followed by exact same arbitrary word = u * u (with u being out of non-empty words of alphabet {0, 1} )
(sorry for the formatting, see screenshot-link for conventional/clear expression)

The purpose is to prove that the given language is not a context-free-language (using the pumping lemma).

So i thought that this language should definitely be pumpable, since you can choose x and z as corresponding parts in one of the u/"halves". So if word to be pumped is "0101" then you choose e.g. x=1 (0101) and z=1 (0101) and the remaining parts that stay static are assigned with u=0 (0101), y=0(0101), and v=empty.
If pumped zero-times/i=0 word reads: 00
i=1: 0101
i=2: 011011
i=3: 01110111
(and so on)

(For more complicated words you would need to use all three (u, y, v), but the basic principle would still be that x and z are assigned corresponding parts of the word and u,y,v would be assigned the remainder. (This doesn’t work for the extremely small words 00,01,10,11 that would become empty when zero-pumped, but as long as the exceptions are finite / of finite/fixed number this isn’t a problem AFAIU.)
Clearly this is wrong, but can anybody explain how/why?

## How to use ‘Bind Variables’ in a ‘Dynamic Query ‘ when the exact number of variables are not known

I have a procedure in which I’m using `Dynamic SQL`. The input parameter`i_tables` is a string which is a concatenation of the name of some tables . It might be one these :

1)All tables `test_table1,test_table2,test_table3`.

2)Only two tables , for instance `test_table2,test_table3` .

3)Nothing .So `NULL` will pass to the procedure.

I’ve read about `Bind variable` and the significant role it has in preventing `injection` and improving `performance`. I want to use bind variable in my procedure but there is one things I don’t know how to handle :

As you can see we do not know the exact number of variables.It might be one , two , three or nothing. Depending on The input parameter`i_tables`.

``   create or replace procedure bind_variable_test(i_tables varchar2,                                                   i_cid    number,                                                   o_result out sys_refcursor) is     actual_query varchar2(1000) := '';    begin         -- this is the base query     actual_query := 'select *                 from z_test_a t1                   inner join z_test_b t2                 on t1.id = t2.id';      -- check input parameter " i_tables "       if i_tables like '%test_table1%' then              actual_query := actual_query || '  inner join test_table1 t3 on t3.id = t1.id and                              t3.cid = ' || i_cid;      end if;       if i_tables like '%test_table2%' then             actual_query := actual_query || '  inner join test_table2 t4 on t4.id = t1.id and                              t4.cid = ' || i_cid;      end if;       if i_tables like '%test_table3%' then             actual_query := actual_query || '  inner join test_table3 t5 on t5.id = t1.id and                    t5.cid = ' || i_cid;      end if;      open o_result for actual_query;     end; ``

## Greedy Probabilistic Algorithm for Exact Three Cover

I have a probabilistic greedy algorithm for Exact Three Cover. I doubt it’ll work on all inputs in polytime. Because the algorithm does not run $$2^n$$ time. I will assume that it works for some but not all inputs.

Our inputs are $$S$$ and $$B$$

$$S$$ is just a set of integers

$$B$$ is a list of 3-element {}s

## Algorithm

1. Input validation functions are used to ensure that sets of 3 are $$elements$$$$S$$.

2. A simple $$if~~statement$$ makes sure that $$|S|$$ % $$3$$ = $$0$$

3. I treat the sets like lists in my algorithm. So, I will sort all my sets from smallest to largest magnitudes (eg {3,2,1} now will be sorted to {1,2,3}

4. I will also sort my list of sets called $$B$$ in an ordering where I can find all {1,2,x}s with all other {1,2,x}s. (eg, sorted list {1,2,3},{1,2,4},{4,5,6},{4,5,9},{7,6,5} )

5. I will also genereate a new list of sets containing elements where a {1,2,x} only occurs one time in $$B$$.

6. Use brute force on small inputs and on both sides of the list $$B$$ up to $$|S|$$ / $$3$$ * $$2$$ sets. (eg. use brute force to check for exact covers on left and right side of the list `B[0:length(s)//3*2]` and reversed `B[0:length(s)//3*2]`)

## Seed the PRNG with a Quantum Random Number Generator

``for a in range(0, length(B)):     o = quantumrandom.randint(0, length(B))     random.seed(int(o))  # I will create a function to shuffle B later  def shuff(B, n):     for i in range(n-1,0,-1):         random.seed()         j = random.randint(0,i+1)         B[i],B[j] = B[j],B[i] ``

## Define the number of times while loop will run

``n = length(s)  # This is a large constant. No instances # are impractical to solve.  while_loop_steps = n*241*((n*241)-1)*((n*241)-2)//6 ``

## While loop

``stop = 0 Potential_solution = [] opps = 0 failed_lists = 0 ss = s  while stop <= while_loop_steps:      opps = opps + 1     stop = stop + 1      shuff(B,length(B))          if length(Potential_solution) == length(ss)//3:         # break if Exact         # three cover is         # found.         OUTPUT YES         failed_lists = failed_lists + 1         HALT      # opps helps     # me see     # if I miss a correct     # list           if opps > length(B):         if failed_lists < 1:             s = set()             opps = 0               # Keep B[0]     # and append to     # end of list     # del B[0]     # to push >>     # in list.       B.append(B[0])     del [B[0]]     Potential_solution = []     s = set()          for l in B:         if not any(v in s for v in l):             Potential_solution.append(l)             s.update(l) ``

Run a second while loop for new_list if Step 5 meets the condition of there being only ONE {1,2,x}s )eg. {7,6,5} shown in step 4

## Two Questions

How expensive would my algorithm be as an approximation for Three Cover?

And, what is the probability that my algorithm fails to find an Exact Three Cover when one exists?

## Go back to the exact post page number

I use pagination in my index.php and I have many posts per page. Every post have a button to go back to home. The problem is that when I visit a post in a page 5 for example, the button always send me on the first page.

I’m using this: `<a href="<?php echo home_url(); ?>">back</a>`

Is there a simple way to track the post page position, and use it to go back properly?

## What’s the exact meaning of the phrase “when the target willingly moves” in Booming Blade?

The Booming Blade cantrip’s secondary effect states that “[the target] becomes sheathed in booming energy until the start of your next turn. If the target willingly moves before then, it immediately takes 1d8 thunder damage, and the spell ends”. We can deduce, then:

• That the damage does not trigger when the target is dragged or pushed around via physical means (grappling, shoving, scenario effects, etc.)
• That the damage does not trigger when the target is dragged or pushed around via magical means (Gust, Eldritch Blast with Grasp of Hadar, Graviturgist’s Gravity Well, etc.)

This seems pretty clear. However, what happens when the following cases arise?

• The target is ordered to move via the use of Command (assuming they don’t know yet that the thunderous aura is damaging).
• The target is forced to move via the use of Compulsion.
• The target is invited to move via the use of Suggestion.
• The target is Turned.
• The target is Frightened and forced to run via Dissonant Whispers.
• The target has a Geas that prohibits them from ending a turn next to an enemy if they can avoid it.
• The target is threatened into leaving the area or else. This one seems “willingly”, but are they truly willing if they are panicking because you are telling them you will cut their heads off if they don’t run?

This SageAdvice entry seems to suggest that forcing people to move via mind control spells doesn’t count as willing. However, from what I understand, Jeremy Crawford’s Twitter rulings are no longer considered official, so I was looking for something more solid to make a RAW judgement of this interaction.

## I am unable to understand the logic behind the code (I’ve added exact queries as comments in the code)

Our local ninja Naruto is learning to make shadow-clones of himself and is facing a dilemma. He only has a limited amount of energy (e) to spare that he must entirely distribute among all of his clones. Moreover, each clone requires at least a certain amount of energy to function (m) . Your job is to count the number of different ways he can create shadow clones. Example:

e=7;m=2

ans = 4

The following possibilities occur: Make 1 clone with 7 energy

Make 2 clones with 2, 5 energy

Make 2 clones with 3, 4 energy

Make 3 clones with 2, 2, 3 energy.

Note: <2, 5> is the same as <5, 2>. Make sure the ways are not counted multiple times because of different ordering.

``int count(int n, int k){     if((n<k)||(k<1)) return 0;     else if ((n==k)||(k==1)) return 1;     else return count(n-1,k-1)+ count(n-k,k);   // logic behind this? }  int main() {     int e,m;            // e is total energy and m is min energy per clone     scanf("%d %d", &e, &m);     int max_clones= e/m;     int i,ans=0;     for(i=1;i<=max_clones;i++){         int available = e - ((m-1)*i);   // why is it (m-1)*i instead of m*i         ans += count(available, i);     }     return 0; } ``

## When does Gaussian elimination solve exact 1-in-3 SAT?

Terms:

A literal is a variable or its negation.

A clause is a set of literals.

An exact 3-in-1 clause is satisfied if an assignment of values to variables results in exactly 1 `true` literal and 2 `false` literals.

Exact 3-in-1 SAT is the problem, given a set of exact 3-in-1 clauses, is there as assignment of variables that satisfies all clauses?

Question:

This corresponds to a linear algebra problem, sort of:

Let `true` be `1` and `false` be `-1`.

For each variable `v` and its negation `w`, add the equations:

`v + w = 0`

(This is because `1 + (-1) = 0`)

For each exact 3-in-1 clause (`a` `b` `c`), add the equations:

`a + b + c = -1`

(This is because two `-1`‘s and one `1` will add up to `-1`.)

It’s possible solving the equations results in a value other than `1` or `-1`. However if the solution to the system of equations is only `1` and `-1`, I suspect that’s a valid solution to the original exact 1-in-3 problem.

So, when does Gaussian elimination solve exact 1-in-3 SAT?

Here’s an example when it does:

These clauses:

(`1` `2` `3`) (`2` `3` `-2`) (`2` `3` `-3`)

Correspond to this matrix:

``1, 0, 0, 1, 0, 0, 0 0, 1, 0, 0, 1, 0, 0 0, 0, 1, 0, 0, 1, 0 1, 1, 1, 0, 0, 0, -1 0, 1, 1, 0, 1, 0, -1 0, 1, 1, 0, 0, 1, -1 ``

Reduced row echelon:

``1, 0, 0, 0, 0, 0, 1 0, 1, 0, 0, 0, 0, -1 0, 0, 1, 0, 0, 0, -1 0, 0, 0, 1, 0, 0, -1 0, 0, 0, 0, 1, 0, 1 0, 0, 0, 0, 0, 1, 1 ``

Therefore solution (via far-right column) is: (`1` `-2` `-3`)

Does this always work on larger matrices with `2*n` rows and `2*n+1` columns where `n` is the number of variables? (I think it may need non-redundant (linearly independent?) rows.)

## Knapsack Problem with exact required item number constraint

How would we solve the knapsack problem if we now have to fix the number of items in the knapsack by a constant L ? This is the same problem (max weight of W, every item have a value v and weight w), but you must add exactly L item(s) to the knapsack (and obviously need to optimize the total value of the knapsack).

Every way I’ve thought of implementing this so far (dynamic programming, brute force) has resulted in either failure, or lifetime-of-universe level computation times. Any help or ideas are appreciated.

## Website doesn’t show first when looking for the exact domain name

I need a website to have good results when looking for the domain name.

A quick rundown of my research results :

Searching for -> Results

“le-petit-pois.fr” -> “lepetitpois.fr”, which is another website.

`http://le-petit-pois`“->”lepetitpois.fr”

`https://le-petit-pois`“>”le-petit-pois.fr” (finally the good website)

Seeing that “petit pois” (green beans) is a pretty wide term in French, I focused the SEO on “petit pois+location”. The website is pretty new and I made adjustment to the SEO so that the website would be better ranked for searching the domain.

Weird thing is 2 domains are registered for the website and one is just a redirection. When searching for “le-fraisier.fr” (only redirection on this), it shows the good website as well.

What solution other than putting more value to the domain name in the SEO would be valuable?