Plugin Development – Go through custom posts and add the title to an array

The main problem is that you need to use get_the_title() Instead of the_title() in your code as the_title() is repeated and can not be set to a variable.

It appears that you want your pickup location (custom post type) to appear in a drop-down box (or radio button) on the WooCommerce Checkout page.

You can also use it easily get_posts() work like:

add_action('woocommerce_after_order_notes', 'custom_checkout_field');

function custom_checkout_field( $checkout ) {

    $pickup_points = (array) get_posts( array(
        'post_type'         => 'pickup-point',
        'posts_per_page'    => -1,
        'post_status'       => 'publish'
    ) );

    if ( count( $pickup_points ) > 0 ) {

        $available_locations = (); // Initializing

        // Loop though each 'pickup-point' WP_Post object
        foreach ( $pickup_points as $pickup_point ) {
            // Set current post title in the array
            $available_locations() = $pickup_point->post_title;
        }

        // testing output
        var_dump ($available_locations);
    }
}

Or if you keep one WP_Query:

add_action('woocommerce_after_order_notes', 'custom_checkout_field');

function custom_checkout_field( $checkout ) {

    // Custom query to pull in the pickup points.
    $query = new WP_Query( array(
        'post_type'         => 'pickup-point',
        'posts_per_page'    => -1,
        'post_status'       => 'publish'
    ) );

    $available_locations = (); // Initializing

    // Check that we have query results.
    if ( $query->have_posts() ) :

    $available_locations = (); // Initializing

    while ( $query->have_posts() ) : $query->the_post();

    $available_locations() = get_the_title(); // Set the current title in the array

    endwhile;

    // testing output
    var_dump ($available_locations);

    wp_reset_postdata();

    endif;
}

Both should work the same.

java – How to cross an array from a waypoint

I have to go through a matrix from a point of reference, I want to know what the best option would be, I can not imagine how to start with one forSuppose I have the following 8×5 matrix

matrix

I could do the checks from the red point by hand ((5) (2)), but if it were a page that would already have the matrix burst, there would be a way to create a for to assign that matrix run through?

Initially, I had considered performing the direct operations, for example, to go to the top left (x - 1),(y - 1)But I think there has to be a way to meet my needs.

Array – Are you scrolling from a random Java position through a matrix?

Basically, I have a matrix loaded with 0.1 and 2, in which I arbitrarily position myself in one of these 0 and from there convert all found 1 to 0 and consider the 2 as obstacles.

There's my dilemma, I do not know how to go through the Matrix. I have the basic idea of ​​checking the values ​​around me and moving around, but I think I would have to use too many if and it does not seem practical at all.

Pointer – Dynamically allocate a 2D array in C

I understand code, but explain what is int *arr = (int *)malloc(r * c * sizeof(int)); specially malloc(r* c*) Part.

#include  
#include  

int main() 
{ 
    int r = 3, c = 4; 
     /*Explain this Code please! */
    int *arr = (int *)malloc(r * c * sizeof(int)); 

    int i, j, count = 0; 
    for (i = 0; i <  r; i++) 
      for (j = 0; j < c; j++) 
         *(arr + i*c + j) = ++count; 

    for (i = 0; i <  r; i++) 
      for (j = 0; j < c; j++) 
         printf("%d ", *(arr + i*c + j)); 

   /* Code for further processing and free the  
      dynamically allocated memory */

   return 0; 
} 

Is there an algorithm for compressing a string array represented as a pointer to a long string to pointers with a compressed version of the long string?

In a program I write, I represent an array of strings as a long string and have pointers pointing to the different substrings to represent my array. For example,

str_array = struc string_array
   long_str = "abcdefab"
   pointer_array = ((start = 0, len = 3), (start = 3, len = 3), (start = 6, len=2))
end

So str_array = ("abc", "def", "ab")but note that I can actually compress the long string by removing "down" at the end. For example,

str_array2 = struc string_array
   long_str = "abcdef"
   pointer_array = ((start = 0, len = 3), (start = 3, len = 3), (start = 0, len=2))
end

and notice that str_array2 is too ("abc", "def", "ab") === str_array,

What is this type of compression in computer science? I assume there is already literature about these types of algorithms?

python – Numpy – Maximum of each line of a 2D array after a given index

Consider this 2D array:

import numpy as np
a = np.array(((3,1,5,3),(1,4,8,2),(4,2,1,2),(9,2,4,4)))

I know how to find the maximum entry of each line: np.amax(a, axis=1), This returns array((5,8,4,9))

However, what I want to do is get the maximum entry of each line after a particular index nignoring the first one n Terms and only looking for the maximum among the remaining entries in that line for each line.

One complication: the point at which I "cut" each row is different for each row.

Example: I would like to calculate the maximum of each line, but only among the last 2 entries in the first line, the last 3 entries in the second line, the last 2 in the third line and the last 1 in the fourth line. This should return array((5,8,2,4))

If that works without it for or while Loops, that would be great – I really can not use them because of computational time limitations.

Recursion – repeating the division of a matrix array?

If we have a matrix of nxn, how often is it divided into 4 equal parts of size (n / 2) * (n / 2)?

I thought it was 4T (n / 4) because we divide it into a quarter of the original size, but I saw a similar problem in my book (matrix multiplication) in which the repetition occurred by splitting two matrices into 8 (n / 2) * (n / 2) matrices was 8T (n / 2).

Would it be kT (n / 2) or kT (n / 4)?

Determine the largest sequence in a 2D array

I'm having trouble finding this weird one. I can not figure out how to best solve it.

If you get a 2D array size n * n with only ones and zeros, you must find the longest sequence of ones, either column by column or row by row.

I'm pretty much stuck in this problem. I've tried dividing the array into 4 n / 2 * n / 2 arrays using a divide-and-conquer technique, but the step in which I merge is still so slow because I have every adjacent row / column must check. Any advice on a quick fix would be great. I've spent far too much time staring at it.

Combinatorics – Go function for generating permutations of a particular integer array

I am writing a function to produce a permutation of given ()int:

// Input: (1,2,3)
// Output:
// (
//   (1,2,3),
//   (1,3,2),
//   (2,1,3),
//   (2,3,1),
//   (3,1,2),
//   (3,2,1)
// )

func permute(nums ()int) ()()int {
    var tmp ()int
    var res ()()int
    invalid_pos := make(()bool, len(nums))
    res = backtrack(nums, tmp, invalid_pos, res)
    return res
}

// backtrack generates all the permutations of the given `nums` and put them into `res`.
// `invalid_pos` keeps track of which number is valid to pick from `nums` to form a permutation
// `tmp`
func backtrack(nums ()int, tmp ()int, invalid_pos ()bool, res ()()int) ()()int {
    if len(tmp) == len(nums) {
        tmp2 := make(()int, len(tmp))
        copy(tmp2, tmp)
        res = append(res, tmp2)
    } else {
        for i, num := range nums {
            if invalid_pos(i) {
                continue
            }
            invalid_pos(i) = true
            tmp = append(tmp, num)
            res = backtrack(nums, tmp, invalid_pos, res)
            invalid_pos(i) = false
            tmp = tmp(:len(tmp)-1)
        }
    }
    return res
}

My question is, do I have to make a copy? copy(tmp2, tmp)? I've read about iterating variables and wondered if this will have any side effects. I think I can simplify the code by removing it copy