Choose $n$ out of $2n-1$ boxes containing at least half of all white balls and half of all black balls


We are given $ 2n – 1$ boxes with black and white balls. In the $ i$ -th, box there are $ w_i$ white and $ b_i$ black balls. It is required to choose $ n$ boxes so that, the sum of the white balls is at least $ W/2$ , and the sum of black balls is at least $ B/2$ . Solve for $ O(n\log{n})$ .

What I am currently thinking is this:

Generate some hashtable to be able to track the boxes that we chose.
Sort the boxes by the quantity of the white (in increasing order) balls and chose the last $ n$ balls every time keeping them in our hashtable.
Sort by the quantity of the black balls and do the same. Check every time to see if we already chose the box or not. Here comes the problem: Suppose we didn’t. Then we can face a situation where we already have $ n$ boxes that have in total at least $ W/2$ white balls but at the same time, they have in total less than $ B/2$ black balls. How can we overcome this problem?

We can’t just switch the chosen boxes that have the least number of white balls with the one that have the maximum available number of black balls since the box with white balls can contain significant amount of black balls on its own.

Putting Blocks in Boxes Untill th height is met Using Dynamic Programming

I am pretty new in the field of DP. My friend recently gave me a question from one of his old assignments to solve and practice and I am stuck at it.

The question says:

Given n blocks of same height and width but the different thickness and list B = (b_1, . . . , b_n) of the thickness of the block, define a DP algorithm to fit all the blocks in k boxes where each box can fit t thickness of blocks at most.

I was thinking of putting as many blocks in the first 2 boxes and the third one will be filled with the left blocks. But I have no idea how to break it down into the subproblems and create the base cases to define the time required. Any help will be appreciated. The given time complexity is O(nt^2).

Thanks!

(Quiz/Algorithm) How many boxes are needed?

I have X pieces to store in Y boxes.

The boxes vary in size and contain N, M, L, Q pieces.

How do I find which boxes and how many boxes to use, in order to use as few of them as possible and without advancing pieces?

Nb: The number of boxes is integer. Not necessarily the boxes are dismantled.

Example

Pieces: 98

Boxes: A (Containing 20 pieces), B (Containing 5 pieces), C (Containing 4 pieces), D (containing 3 pieces)

Answer: (4 box A) + (3 box B) + (1 box D)

What’s the algorithm?

Disable Fields in Custom Meta Boxes inside Custom Post Type

I want to create an Options page for my plugin.

I have two custom post types. Both habe metaboxes with fields inside. They are perfectly saving now (thanks to you guys on stackexchange).

Now, I want to create an Options Page (already done) and want to allow the admin to disable or enable every single field of every metabox

For example

Post Type: np-food Metabox: nutrition-info fields: energy_kcal, energy_kilojoule, etc

Optionspage:

Enable energy_kcal yes/no dropdown Enable energy_kilojoule yes/no dropdown

Saving removes them if disabled and let them appear if enabled.

Glad for any help 🙂

Have a great Day

Buddy

Is this a valid heuristic for Dots and Boxes to reduce the branching factor of the search tree?

I am implementing an AI based on the MiniMax algorithm that plays the game Dots and Boxes. I would like to reduce the branching factor of the search tree, by introducing a heuristic rule that limits the number of successor states. However, I am not sure whether there exist any situations, where this rule would exclude the optimal move and make the AI play worse.

In the game 2 players take turns, until one of them captures a box, after which they have to make another move, possibly capturing another box etc. For this purpose, I define successor states of $ S$ to be all states, where the opponent gets the move, or the terminal state. If a player made a capture and still has to make another move, then the current state is not yet a successor state of $ S$ – the player has to continue making moves until they’re unable to.

My rule is as follows:
Assume a player makes a series of captures from a starting state $ S$ and ends it with a move $ m$ , after which the turn goes to the opponent. Then it’s always better or at least not worse for the player to have made as many captures as possible before finishing the sequence with $ m$ .

This means that any state $ S$ always has less successors, then there are legal moves. All successors where the player captures $ n$ boxes and finishes with move $ m$ are discarded, unless $ n$ is the maximum number of boxes that can be captured such that $ m$ can still be a finishing move. For example, in the following state:
example state
immediately capturing the 4 boxes leads to a loss, while dividing them into 2 small chains, 2 boxes each, with the move (2,2)-(2,3) leads to a victory. The optimal strategy is consistent with the rule, as it would not be possible to finish with the move (2,2)-(2,3), if any of the boxes were captured. The rule excludes all successors, where the player captures 1 or 2 boxes, from being considered.

How can i write script for search two different List columns of search boxes related data show on grid view in SPFX?

Am able to search the PR_Number column data, the same i want to search for Description as input in another search box and show the gridview in SPFx.

import * as React from 'react'; import * as ReactDom from 'react-dom'; import { Version } from '@microsoft/sp-core-library'; import {   BaseClientSideWebPart,   IPropertyPaneConfiguration,   PropertyPaneTextField } from '@microsoft/sp-webpart-base'; //import styles from './PrFilter.module.scss'; import { escape } from '@microsoft/sp-lodash-subset';  import * as strings from 'PrFilterWebPartStrings'; import PrFilter from './components/PrFilter'; import { IPrFilterProps } from './components/IPrFilterProps'; import { SPHttpClient, SPHttpClientResponse } from '@microsoft/sp-http';  export interface IPrFilterWebPartProps {   description: string; } export interface ISPLists {   value: ISPList[]; } export interface ISPList {   PR_Number: string;   Description: string;   Request_Date: string; }      export default class PrFilterWebPart extends BaseClientSideWebPart<IPrFilterWebPartProps> {    private _getListData(): Promise<ISPLists> {       let queryString: string = '';     let queryStringforPR: string = '';     let searchboxVal: string=(this.domElement.querySelector('#searchbox') as  HTMLInputElement).value;     if(searchboxVal!=""){       // alert("searchboxVal" + searchboxVal);             queryString="$  filter=substringof('"+searchboxVal+"',PR_Number)";       queryStringforPR= searchboxVal;       console.log("qurery string value is " + queryString);       console.log("queryStringforPR value is " + queryStringforPR);     }     return this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl + `/_api/web/lists/GetByTitle('PurchaseRequest')/Items?$  filter=PR_Number eq $  {queryStringforPR}`, SPHttpClient.configurations.v1)         .then((response: SPHttpClientResponse) => {             return response.json();         });   }   private _renderListAsync(): void    {       this._getListData()     .then((response) => {       this._renderList(response.value);     });   }    private _renderList(items: ISPList[]): void    {     //debugger;     let html: string = '<table class="TFtable" border=1 width=100% style="border-collapse: collapse;">';     html += `<th>PR_Number</th><th>Description</th><th>Request_Date</th>`;     items.forEach((item: ISPList) => {       html += `           <tr>           <td>$  {item.PR_Number}</td>           <td>$  {item.Description}</td>           <td>$  {item.Request_Date}</td>           </tr>           `;     });     html += `</table>`;     const listContainer: Element = this.domElement.querySelector('#spListContainer');     listContainer.innerHTML = html;   }   private _setSearchBtnEventHandlers(): void    {     //debugger;     this.domElement.querySelector('#searchBtn').addEventListener('click', () => {         this._renderListAsync();     });   }     public render(): void {      this.domElement.innerHTML = `     <div>     <div>        <div class="ms-Grid-row ms-fontColor-white">         <div class="ms-Grid-col ms-u-lg10 ms-u-xl8 ms-u-xlPush2 ms-u-lgPush1">                  <p class="ms-font-l ms-fontColor-white" style="text-align: center">P2P Tool</p>         </div>       </div>       <div class="ms-Grid-row ms-fontColor-white ">          <input id="searchbox" type="textbox"/><input id="searchBtn" type="button" value="Search"/>         <input id="searchboxDescription" type="textbox"/><input id="searchBtnDescription" type="button" value="Search"/>              <br>         <div id="spListContainer" />       </div>     </div>   </div>`;     this._renderListAsync();     this._setSearchBtnEventHandlers();   }    protected get dataVersion(): Version {     return Version.parse('1.0');   }    protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {     return {       pages: [         {           header: {             description: strings.PropertyPaneDescription           },           groups: [             {               groupName: strings.BasicGroupName,               groupFields: [                 PropertyPaneTextField('description', {                   label: strings.DescriptionFieldLabel                 })               ]             }           ]         }       ]     };   } }  

enter image description here

Alternatives to boxes

I have a box problem. 90% of all my original magic items either are boxes, or are inside boxes. I try to hide it by making them interesting shapes, but ultimately a box is a box.

It has gotten to the point where if I even so much as mention a box, the words “a box, must be important!” can be heard around the table.

How do I break my box habit, and what alternatives do I have to boxes?

nested boxes algorithm

I am given a set of 3D boxes {$ B_1$ , $ B_2$ $ B_n$ } and each box have length, width and height. But these values are interchangeable since I can rotate the box. I need to find out the maximum sequence of nested boxes.

I have tried this problem using sort. But I still get stuck. I used built in sort function to sort all boxes by length in ascending order. I read the reference about this question and learned that people used radix sort. I have know idea how radix sort is applied here because all sorts I am familiar is comparison sort.

Add boxes for generic_fields

Some fields could be added by default, but not required. Its not a perfect solution, it would me much better to create additional .dat file, where we could define custom types (just like in engine.ini) that can be used for generic fields <- all of them could pop – up in project settings as additional but not required. But they should not be overriden by default Engines data fields ? Its a thing to discuss.

 Facebook_URL
Twitter_url
about_yourself

Check off the boxes you wish to unsubscribe from

In attempting to unsubscribe from a company’s emailing list, I was directed to a website with the following form.

enter image description here

Note the phrase “Check off the boxes… you wish to unsubscribe from.” Is this some type of standard phrasing? The use of the terms off and unsubscribe seem to make the sentence ambiguous; should I check or uncheck? (The default page has all check boxes unchecked.)

Is there a way this company can improve their phrasing?