ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how to write the formula using INDEX? (https://www.excelbanter.com/excel-discussion-misc-queries/48143-how-write-formula-using-index.html)

gipsassignment

how to write the formula using INDEX?
 
hi, i gotta a problem when doing an assignment of writing the formula:

Given that Paper breaks Rock, Rock breaks Scissors, Scissors breaks Paper

I need to let the computer randomly generates Paper/Rock/Scissors(well this
formula i can do), then i input one of the three and then the computer will
automatically come out the result. Thanks!


Bryan Hessey


Hi,

To generate a random selection, put =rand() in A1 A2 and A3
put "scissors" in B1, "paper" in B2 and "rock" in B3,
then put
=VLOOKUP(SMALL(A1:A3,1),A1:B3,2,FALSE)
in C1
This will generate a new guess each calculation, including your entry
(providing that auto-calculate in on)

setup a table for lookup (say, A10 to B19) with (ignore the dots, they
are for spacing purposes only)

scissorsscissors ..... equal
scissorspaper ........ scissors cuts paper, computer wins
scissorsrock ........... rock blunts scissors
paperscissors ........ scissors cuts paper
paperpaper ............ equal
paperrock .............. paper wraps rock, computer wins
rockscissors ........... rock blunts scissors, computer wins
rockpaper .............. paper wraps rock
rockrock ................. equal

and, in cell E1 put =VLOOKUP(C1&D1,A10:B19,2,FALSE)

enter your guess in D1

This should provide you the answer.



gipsassignment Wrote:
hi, i gotta a problem when doing an assignment of writing the formula:

Given that Paper breaks Rock, Rock breaks Scissors, Scissors breaks
Paper

I need to let the computer randomly generates Paper/Rock/Scissors(well
this
formula i can do), then i input one of the three and then the computer
will
automatically come out the result. Thanks!



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=472397


Bryan Hessey


Of course, I could read the question correctly, and use INDEX (it's an
assignment, nothing to do with normalness)

set your table as

B10=scissors C10=paper D10=rock
A11=scissors B11=equal C11=scissors cuts paper, computer wins D11=rock
blunts scissors
A12=paper B12=scissors cuts paper C12=equal D12=paper wraps rock,
computer wins
A13=rock B13=rock blunts scissors, computer wins C13=paper wraps rock
D13=equal

and your formula

=INDEX(B11:D13,MATCH(C1,A10:A12,0),MATCH(D1,B10:D1 0,0))

(note the final match is MATCH(D1,B10:D10,0)) but keeps reflecting
incorrectly)

where C1 is the computers guess, and D1 is yours.


Bryan Hessey Wrote:
Hi,

To generate a random selection, put =rand() in A1 A2 and A3
put "scissors" in B1, "paper" in B2 and "rock" in B3,
then put
=VLOOKUP(SMALL(A1:A3,1),A1:B3,2,FALSE)
in C1
This will generate a new guess each calculation, including your entry
(providing that auto-calculate in on)

setup a table for lookup (say, A10 to B19) with (ignore the dots, they
are for spacing purposes only)

scissorsscissors ..... equal
scissorspaper ........ scissors cuts paper, computer wins
scissorsrock ........... rock blunts scissors
paperscissors ........ scissors cuts paper
paperpaper ............ equal
paperrock .............. paper wraps rock, computer wins
rockscissors ........... rock blunts scissors, computer wins
rockpaper .............. paper wraps rock
rockrock ................. equal

and, in cell E1 put =VLOOKUP(C1&D1,A10:B19,2,FALSE)

enter your guess in D1

This should provide you the answer.



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=472397



All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com