jaroshevskii/swift-ice-cream-sandwich
> **Language**: 🇺🇸 English | 🇺🇦 [Українська](README.uk.md) | 🇯🇵 [日本語](README.ja.md)
Definition
An Ice Cream Sandwich is a pattern with matching and distinct left and right ends, enveloping a unique middle portion.
Examples
"AABBBAA"[1, 2, 3, 3, 2, 1]505
Criteria
- Distinct Ends: Left and right ends must match in both length and repeated characters.
- Unique Middle: The middle portion is distinct from the ends.
- Minimum Length: Must be at least 3 characters.
Usage
To use the IceCreamSandwich library, include it in your project and utilize the isIceCreamSandwich property on instances.
import IceCreamSandwich
// String
let smileySandwich = "😊😊🍦😊😊"
if smileySandwich.isIceCreamSandwich {
print("Yay! You've created an Ice Cream Sandwich!")
} else {
print("Oops! Your arrangement doesn't form an Ice Cream Sandwich.")
}
// Collection
let numberSandwich = [1, 2, 3, 3, 2, 1]
if numberSandwich.isIceCreamSandwich {
print("Congratulations! You've assembled a numeric Ice Cream Sandwich!")
} else {
print("Oops! Your arrangement doesn't form a numeric Ice Cream Sandwich.")
}
// Integer
let integerSandwich = 505
if integerSandwich.isIceCreamSandwich {
print("Awesome! You've crafted a numeric Ice Cream Sandwich!")
} else {
print("Oops! Your numeric arrangement doesn't form an Ice Cream Sandwich.")
}Installation
Xcode
- In Xcode, go to
File>Swift Packages>Add Package Dependency... - Enter the URL:
https://github.com/jaroshevskii/swift-ice-cream-sandwich.git - Specify the desired version or use the latest, and follow the installation prompts.
For more information on adding Swift Packages to Xcode, you can read the Hacking with Swift tutorial.
Swift Package Manager
- Add IceCreamSandwich to your Package.swift file as a dependency:
``swift let package = Package( // name, platforms, products, etc. dependencies: [ .package(url: "https://github.com/jaroshevskii/swift-ice-cream-sandwich.git", from: "1.0.0"), ], targets: [ .target( name: "YourTargetName", dependencies: [ .product(name: "IceCreamSandwich", package: "swift-ice-cream-sandwich"), ]), ] ) ``
- Run
swift buildto fetch and integrate the package into your project.
Contributions
Feel free to contribute, report issues, or suggest improvements! Let's make IceCreamSandwich even more delightful.
License
Licensed under the MIT license.
Package Metadata
Repository: jaroshevskii/swift-ice-cream-sandwich
Default branch: main
README: README.md