Categories
Linux Mastering Development

looping in awk, calculating percentages for each integer within its column

I have a line of code I want to use, but I want it to loop through all the columns in a file, I can do it outside of awk but its really slow. My problem is that I’m not good at looping inside awk, I can run a simple awk loop but this needs […]

Categories
Mastering Development

How do you split an array of sorted values into N arrays with max sum X?

I have a large array with a bunch of integers in it, sorted from largest to smallest: Array( 0 => 472, 1 => 388, 2 => 211, 3 => 194, 4 => 175, … 29 => 13, 30 => 6, 31 => 3, 32 => 3, 33 => 1 ) What I need to do […]

Categories
Mastering Development

Mongodb sum by field exists

I have the following collection with the number of fields changing over time. { “_id” : “9235@7421”, “usine” : { “0” : 0, “1” : 3, “2” : 1, “3” : 2, “4” : 0, “5” : 3, “6” : 1, “7” : 0, “8” : 2, “9” : 1 }, “ecole” : { “0” […]

Categories
Mastering Development

Extracting Values from text using Python

I have long list of text from a pandas dataframe. However I am going to explain what I want to do just with one example. I have two pre-defined lists. These two-predefined list can be used for extracting the values I need from the text: ingredient_name_list = [‘butter’, ‘butter oil’, ‘cheese’, ‘cheese food’, ‘cheese spread’, […]

Categories
Mastering Development

recursive function for 2D list

I’m very new to f# so please forgive my ignorance. I have a 2D list of int. I’m trying to make a function that will return another 2D list which will contain only the lowest tail items. Something like this: [[2, 3] [2, 4] [2, 5] [[2, 3] [3, 8] => [3, 2] [3, 6] […]

Categories
Mastering Development

How to write to a text or csv file in python?

In images folder, I have 10 images of my face and I used face detection for each image in the folder. How can I put these results from my code below in a CSV file or a text file? ######## Full code face detection ################ from cv2 import * import numpy import glob import sys […]

Categories
Mastering Development

r force a list to dataframe

I am trying to take a nested list and store the contents into a dataframe. The list is an output from the Hmsic::describe function. Here is a test case. list <- Hmisc::describe(iris) This list has multiple objects and some are nested. I am only interested in a subset of objects in the list. unlist(list [[1]])[1:4] […]

Categories
Mastering Development

How to validate a numeric field value in react using Yup? I want to check if the number provided is in increments of 0.01 or 0.1

I have the below code to validate the numeric value provide to be an increments of ‘fraction’ i provide , which works fine for 0.25 , 0.5 etc but not 0.1 , 0.01 export function buildFractionStepTest(message: () => string,fraction: number): Yup.TestOptions{ return { name: ‘fractionStepNumericValue’, test: (value: number | null) => typeof value !== ‘number’ […]

Categories
Ask Board Games Games

How does Shield Dancer’s ability work with a creature that has Trample?

I have a Shield Dancer, 1/3, whose activated ability states: “The next time target attacking creature would deal combat damage to Shield Dancer this turn, that creature deals that damage to itself instead. He blocks a 6/1 creature with Trample. Trample states that leftover damage carries over to the ‘defending’ player. With the Shield Dancer’s […]

Categories
Mastering Development

Can someone explain in detail how mapping this array works step by step

The original array: [ [3, 5], [9, 6], [3,1] ] 1) Make the first number in each mini array the smaller number and the second number in each mini array the bigger number – [ [3, 5], [9, 6], [3,1] ] -> [[ 3,5], [6,9], [1,3]] 2) Sort the mini arrays by first number. – […]