Fork me on GitHub
#ldnclj
<
2016-01-11
>
agile_geek08:01:18

Morning from train in Yorkshire. Sad news about David Bowie this morning 😢

thomas09:01:29

yes.... another one bites the dust...

thomas09:01:36

oops.. wrong band

jamiei10:01:48

Morning all

mccraigmccraig10:01:35

måning yål

practicalli-johnny11:01:50

Hello, any suggestions on how to generate all the permutations of a given string. Eg. given "abcdedcba" I would like to return ["a" "ab" "abc" "abcde" "abcded" "abcdedc" "abcdedcba" "b" "bc" "bcd".... etc etc...

practicalli-johnny16:01:05

Thanks @mccraigmccraig the combinatorics does what its supposed to do, however I now have too many cobinations. I only want combos that exist within the original string. So i guess I can filter the output and drop any combos that are not sub strings of the original string.

rufoa23:01:42

@jr0cket if you just want all substrings then (let [s "abcdedcba"] (for [i (range (count s)) j (range (count s)) :when (< i j)] (subs s i j)))

rufoa23:01:10

actually make the j (inc (count s)). i was off by one