Excel Formulation/table - excel

Scientists at the research institute for robotics have created a new type of robot that reproduces itself. The new robot takes two weeks to gather materials and then builds one new robot(exactly like itself) each week for three weeks. The first new robot is activated at the end of week 3, the second new robot is activated at the end of week 4 and the third new robot at the end of week 5. as soon as it is created, each new robot goes through the same cycle of gathering materials for two weeks and then creating three new robots, one per week. And so on for each of the new robots. At the end of the first five weeks of its existence each new robot ceases building new robots but retires and lives forever. The scientists plan to build only one robot with their own hands and then set it in motion. Create an excel worksheet that will tell you how many robots there will be in 2 years.
i have search but the answer wasn't enough to help me figure this out. any help out there?

#yosukesabai is quite right - this is a Markov chain problem, and once you've worked out how to set up the transition matrix it's very easy to solve. If we know how many robots of each age we have at the end of each week (in complete weeks, capped at 5), we can use the transition matrix to calculate the number of robots of each age at the end of the following week.
The transition matrix can be written like this:
0 1 0 0 0 0
0 0 1 0 0 0
1 0 0 1 0 0
1 0 0 0 1 0
1 0 0 0 0 1
0 0 0 0 0 1
For each robot of age y at the end of the week, there will be T(x,y) robots of age x at the end of the next week (x = column number, y = row number, both starting at 0). The entries are all filled in according to the puzzle description.
The starting state in week 0 is a single robot of age 0, and no other robots of any other ages. This can be represented as a row vector:
1 0 0 0 0 0
You can now use the MMULT function to get from week zero to week one. If you put the transition matrix in cells J2:O7 and the vector for week 0 in cells B3:G3, it can be entered as:
=MMULT(B3:G3,$J$2:$O$7)
This needs to be entered as an array formula. Select cells B4:G4, press F2, enter the formula and press Ctrl + Shift + Enter. You should now see the following in B4:G4:
0 1 0 0 0 0
You can then copy & paste these cells down into another 103 rows to see how robots you have after 2 years. I get 5,369,858,819,104 at the end of week 104.

Related

How do I count the number of cells in a column against criteria in another column

I need help creating a formula to count number of unique delivery stops each day. The table below is similar to my actual data.
Name
Address
Sun
Mon
Tues
Wed
Bob
1 Main St
1
0
1
2
George
3 Main St
3
0
1
2
Tom
4 Main St
4
0
1
2
Harry
1 Main St
0
0
1
2
Randy
1 Main St
0
0
4
2
Homer
5 Main St
2
0
1
2
Bill
10 Main St
3
0
1
2
Jim
1 Main St
1
0
1
2
Joe
2 Main St
1
0
1
2
For instance, "1 Main St" is marked 4 times on the chart, but on Sunday there were 2 deliveries but only 1 actual stop at that location.
How would I go about calculating that based with a formula? I originally tried a ```=SUMPRODUCT```` but it wasn't calculating correctly, it would count each delivery stop, I'm not sure how to make it not count 0's and to combine multiple deliveries to the same address as a single delivery.
My last formula was "=SUMPRODUCT((COUNTIF($D$6:$D$96,$D$6:$D$96)=1)*$J$8:$J$98)
Where Column D is the addresses and J starts the delivery counts on Sunday.
Thanks
EDIT
Sorry, I wasn't clear with my question: I need a way to count the number of stops made per day (so if an address has multiple deliveries to different people, it's just counted as a single stop and 0's are skipped). Using Excel 2013
After many, many attempts, here it is...
Answer:
=SUM(IF(LEN(UNIQUE(FILTER(B2:B10;C2:C10>0;0);FALSE;FALSE))>1;1;0))
Where B2 is the first address, C2 is the first row under sunday.
This will give you unique delivery locations. So, if you visit the same place multiple times in one day, it is still counted as 1. If 0, it is counted as 0.
Your question was VERY unclear. Next time around, please tell us what you want the result to be.
This answer will give 6 for Sunday. If there are no deliveries, it will be zero. This last point took me hours to solve. COUNTIF won't work on single cells, only arrays. COUNT only works on numbers, COUNTA... Well, apparently COUNTA counts empty arrays (like if FILTER returns nothing). So I had to get the length (>1 for some reason). If it was greater than 1 in length, add 1, otherwise 0. And finally SUM it all.
Like I said, this is to calculate deliveries on Sunday, so this formula will be repeated for the other days.
Hope you like it! ^_^

Counting digit in column based on subject

I am just using formulas in excel and was wondering how you could count all the 0s until a 1 is reached, and then start the process over again, based on subject number. If this is not possible simply with formulas, how could I write a VBA code for this?
Right now I am trying to use,
=IF(OR(F4=0,F3=1),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
which I input in I3 and I change the COUNTIFS($A$#:A#, $A$#...) part for each subject number.
This seems to work with the exception of the last grouping, as it won't output a number before the next subject.
Example Data:
subid yes number_yes(output)
1 0
1 0
1 0 3
1 1
1 0 1
1 1
1 0
2 0
2 0 2
2 1
2 0
2 0
3
etc.
A blank cell is numerically zero and that is one of your accepted conditions. Differentiate between blanks and zero values.
=IF(and(f4<>"", OR(F4=0,F3=1)),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
Based on #Jeeped answer. If you use -SUMIF($A$2:A2,A3,$I$2:I2) instead of -SUM($I$2:I2) you don't need to adjust this part for each subject number. Just use the following formula in I3 and copy it down.
=IF(AND(F4<>"",OR(F4=0,F3=1)),"",COUNTIFS($A$2:A3,A3,$F$2:F3,0)-SUMIF($A$2:A2,A3,$I$2:I2))
Note that I also changed the second parameter in the COUNTIFS to A3.

Calculate percentage using functions

I have an Excel workbook (Office 2010) that lists multiple different spreadsheets (offices) in our organization. We use this workbook to keep track of their "errors" in turned-in documents (example only). I'm trying to figure out a good way to determine, through automation (functions) the percentage of documents that have had errors in them. I want to determine the percentage of documents looked at versus the amount of errors, completely ignoring the amount of errors. So if I looked at 10 documents and 7 of those had at least one error, the office's percentage of errors would be 70%.
Is there any easy way to do this?
I've tried a few functions but I continue to get errors. I show a sample sheet (one office) below. This example is similar across multiple sheets and there is a dashboard that I would like to display all of these statistics based on offices.
workpaper DISCREPENCIES
Paper Spelling Grammar Punctuation Total Errors/Paper
A.36.7 1 0 1 2
A.36.8 0 1 1 2
A.36.9 0 1 0 1
A.36.10 0 0 0 0
A.36.11 1 0 0 1
A.36.12 1 1 1 3
A.36.13 2 3 0 5
A.36.14 0 0 0 0
A.36.15 0 0 0 0
A.36.16 1 1 1 3
Total Errors 17
Total Documents 10
Total Documents w/ errors 7
Percentage of Errors 70%
I can do all of this manually but I would like to find a way to do this across all sheets since there are a quite a few and output them to a "dashboard" that has all offices listed in rows.
One way is to look at the number of worksheets with 0 errors in them. Then subtract that percentage from 100%. For example in G5:
=COUNTIF(E3:E12,0)/COUNT(E3:E12)
and in G6:
=100%-G5

EXCEL Count number of weeks in month based on date

I am trying to look up a value in a matrix based on a given date. The matrix has the first day of the week along the vertical axis, and the first day of the month along the horizontal axis.
For a given day, e.g. 31/08/15 I would like to match the exact date to the vertical axis of the matrix (i.e. 31/08/15), and the month to the horizontal axis (1/08/15).
So in the example below, an input of 31/08/15 should provide an output of 3.
01/06/2015 01/07/2015 01/08/2015 01/09/2015
03/08/2015 1 0 0 0
10/08/2015 0 2 0 0
17/08/2015 0 0 3 0
24/08/2015 0 0 0 4
31/08/2015 0 0 3 0
I am trying and failing with index and match formulae.
I have tried the following:
=index(area where to look, match(31/08/15,first column,0),match(and(month(31/08/15),year(31/08/15)),(and(month(first row),year(first row)),0)
Hope this is clear, thanks!
You can use an INDEX function with two MATCH functions top supply both the row and column.
    
The formula in D8 is,
=INDEX($B$2:$E$6,MATCH(C8,$A$2:$A$6,0),MATCH(DATE(YEAR(C8),MONTH(C8),1),$B$1:$E$1,0))
I'm a little concerned about the dates matching exactly down column A but a little maths manipulation with the WEEKDAY function would take care of that.
=INDEX($B$2:$E$6,MATCH(C9-WEEKDAY(C9, 2)+1,$A$2:$A$6,0),MATCH(DATE(YEAR(C9),MONTH(C9),1),$B$1:$E$1,0))
Here you go:
=INDEX($B$2:$E$6,MATCH(DATE(2015,8,31),$A$2:$A$6,),MATCH(DATE(2015,8,1),$B$1:$E$1,))

Optimal to lookup and display column/row names from a table of binary data

Job Coach ConsumerName Monthly General Goals
Anna Joe 0 0 0
Sam John 0 0 0
Veron Jane 0 0 0
Bill Jack 1 1 1
Anna Jill 1 1 1
Jim 0 0 0
Bill Jiang 1 1 1
Jolly 0 1 1
Sam Jiant 0 0 0
Jap 0 1 1
Joule 1 1 1
Aardvark 0 1 0
Drake Darding 0 0 0
Hello, as you can see above I have two columns of strings; one column is "job coach" the other is "consumer name". There are three columns of 1's and 0's; monthly, general, and goals.
I'm trying to find the specific pattern of 1's and 0's in each of the rows, and to report it. For instance, the data says:
Consumer Jolly still has a a monthly which needs to be completed;
Consumer Aardvark still has a monthly which needs to be completed;
Consumer Aardvark still has a monthly and a goals which needs to be completed.
Lookup doesn't really work, because it only will return the first instance of the corresponding variable and not additionally instances.
I've tried a index function like this:
{=INDEX($C$2:$E$14,SMALL(IF($C$2:$C$14=0,ROW($C$2:$C$14)),ROW(1:1)),3)}
But that only would look up for a single column at a time, which makes the report rather cumbersome. I'm open to doing a loop in excel without formulas, however its not a simple looping formula, because I'm trying to look at each cell and to output the specific column name.
Any thoughts on how to best do it?
It's not exactly clear what the condition you want to check is, but if you want to check for a specific given pattern and return the customer name you can use this adjusted formula:
=INDEX($B$2:$B$14,SMALL(IF($C$2:$C$14&$D$2:$D$14&$E$2:$E$14="010",ROW($C$2:$C$14)-1),ROW(1:1)),1)
In your formula you checked only the first binary column and returned the last. You also had a mistake of returning the row number and not the index in the list which is row-1 in your case.
So notice:
The INDEX returns values from column B.
The IF checks a pattern of C&D&E equals a pattern like 010 which can be changed or set to a reference.
Then return the ROW()-1 in case your list starts at row 2, to return the index in the data and not the actual row.

Resources