This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| # QUESTION | |
| Is there a way to combine `guard` and `try-catch`, so that we can | |
| exploit the `guard let` to have a immutable value, but have an early | |
| return in case of errors? | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum CollectionClusteringError : ErrorType { | |
| case SizeIsNotMultipleOfClusterSize | |
| } | |
| extension CollectionType where Index.Distance == Int, Index == Int { | |
| /** | |
| Returns an array of elements from the collection grouped in clusters of the given size, | |
| grouped according to the original order in the collection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public func p004()->Int { | |
| // 999 * 993 = 992007 sum: 1992 | |
| // 998 * 994 = 992012 sum: 1992 | |
| // 997 * 995 = 992015 sum: 1992 | |
| // 996 * 996 = 992016 sum: 1992 | |
| // 999 * 994 = 993006 sum: 1993 | |
| // 998 * 995 = 993010 sum: 1993 | |
| // 997 * 996 = 993012 sum: 1993 | |
| // 999 * 995 = 994005 sum: 1994 |