Category "arrays"

How to generate numpy arrays with random regions with rectangular shape with random size?

I would like to generate a binary array (values are 1s and 0s) filled with rectangular regions. Something like this: a = np.array([0, 1, 1, 0, 0] [

Random array element creation into Dom only once JavaScript

I've got a problem to insert a random array element into the DOM. I want it to only do it once for each array element but the code keeps fetching the element in

How to copy char array of a structure into another char array of a structure?

#include <iostream> using namespace std; struct stud { char name[10]; int id; }; int input(stud a[], int size) { for(int i=1; i<=size; i+

Distirbute Candy - Finding minimum reproducible example of the problem

The question is to distribute candies to N children.Each child has a rating. Distribution should be such that each child have at least one candy and children wi

how do i make a picture box hide and show on click within an array?

im having trouble with a project which requires me to make a picture box inside of an array disappear when i click it, but for some reason, im having trouble ge

how to filter array to only pick last changed value of same id of object in react

This is the function i run on OnChange in AvField let selectedFieldArray = [] const templateValue = (e) => { const fieldObject = { "id": e.target.

Allocate a vector of bytes on stack in assembly x86

I try to put on stack the values contained by array_output but every time I print the values from the stack it prints just 0s. If I try to print the array simpl

Longest Common Prefix in Javascript

I am trying to solve the Leet Code challenge 14. Longest Common Prefix: Write a function to find the longest common prefix string amongst an array of strings.

Loop or map array inside the JavaScript object

I have an array of javascript objects like: const arrayData = [ { name: "campaign 1", date: "2022-05-13", milestones:[{name:"Planning", targetDate: "2022-05-25"

How to make a vector of matrices in numpy

I would like to create a vector of the same matrix in numpy (so as an array). Let's say the matrix is: w = np.array([[1,2], [3,4], [

How To write a function to Check for a Sequence of integers in an array in python

I'm trying to figure out why the code I wrote to find a sequence of integers in any given array is not catching all the instances. Could you help, please? Here'

Maximum Frequency Number in an array using Hashmaps

Problem: You are given an array of integers that contain numbers in random order. Write a program to find and return the number which occurs the maximum

k-diff sequences in a float array

Looking for an algorithm to find longest sequences (pairs, triplets, up to quadruplets) that are separated by a constant, non-integer difference k in a sorted a

ValueError: setting an array element with a sequence while using MLPCLassifier on classifier.fit

I have this dataset (shape is (36,2)). x is a numerical pattern, y is a binary class (0,1) x y [0.2, 0.3, 0.5 ..... 0.5] 0 [0.1, 0.4, 0.5 ..... 0.9] 1 and so

Iterate through array 1000 items at a time in an array of thousands

I want to loop through an array consisting of thousands of items. I want to process thousand item at a time. Is there a better way to achieve this ? const a = [

convert List of string array into xml

I need to convert list of array into xml. In the list the first object is the elements of the xml and from second object onwards it is the values of the element

How to execute class method in a Java program? [closed]

In this code, we have to add a method set() which will take two parameters, an int index, and an Integer value, which will set the array eleme

SwiftUI View not updating based on @ObservedObject

In the following code, an observed object is updated but the View that observes it is not. Any idea why? The code presents on the screen 10 numbers (0..<10)

Airplane seating program (2 dimensional array)

I have an airplane seating program but I don't know how to get it to print the number of seats still available and how to get it to quit when I enter q. Any he

how to retrieve the first and last instance of a row in pdo dataset

I have a dataset that I retrieve using PDO and fetchall. I need to find the first date a part was sold and its cost then also I need to find the last date that