In this post, we have Swift 5.0 solution for - Given the number of players P and the number of reserved courts C, returns the maximum number of games that can be played in parallel. For Example, Given P = 5 players and C = 3 available courts, the function should return 2. Working solution : public func solution ( _ P: Int , _ C: Int ) -> Int { // 1 if P < 2 || C < 1 { return 0 } // 2 return P >= (C * 2 ) ? C : (P / 2 ) % C } solution ( 5 , 3 ) // returns 2 When insufficient Players or Courts, games can not be played. If total players exceeds courts capacity, all courts occupied & games will be played. Otherwise return total number of games played from Players strength. Full detail of exercise challenge : https://app.codility.com/programmers/trainings/3/tennis_tournament/ Happy coding !
Long waiting is over. !! iOS 12 brings Autofill for OTP text field which is close to Android provided a decade back. Previously in iOS we used to toggle between OTP text screen and message inbox. Which was hard to remember and time consuming resulting a bad user experience. Personally, I have been asked from the client/customer couple of times to implement autocompletion for OTP field and took me a lot of time to convey that it is not possible in iOS. Why Autofill was not possible previously? We all know that Apple gives at most care for user privacy. When we see iOS architecture, each individual app is like a separate island. There is no inter-app bridge between apps (exception for Keychain and URLSchemes APIs which gives very limited scope). Thus we cannot read message content from inbox. Where to start Autofilling? First of all, the target SMS need to have the OTP Code with prefix string "Code" or "Passcode"on its message content. Beware of OTP c...