Code Kata 2

I now have implemented two different implementations of Code Kata 2 Kata02: Karate Chop - CodeKata. Learning Swift as I go along. Didn’t realise/remember language has Pythonic array slicing!

My implementations are swiftkatas/chopper.swift at master · timokoola/swiftkatas, still think I could do a much better job if I knew language in idiomatic level. Also: realised binary search is one of those things one thinks they know how to implement but when rubber hits the road it is not at all that easy. In addition I feel that recursive solutions are somehow much more easy to implement for me.

Will try to think three more implementations before moving on to the next one. Can I do this in one big chain of functions? I could also randomly pick the split point but what could be the fifth way?

Mastodon