## [Solved] Algorithm needed for product aging in a storage [closed]

This problem is indeed not vba specific. For each box, add a label when it was added to the storage. You may take the point in time as a timestamp, iteration number or whatever unit suits you. Then you can now evaluate the time the box spent in storage by calculating now-time_when_box_was_added, for every single … Read more

## [Solved] Big O, how do you calculate/approximate it?

I’ll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the Data Structures and Algorithms in Java book. There is no mechanical procedure that can be used to … Read more

## [Solved] SQL Database Algorithm

Even though this question is Way too broad, and actually not asking anything, i’ll give it a few minutes of attention. 1) You backup the current state and work on a Sandbox! 2) if your only need is few reports, i guess you can generate them query the different databases independently and maybe post processing … Read more

## [Solved] How to Balance Quadcopter using L3G4200 and PID controll [closed]

I don’t have the exact sensor as you, but this code is a snippet that I’ve been working on. You can look at it… Maybe it could help. If it did, then good ðŸ™‚ /* Project goal: Arduino built quadcopter. Motor diagram: Legend: num : motor number -> : clockwise <- : counter-clockwise 2 -> … Read more

## [Solved] How to solve this mathematical equation in php [closed]

Just group the D’s first and dont hardcode the indices, use \$i \$S = array(); \$D = array(); \$M = array(“1″=>30,”2″=>31,”3″=>30); \$Y = array(“1″=>360,”2″=>360,”3″=>360); \$O = 30000; \$P = 0.3; \$N = 10509.74; for(\$i = 1, \$size = count(\$M); \$i <= \$size; \$i++){ \$final_D = 0; // group the D’s first (O-D1), (O-D1-D2), … and … Read more

## [Solved] how can i solve this problem of coins from n shop in python? [closed]

We can just pick the coin which shop has the largest. So the key point is the order of pick. I think you can use dfs to search all pick orders, and find the best one: def pick_coins(demand, shops): # invalid input if sum(demand) > len(shops): return -1 res = 0 def dfs(demand, idx_remains, num): … Read more

## [Solved] A program which is difficult

Essentially, your question is this: given a graph with nodes represented as indices and edges as index pairs, and given an index i that represents a node, find all nodes which are connected to the given node. UnionFind algorithm to find connected components over nodes with indices: Initialize an array father of size number of … Read more

## [Solved] finding number of numbers which have prime number of factors

You could try computing this mathematically (I’m not sure this will be faster/easier). Basically, given the prime factorization of a number, you should be able to calculate the number of divisors without too much trouble. If you have an input x decompose into something like x = p1^a1 * p2^a2 * … pn^an Then the … Read more

## [Solved] An algorithm to find the exact amount to add to a top-up a card

The problem you describe is actually a very difficult problem in general, since it is related to the knapsack problem. But it is only hard if you allow very large amounts of money on the card and very many different prices. For your real world problem with very few different prices you can solve this … Read more

## [Solved] Can an algorithm for this be done in one line? [closed]

Something like this should work: paid = Math.Min(total, payment+paid) 3 solved Can an algorithm for this be done in one line? [closed]

## [Solved] Check if number is divisible by a power of two [duplicate]

In the Long class, there is a handy static function numberOfTrailingZeros, which does almost what you want, except that it returns zero (instead of -1) when the input is not divisible by 2. You could handle that case in different ways. For example, extending the answer of @0x476f72616e if ((num & 0x1) == 0) return … Read more

## [Solved] FloydWarshall infinite [closed]

if (variable >= 1000) { printf(“INF”); } I chose a random variable name, but this logic should do what you want. 1 solved FloydWarshall infinite [closed]

## [Solved] unable out figure out error in below program [closed]

This is a case of undefined behavior: if(!visited[j]) is undefined. visited is not initialized because the call memset(visited, sizeof(visited), false); is wrong. You are reading uninitialized variables. The declaration of memset is void *memset( void *dest, int ch, size_t count ); You are writting 0 times the value 10000 into visited. On your machine this … Read more

## [Solved] Interval range insert with split into unique ranges

in the actual code there is a differentiation between old interval ranges and new ranges after applying certain operation those ranges would be merged together. I wanted to split the question into smaller chunk so the merging part is left out. Solely: It is easier to merge in the new interval directly, instead of artificially … Read more

## [Solved] Prove that (log n)! = O(n^k)

n^k = (e^k)^log n and the factorial grows faster than an exponential (product of growing factors vs. product of constant factors). 1 solved Prove that (log n)! = O(n^k)