Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
| #include <iostream> | |
| using namespace std; | |
| int partition(int *, int, int); | |
| void printArray(int *, int); | |
| void quickSort(int *arr, int start, int end) { | |
| if(start < end) { | |
| int q = partition(arr, start, end); | |
| quickSort(arr, start, q); |
| #include <iostream> | |
| using namespace std; | |
| void print(int *arr, int n) { | |
| for(register int i=0; i<n; i++) { | |
| cout<<arr[i]<<" "; | |
| } | |
| } | |
| void bucketSort(int *arr, int n) { |
| #include <iostream> | |
| #include <vector> | |
| #include <cmath> | |
| using namespace std; | |
| void print(int *arr, int n) { | |
| for(register int i=0; i<n; i++) { | |
| cout<<arr[i]<<" "; | |
| } | |
| cout<<"\n"; |
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| template <class T> | |
| void print(T *arr, int n) { | |
| for(register int i=0; i<n; i++) { | |
| cout<<arr[i]<<" "; | |
| } |
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
| extension StringProtocol { | |
| subscript(_ offset: Int) -> Element { | |
| return self[index(startIndex, offsetBy: offset)] | |
| } | |
| subscript(_ range: Range<Int>) -> SubSequence { | |
| return prefix(range.lowerBound+range.count).suffix(range.count) | |
| } | |
| extension String { | |
| func contains(find: String) -> Bool{ | |
| return self.range(of: find) != nil | |
| } | |
| func containsIgnoringCase(find: String) -> Bool{ | |
| return self.range(of: find, options: .caseInsensitive) != nil | |
| } | |
| } | |
| var value = "Hello world" |
| // Wrong | |
| if bgAudioPlayer.isPlaying { | |
| bgAudioPlayer.stop() | |
| pausePlayButton.titleLabel?.text = "Play" | |
| } else { | |
| bgAudioPlayer.play() | |
| pausePlayButton.titleLabel?.text = "Pause" | |
| } | |
| // Right |
| func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
| let nsString = textField.text as NSString? | |
| let newString = nsString?.replacingCharacters(in: range, with: string) | |
| if let string = newString, | |
| string.count > YOUR_LIMIT_HERE { | |
| return false | |
| } | |
| return true | |
| } |
| // MARK: - Main | |
| var cipherText = "VSRQJHEREVTXDUHSDQWU".lowercased() | |
| let decipheredTexts = decipherText(cipherText) | |
| for (k, s) in decipheredTexts { | |
| print("Shifts: \(k)\t\(s)") | |
| } | |
| // MARK: - Actions |