Let's say I have a group of X's characters that I want to cut down. I want to use a method similar to 'find-and-replace-all' tool from Word, which takes an amount of X's each time, deletes them, and replaces them with another, smaller amount. For example, I can state that I want an amount of 8 X's to be replaced with 5 X's from an original amount of 14 X's. This cycle happens forever, or until there isn't a sufficient remainder left to replace anymore. To visualise the example I just provided:
(XXXXXXXX)XXXXXX --> [XXXXX]XXXXXX
(XXXXXXXX)XXX --> [XXXXX]XXX
(XXXXXXXX) --> [XXXXX]
So, you start with 14 X's and end with 5 X's, and the process carried out here can be summarised as '14, 11, 8, 5'. The process that was undergoing in terms of finding and replacing can be described as (8,5) as 8 X's are replaced with 5 each time.
If you guys need a more mathematical way of me putting it, divide the amount of X's by a in (a,b), subtract the remainder in integer form, multiply the total by b, then finally add the remainder to the total. Continue this until Amount of X's/a < 1.
Now, I was wondering if there is a way to do this in Wolfram Alpha/Mathematica. Can anyone help me do this. If not, can anyone redirect me to an appropriate scripting language that can handle this? Thank you.
ReplaceAll
andStringExpression
. $\endgroup$