How to keep track of the index in an array - c++

I need to create a stats sheet that records the amount of touchdowns performed by a certain team. I have it working for the first round when it records all 8 teams, however in the semifinals since only 4 teams make it, it does not keep track of what index the winning teams were on and just couts the stats in a regular order from 0 - 4. Ive been thinking for a couple days now on how I could possibly overcome this but I havent been able to find a solution yet.
the stats table that is outputted
Please let me know if i can contribute anymore information to make my question less vague and easier for you to understand. I appreciate all the help, thank you.

Related

Django query to find value of objects from previous period (if exists)

I have a simple django project and I am trying to keep track of ranks for certain objects to see how they change over time. For example, what was the rank of US GDP (compared to other countries) over last 3 years. Below is the postgres db structure I am working with:
Below is what I am trying to achieve:
What I am finding challenging is that the previous period value may or may not exist and it's possible that even the entity may or may not be in the pervious period. Period can be year, quarter or months but for a specific record it can be either of one and stays consistently same for all the years for that record.
Can someone guide me in the right direction to write a query to achieve those tables? I am trying to avoid writing heavy forloop queries because there may be 100s of entities and many years of data.
So far I have only been able to achieve the below output:
I am just trying to figure out how to use annotate to fetch previous period values and ranks but I am pretty much stuck.

QT Data storage and updating across multiple computers

Im struggling to understand how to make an inventory application:
Store inventory data (item name, sku, descriptions, prices, inventory counts)
Allow computers access from different networks
Keep computers updated. By that I dont understand how they communicate to each other across different networks/connections, so that if one computer makes a change to say inventory count how does it let the other computers know to subtract say 5 of an item bc 5 were sold.
question 1 I can understand how storage works to a degree, but when it comes to 2 and 3 how would you approach it? I figured servers would be the answer but then the question becomes what kind? AWS RDS? If you have links to tutorials that can explain this process and different approaches please feel free to link
Ive been trying to figure this out for a few months now and I think im getting more confused than answers (I swear I get more inventory application ADs crap than actual information, like no joke try searching "how inventory applications store and update data and keep computers updated" or any phrase like that... and its a bazillion freaking ads lol)

Comparing data of payments

At my work we have two systems, one that collects the customers payments automatically every month. And one that manages the memberships of those customers. Sadly our outdated technology doesn’t communicate to each other so we don’t know if a customer actually paid for their membership without manually auditing them.
I’ve been put in charge of this process and boy does it take awhile to do.
I have limited knowledge of C++ and was looking into maybe writing a program to do the comparisons for me.
I have two ideas on how to implement this, and was wondering what you guys thought. If these would be best or if it’s even possible or if there’s a better solution?
Current Setup: We have a list of all members in excel, with how much each should be paying, we then go through the actual money collected and check to make sure everyone’s payment went through and was processed and not declined.
Option 1: have a multi-dimensional array of strings. Read the excel file into this array it would have three Columns, first name, last name, amount they should be paying. This would be put in alphabetical order to help with the searching. I would then export the transactions in css file format and read each line one at a time. When it reads a line it would search the array for the same first and last name. Once found it would take the amount paid confirm it said processed and not declined and if so would subtract it from the customers amount they should be paying. In the end if every customers amount they should be paying is equal to 0 then everyone paid.
Option 2: is similar to option 1 just instead of using a multidimensional array it would use two css files. And not put the items into the array at the start.
Thoughts? Is this a smart way to combat this problem? I’m a newbie programmer so I’m just looking for suggestions/advice.
Your solutions would work, but are suited for small datasets. I don't now what your constraints are, but I think that a more elegant solution would be to setup a database on the first system first(instead of the excel file).
Are you allowed to create a database? How many customers are in the excel file?

Optimizing / speeding up calculation time in Google Sheets

I have asked a few questions related to this personal project of mine already on this platform, and this should be the last one since I am so close to finishing. Below is the link to a mock example spreadsheet I've created, which mimics what my actual project does but it contains less sensitive information and is also smaller in size.
Mock Spreadsheet
Basic rundown of the spreadsheet:
Pulls data from a master schedule which is controlled/edited by another party into the Master Schedule tab.
In the columns adjacent to the imported data, an array formula expands the master schedule by classroom in case some of the time slots designate multiple rooms. Additional formulas adjust the date, start time, and end time to be capped within the current day's 24-hour period. The start time of each class is also made to be an hour earlier.
In the Room Schedule tab, an hourly calendar is created based on the room number in the first column, and only corresponds to the current day.
I have tested the spreadsheet extensively with multiple scenarios, and I'm happy with how everything works except for the calculation time. I figured the two volatile functions I use would take some processing time just by themselves, and I certainly didn't expect this to be lightning-fast especially without using a script, but the project that I am actually implementing this method for is much larger and takes a very long time to update. The purpose of this spreadsheet is to allow users to find an open room and "reserve" it by clicking the checkbox next to it (which will consequently color the entire row red) allowing everyone else to know that it is now taken.
I'd like to know if there is any way to optimize / speed up my spreadsheet, or to not update it every time a checkbox is clicked and instead update it "manually", similar to what OP is asking here. I am not familiar with Apps Script nor am I well-versed in writing code overall, but I am willing to learn - I just need a push in the right direction since I am going into this blind. I know the number of formulas in the Room Schedule tab is probably working against me yet I am so close to what I wanted the final product to be, so any help or insight is greatly appreciated!
Feel free to ask any questions if I didn't explain this well enough.
to speed up things you should avoid usage of the same formulae per each row and make use of arrayformulas. for example:
=IF(AND(TEXT(K3,"m/d")<>$A$1,(M3-L3)<0),K3+1,K3+0)
=ARRAYFORMULA(IF(K3:K<>"",
IF((TEXT(K3:K, "m/d")<>$A$1)*((M3:M-L3:L)<0), K3:K+1, K3:K+0), ))
=IF(AND(TEXT(K3,"m/d")=$A$1,(M3-L3)<0),TIMEVALUE("11:59:59 PM"),M3+0)
=ARRAYFORMULA(IF(K3:K<>"",
IF((TEXT(K3,"m/d")=$A$1)*((M3-L3)<0), TIMEVALUE("11:59:59 PM"), M3:M+0), ))

Algorithm to schedule courses

I currently have a problem that for my senior year, I need to choose 5 elective courses out of 20+ possible courses. All these courses are distributed to weekdays. I need to develop a robust algorithm to show me all possible combinations without overlapping any of the course hours. I am a little bit short of time, so I figured I'd ask here, and it would be of help to other people in the future.
My original idea was to try all combinations of 5 out of 20+, and remove the schedules that had overlapping courses. The brute force solution seems easy to implement. Just out of curiosity, would there be another more intelligent solution to this problem? e.g. What if I had 1000+ courses to choose from?
A little bit faster could be to select the first course (out of 1000) and remove all the courses that overlap. Then select the 2nd course out of the remaining courses and remove the overlapping courses again. If you do that 5 times, you will have 5 courses that don't overlap.
The last iteration isn't really necessary because once you have 4 courses, then every course that's left will not overlap.
By backtracking you will get all the possible course combinations. An efficient way of backtracking here could be by using dancing links as proposed by Knuth.