Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Alchemical Reduction drill
- function reduce(x::Char, y::Char)
- if (x != y) && ((x == lowercase(y)) || (y == lowercase(x)))
- return ""
- else
- return string(x,y)
- end
- end
- function reduce(z::AbstractString, n::Int64)
- for i = 2:n
- x = z[i-1]
- y = z[i]
- new = reduce(x, y)
- if length(new) == 0
- return string(z[1:(i-2)], z[(i+1):end]), 1
- end
- end
- return z, -1
- end
- function main(z::AbstractString)
- while true
- n = length(z)
- z, flag = reduce(z, n)
- if flag == -1; return z; end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement