Categories
Mastering Development

How to make the decimal work in calculator p5.js

So I am building a calculator using only p5.js. I have made it all function properly exept from one button. The decimal point. I have done something on the decimal in my code but it doesn’t really work like I want it. Does anyone know how to make this feature work. Help is hghly appreciated. […]

Categories
Mastering Development

Removing first index of an array [duplicate]

I have an array that i’d like to remove the first index of an array before. I’ve looked up some examples and saw that .shift() is the quickest and easiest method to use in what I am trying to accomplish. so I declare a variable stateData to equal the original array.shift my console.log log is […]

Categories
Mastering Development

pyalgotrade can not procee csv feed in strategy

I am trying to load 1- minutes data into pyalgotrade. The feed is loaded correctly but I have some weird error in initializing strategy. Anyone can give some advice on this? Here is the code class MyStrategy(strategy.BacktestingStrategy): def __init__(self, feed, instrument): super(MyStrategy, self).__init__(feed) self.__instrument = instrument self.__rsi = rsi.RSI(feed[instrument].getCloseDataSeries(), 14) self.__sma = ma.SMA(self.__rsi, 15) self.__instrument […]

Categories
Mastering Development

MongoDB How to count where total of sub documents is greater than 3 and sum of sub documents value is greater than 15000

Sample data: { “_id” : “5e7b0e1c4669fe48ea07b63a”, “isActive” : false, “balance” : -1503.89, “age” : 27, “eyeColor” : “green”, “name” : “Allison Alvarez”, “gender” : “female”, “company” : “RONELON”, “email” : “allisonalvarez@ronelon.com”, “phone” : “+1 (963) 559-2276”, “address” : “583 Sumpter Street, Stewartville, West Virginia, 110”, “registered” : “2016-10-19T11:45:39 -01:00”, “outstandingloans” : [ { “id” : […]

Categories
Mastering Development

Multiply each element of generic class

I have a generic class, that contains a list of type T, and I have method ‘concat’ that concatenates two objects and return new one. I need to make it concat two lists, but if the type of list Int, Double or Float it should multiply each element of list on result of func class […]

Categories
Mastering Development

Distribute value to zones using population ratio and min/max criteria in R

I have the following data: require(“data.table”) dt1 <- data.table(ZONE = c(“A34″,”G345″,”H62″,”D563″,”T63″,”P983″,”S24″,”J54″,”W953″,”L97″,”V56″,”R99”), POPULATION = c(40,110,80,70,90,90,130,140,80,30,80,50), MIN = c(1,0,0,1,0,1,0,1,1,0,1,1), MAX = c(10,9,2,11,12,8,5,3,2,0,8,8)) I would like to distribute 50, let’s say hats, to these zones weighted on the population. However, some of these zones require at least 1 hat while others can receive only a very small number […]

Categories
Mastering Development

How to optimize this pandas iterable

I have the following method in which I am eliminating overlapping intervals in a dataframe based on a set of hierarchical rules: def disambiguate(arg): arg[‘length’] = (arg.end – arg.begin).abs() df = arg[[‘begin’, ‘end’, ‘note_id’, ‘score’, ‘length’]].copy() data = [] out = pd.DataFrame() for row in df.itertuples(): test = df[df[‘note_id’]==row.note_id].copy() # get overlapping intervals: # https://stackoverflow.com/questions/58192068/is-it-possible-to-use-pandas-overlap-in-a-dataframe […]

Categories
Mastering Development

When I enter a word such as “hi” in edittext the app crashes

EditText et = (EditText) findViewById(R.id.editText); String value = et.getText().toString(); int number = Integer.parseInt(value); Full code – package com.example.numbersystems; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.InterstitialAd; public class Main3Activity extends AppCompatActivity { String input2; String input1; AdView adView3; InterstitialAd interstitialAd1; @Override […]

Categories
Mastering Development

How can I Iimit the data that the user write in R?

checknames <- function(){ gamers <- c(“Rebeca”,”Luis”,”Paco”) games <- c(3,2,7) scores <- c(100,110,50) table <- data.frame(gamers,games,scores) r=0 p=0 repeat{ print(“Name Player 1: “) name1=scan(,what=”character”,1) if(any(name1==gamers)){ r=readline(prompt = “This player is already in the file. Would you like to change the name? \n 1. Yes \n 2. No \n Select an option: “) } else{ r <- […]

Categories
Mastering Development

Pygame: How to move on to seperate level?

So, i’m making a platformer game in Pygame. I’m currently a bit stuck with moving onto the next level. I already have an object ready (and collision), so when the player hits that object the intended effect is to move on to the next level. I use lists for all my objects, like enemies, platforms, […]