What you are describing is called a wash sale. You can sell a stock and immediately buy it back (or within 30 days) but any losses cannot be recognized. Instead the loss is added to the basis of the stock when you buy it back which will reduce your taxable gain in the future when you sell it.
I believe the three day thing you are talking about pertains to how many brokerage accounts require three days from the sale of a security for the money to clear. Until then you cannot use the money gained from a sale to purchase new securities.
You can buy stock X, then sell stock X the same day (say Monday). You can then (on the same day) buy stock Z. You run into a problem when you try and sell Stock Z. The reason being is that you bought stock Z with the unsettled funds from the sale of stock X. You can sell stock Z about 3 days later (thursday).
-The same applies if you wanted to buy back into stock X, you just can't sell it again for three days or after the transaction from original sale settles.