## How do you render_callback for register_block_type to a method in another class?

I’m writing a new plugin, and one of the things it does is create a new dynamic block. I generally write my plugins based off of WPPB, which does things in an object-oriented way, and semantically separates admin functionality from public functionality.

I have the admin class successfully creating the edit side of the block. But for the "save" side, for a dynamic block, it makes semantic sense for the render function to be in the public class … but (I think) it needs to get registered in the admin class (actually, now that I’m writing this, is there any harm to calling register_block_type more than once?).

I’m thinking there’s more than one way to skin this cat, and I’m trying to figure out the "best", where "best" is making optimal use of both PHP OOP and WordPress builtin functionality, to maximize speed, minimize size, and provide clean, readable code.

Option 1: make sure the main plugin class instantiates the public class first, and then passes it to the admin class:

class My_Plugin {         $my_public = new My_Public();$  my_admin = new My_Admin($my_public); } class My_Admin { public function __construct($  my_public) {                 $this->my_public =$  my_public;         }          register_block_type( 'my-plugin/my-block',                     array(                         'editor_script' => 'my_editor_function',                         'render_callback' => array($this->my_public, 'my_save_function') ) ); } class My_Public { public function my_save_function() { //do stuff to render the public side of the block } }  Option 2: do something with WordPress Actions and Hooks: class My_Admin { register_block_type( 'my-plugin/my-block', array( 'editor_script' => 'my-editor-function', 'render_callback' => 'render_front_end') ) ); public function render_front_end() { do_action('my_plugin_render_action'); } } class My_Public { public function my_save_function() { //do stuff to render the public side of the block } add_action('my_plugin_render_action', 'my_save_function', 10); }  Or, hypothetically, Option 3: if there’s no problem calling the register function more than once: class My_Admin { register_block_type( 'my-plugin/my-block', array( 'editor_script' => 'my-editor-function', ) ); } class My_Public { register_block_type( 'my-plugin/my-block', array( 'render_callback' => 'my_save_function' ) ); public function my_save_function() { //do stuff to render the public side of the block } }  Is one of these preferable? Do all of these work? Is there a better way to do this? ## No route was found matching the URL and request method. I don’t understand where the problem is When I send parameters, I get this: No route was found matching the URL and request method. /** * Add json data on plugin. * * */ add_action('rest_api_init', 'register_api_hooks'); function register_api_hooks() { register_rest_route( 'passwordless_register/v0', '/register/(?P<name>[a-zA-Z0-9-]+)/(?P<email>[a-zA-Z0-9-]+)/?aam-jwt=(?P<token>[a-zA-Z0-9-]+)', array( 'methods' => 'POST', 'callback' => 'wc_rest_user_endpoint_handler', ) ); } /** * Register a new user * * @param WP_REST_Request$  request Full details about the request.  * @return array $args. **/ function wc_rest_user_endpoint_handler($  request) {   $request = new WP_REST_Request( 'POST', 'passwordless_register/v0/register/(?P<name>[a-zA-Z0-9-]+)/(?P<email>[a-zA-Z0-9-]+)/?aam-jwt=(?P<token>[a-zA-Z0-9-]+)' );$  username = $request['name'];$  email = $request['email'];$  response = array();   $error = new WP_Error(); if (empty($  username)) {     $error->add(400, __("name field 'username' is required.", 'wp-rest-user'), array('status' => 400)); return$  error;   }   if (empty($email)) {$  error->add(401, __("Email field 'email' is required.", 'wp-rest-user'), array('status' => 400));     return $error; }$  user_id = username_exists($username); if (!$  user_id && email_exists($email) == false) {$  password = wp_generate_password( 20, false );     $user_id = wp_create_user($  username, $password,$  email);     if (!is_wp_error($user_id)) { // Ger User Meta Data (Sensitive, Password included. DO NOT pass to front end.)$  user = get_user_by('id', $user_id); //$  user->set_role($role);$  user->set_role('subscriber');       // WooCommerce specific code       if (class_exists('WooCommerce')) {         $user->set_role('customer'); } // Ger User Data (Non-Sensitive, Pass to front end.) wp_nonce_field( 'wpa_passwordless_login_request', 'nonce', false );$  unique_url = wpa_generate_url( $email ,$  nonce );       $response['code'] = 200;$  response['message'] = __("User '" . $username . "' Registration was Successful", "wp-rest-user");$  response['mail'] = __("Mail '" . $email . "' Registration was Successful", "wp-rest-email");$  response['password'] =  __("Pass '" . $password . "' Registration was Successful", "wp-rest-pass");$  response['url'] =  __("Link '" . $unique_url . "' Registration was Successful", "wp-rest-url"); } else { return$  user_id;     }   } else {     $error->add(406, __("Email already exists, please try 'Reset Password'", 'wp-rest-user'), array('status' => 400)); return$  error;   }   return new WP_REST_Response($response, 123); } add_action( 'after_setup_theme', 'passwordless_register/v0' );  ## Choosing Constant for Last Step in Substitution METHOD$T(n)= 5T(n/4) + n^2\$

I figured out a solution to a recurrence relation, but I’m not sure what the constant should be for the last step to hold.

$$T(n)= 5T(n/4) + n^2$$

Guess: $$T(n) = O(n^2)$$

Prove: $$T(n) \leq cn^2$$

Breakdown

$$T(n) \leq 5(c(n/4)^2) + n^2$$

$$= (5/16)cn^2 + n^2$$

$$\leq cn^2$$

For the last step to hold I’m not sure what the value of c should be because of the (5/16). My guess would be c >= 1 and I’m not sure if that would hold.

## Is My Recurrence Solution Correct? (Substitution method)

nvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvm

## Most efficient method for set intersection

Suppose I have two finite sets, $$A$$ and $$B$$, with arbitrarily large cardinalities, the ordered integral elements of which are determined by unique (and well defined) polynomial generating functions $$f:\mathbb{N}\rightarrow\mathbb{Z}$$ given by, say, $$f_1(x_i)$$ and $$f_2(x_j)$$, respectively. Assume, also, that $$A\cap B$$ is always a singleton set $$\{a\}$$ such that $$a=f_1(x_i)=f_2(x_j)$$ where I’ve proven that $$i\neq j$$.

Assuming you can even avoid the memory-dump problem, it seems the worst way to find $$\{a\}$$ is to generate both sets and then check for the intersection. I wrote a simple code in Sagemath that does this, and, as I suspected, it doesn’t work well for sets with even moderately large cardinalities.

Is there a better way to (program a computer to) find the intersection of two sets, or is it just as hopeless (from a time-complexity perspective) as trying to solve $$f_1(x_i)=f_2(x_j)$$ directly when the cardinalities are prohibitively large? Is there a parallel-computing possibility? If not, perhaps there’s a way to limit the atomistic search based on a range of values—i.e., each loop terminates the search after it finds the first $$i$$ value such that $$f_1(x_i)>f_2(x_j)$$, knowing that $$f_1(x_{i+1}), f_1(x_{i+2}), f_1(x_{i+3}), \cdots, f_1(x_{i+n})>f_1(x_i)>f_2(x_j)$$.

## Choosing a method for algorithmic problems – is it an art or science?

I’ve been doing lot of programming challenges lately (such as on leetcode.com) and often find myself in a situation when I cannot pick a method for solving a problem. I stuck with questions like – should I use brute force or greedy search would work better or maybe dynamic programming would do the job? Then I start coding a solution just too find out it does not work and I have to pick another method.

I wonder if there is a way to restate the problem in some abstract way and from there to see what solution technique would work for it?

## Choosing an AI method to recreate a given binary 2D image

If the title wan not very clear, I want a method to take an input image like this,

[[0, 0, 0, 0],  [1, 1, 1, 0],  [1, 1, 1, 0],  [0, 1, 1, 0]] 

and output the 2D coordinates of the 1s of the image (So that I can recreate the image)

I want the output to be sequential because I need to reconstruct the input image pixel by pixel and there are some conditions on the image construction order (e.g. You cannot place a 1 somewhere when it is surrounded by 1s)

The image can change and the number of 1s in the image too.

1. What is an appropriate AI method to apply in this case?
2. How should I feed the image to the network? (Will flattening it to 2D affect my need of an output order?)
3. Should I get the output coordinates one by one or as an ordered 2xN matrix?
4. If one by one, should I feed the same image for each output or the image without the 1s already filled?

EDIT: The application is a robot creating the image using some kind of building blocks, placing one block after the other

I have tried to apply "NeuroEvolution of Augmenting Topologies" for this using neat-python but was unsuccessful. I am currently looking at RNNs but I am not sure if it is the best choice either.

## convergence rate of newton’s method

So, I’m currently studying Newton method used for finding the 0’s of a function, however my professor has only announced that the speed of this algorithm can be more than quadratic, however I’m wondering when this happens, since in the demonstration used by him to explain the quadratic case, there is no evidence about the "more than quadratic"

Using Taylor and Lagrange
$$f(\xi)=f(x_n)+f'(x_n)(\xi-x_n)+\frac{f”(z_n)}{2}(\xi-x_n)^2$$

$$-\frac{f(x_n)}{f'(x_n)}=\xi-x_n+\frac{f”(z_n)}{2f'(x_n)}(\xi-x_n)^2$$

$$x_{n+1}-x_n=\xi-x_n+\frac{f”(z_n)}{2f'(x_n)}(\xi-x_n)^2$$

$$e_{n+1}=\left|x_{n+1}-\xi\right|=c_ne_n^2 \quad \text{with} \quad c_n=\frac{1}{2}\frac{\left|f”(z_n)\right|}{\left|f'(x_n)\right|}$$

Can someone please tell me when (example) the order of the convergence is cubic, and why?=

## Why decision tree method for lower bound on finding a minimum doesn’t work

(Motivated by this question. Also I suspect that my question is a bit too broad)

We know $$\Omega(n \log n)$$ lower bound for sorting: we can build a decision tree where each inner node is a comparison and each leaf is a permutation. Since there are $$n!$$ leaves, the minimum tree height is $$\Omega(\log (n!)) = \Omega (n \log n)$$.

However, it doesn’t work for the following problem: find a minimum in the array. For this problem, the results (the leaves) are just indices of the minimum element. There are $$n$$ of them, and therefore the reasoning above gives $$\Omega(\log n)$$ lower bound, which is obviously an understatement.

My question: why does this method works for sorting and doesn’t work for minimum? Is there some greater intuition or simply "it just happens" and we were "lucky" that sorting has so many possible answers?

I guess the lower bound from decision tree makes perfect sense: we do can ask yes/no questions so that we need $$O(\log n)$$ answers: namely, we can use binary search for the desired index. My question still remains.

## What method can be used to obtain a fifth and sixth “bonus feat”?

The goal is to obtain a total of six feats that clearly have the label of "bonus feat" at first level. The character class is Erudite, which has two first level bonus feats. Taking two flaws grants two more bonus feats.

How can I obtain the last two bonus feats at first level? Is there a race or template which has two features or abilities using the words bonus feat?

Not interested in TOs (theoretical optimizations), or methods which require helper NPCs, or wealth beyond a starting Erudite’s Wealth by Level.