How to solve this question of picking balls from bins, question is probability of ball number vs selection number? I'm a student and always get confused with different combinations of balls in bins problem. I've encountered this question today and not able to solve this. Hope someone can give me some pointers, thanks! If there are any related materials I need to refresh, that would be helpful as well.
You have been given 3 balls which are numbered as 1, 2 and 3 and they are placed inside a bag. You randomly select 3 balls, one ball at a time. Considering your selection, you win if at least one selection number matches with the number on the ball. So for example if you get ball with number 1 on your first draw you call this as win. The question is what are the chances of winning if you do this with replacement versus without replacement.

I like to simulate such problems as a double check on the
combinatorial logic. [@MathLover's Answer (+1), which you might consider Accepting, and @JMoravitz' Comment have
put you on the right track.]
# without replacement
set.seed(2020)
win.wo = replicate(10^6, sum(sample(1:3, 3)==1:3))
mean(win.wo > 0)
[1] 0.666828       # aprx 1 - (2/3)(1/2) = 2/3

# with replacement
win.wr = replicate(10^6, sum(sample(1:3, 3, rep=T)==1:3))
mean(win.wr > 0)
[1] 0.702987       # aprx 1 = (2/3)^2 = 19/27
1 - dbinom(0, 3, 1/3)
[1] 0.7037037      # Exact binomial computation

Notes: win.w0 and win.wr are vectors of length 1,000,000 with numbers of wins; we want one or more. Logical vector
(win.wr > 0) has a million TRUEs and FALSEs; its mean
is the proportion of its TRUEs. Similarly, for win.wr.
With a million iterations of the game we can expect 2 or 3
place accuracy for the probabilities.
'sample' does the sampling.  Examples:
sample(1:3, 3)
[1] 2 3 1
sample(1:3, 3)
[1] 1 2 3
s = sample(1:3, 3)
[1] 2 1 3
s == 1:3
[1] FALSE FALSE  TRUE
sum(s == 1:3)
[1] 1

sample(1:3, 3, rep=T)
[1] 1 2 2
sample(1:3, 3, rep=T)
[1] 3 3 3
sample(1:3, 3, rep=T)
[1] 2 3 2
sample(1:3, 3, rep=T)
[1] 1 3 2

