Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pcombos(str)
- # `S` is indexed by characters, where each element
- # is a list of indices the character appears within `str`
- S = Dict{Char,Array{Int64,1}}()
- #combos = fill([1 1 1 1], (0))
- total = 0
- for (i, ch) in enumerate(str)
- push!(get!(S, ch, fill(0, (0))), i)
- end
- for a in 1:length(str)-3
- for d in reverse(S[str[a]])
- d <= a && break
- for b in a+1:d-1
- for c in reverse(S[str[b]])
- c >= d && continue
- c <= b && break
- #println([a b c d])
- #push!(combos, [a b c d])
- total += 1
- end
- end
- end
- end
- #return length(combos)
- return total
- end #function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement