# I've a logical problem, and I want to solve it with optimised way

Advertisements This will be accepted value which should be as an array : Input: const x = [ "name_new", "name_test_new", "xyz_new", "xyz_abc_rest_edit", ] This is the putout of input, I’m expecting, Output: const y = { "name":{ "new":true, }, "name_test":{ "new":true, }, "xyz":{ "new":true, }, "xyz_abc_rest":{ "edit":true, }, } Here Input could be anything similar… Read More I've a logical problem, and I want to solve it with optimised way

# How to efficiently do binary search on reverse sorted list in Python?

Advertisements I want to do binary search on reverse sorted lists in Python. The list is appended in reverse order, and it has to be like this or else my code will break. I need the code to be as fast as possible, assume the list is huge. I know Python code is slow so… Read More How to efficiently do binary search on reverse sorted list in Python?

# how to optimize a scraper

Advertisements im trying to figure out how to optimize some code, the purpose is to go through a word list (10k words), make a search query for each word, and then get the last result, printing it if the result is before a certain date. the code: import requests import json import os ln =… Read More how to optimize a scraper

# How can I speed up this for loop? C++

Advertisements The code: int num=999999; //or generally a very big number (like 10^6, etc.) int sum=0; for(int i=num; i>=1; i–) sum+=i; So basically I want to find the sum of the num + num-1 + num-2 +…+ 1, is there any way to make for loop faster or to get rid of it entirely? >Solution… Read More How can I speed up this for loop? C++

# how to predetermine variables without loop?

Advertisements Is it possible to predetermine variables x and d to call initialFunction() without while(1) loop? void function( int xc, int yc, int r, int color ){ int x = 0; int y = r; int d = 1-2*r; while( 1 ){ x++; d += 4*x-2; if( d>0 ){ initialFunction(x,y,d); break; } } while( x>=y… Read More how to predetermine variables without loop?

# Need help optimizing VBA code in Sub WorkSheet_Change

Advertisements I have the following code that does 3 things: in cell F3 it uppers all text and adds the word "cassa" if not already entered; in cell F25 it enters the date and time of the last editing; in range H5:H12 and D18:K19, if the user deletes the content of the cell, a zero… Read More Need help optimizing VBA code in Sub WorkSheet_Change

# Is this a reasonable method of performing a binary search on an array of strings?

Advertisements Given: All strings used only contain ASCII characters. A base-128 integer type has been defined. 128 comes from the number of possible characters we will be expecting. Although most basic operations are not supported, there is implementation to compare one of these base-128 integers to another (<, >, =). Our data is stored in… Read More Is this a reasonable method of performing a binary search on an array of strings?

# Is there a faster way to multiply by 6 in C?

Advertisements I am currently writing a program in C which needs to run as fast as possible and am currently looking at improving the speed of some of the calculations performed. I am aware that the slowest operations are multiplication and division, and I have replaced my multiplications/divisions by a power of 2 with left/right… Read More Is there a faster way to multiply by 6 in C?

# How to fill python dictionary while creating it

Advertisements I’m searching for a way of filling a python dictionary at the same time it is created I have this simple method that firstly creates a dictionary with all the keys at value 0 and then it reads the string again to fill it def letter_count(word): letter_dic = {} for w in word: letter_dic[w]… Read More How to fill python dictionary while creating it

# Rewriting a function

Advertisements In the following code I would like to replace the definition of the function f f=@(x)-x(1)*x(2)*x(3); x0=[1 1 1]; lb=[0 0 0]; nonlincon=@constr; x=fmincon(f,x0,[],[],[],[],lb,[],nonlincon) function [c,ceq] = constr(x) c = [2*x(1)*x(2)+2*x(1)*x(3)+2*x(2)*x(3)-100 ; 1-x(1)*x(2)]; ceq = []; end I replaced it with function erg = f(x) erg = -x(1)*x(2)*x(3); end but unfortunatly it doesn’t work.… Read More Rewriting a function