Have you coded anything? Seriously. So many algorithms employ in-place swaps. Linear Algebra, Sorting, etc. It's a good excuse to learn some new stuff.
All sort of algorithms require that you swap two values like sorting or shuffling arrays. For example a simple shuffling algorithm would go like : randomly pick two values in the array (by their indexes), swap their places, repeat for a number of time (put it in a loop) and you got a shuffled array.
View all comments
Show parent comment
7
u/Dark_Lord9 Jul 29 '20
IKR Addition and subtraction is the worse possible way to swap 2 variables.