Initial commit: Original Python LLMTester project
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
Write a Swift function that solves the FizzBuzz problem.
|
||||
|
||||
The function must have the exact signature:
|
||||
`func generateFizzBuzz(upTo max: Int) -> [String]`
|
||||
|
||||
It must not print directly to the console. Instead, it should return an array of strings.
|
||||
|
||||
Rules:
|
||||
1. For numbers divisible by 3, the string should be "Fizz".
|
||||
2. For numbers divisible by 5, the string should be "Buzz".
|
||||
3. For numbers divisible by both 3 and 5, the string should be "FizzBuzz".
|
||||
4. Otherwise, it should be the number itself as a string.
|
||||
|
||||
Include a complete documentation comment (`///`) explaining what the function does, its parameters, and what it returns.
|
||||
@@ -0,0 +1,5 @@
|
||||
Create a custom SwiftUI Layout container called `SimpleFlowLayout`.
|
||||
|
||||
This layout should arrange its subviews in a horizontal flow, starting a new row when the current row is full. It should behave similarly to a basic left-aligned flow layout in CSS.
|
||||
|
||||
The implementation must conform to the `Layout` protocol and implement both the `sizeThatFits(...)` and `placeSubviews(...)` methods.
|
||||
@@ -0,0 +1,10 @@
|
||||
Create a complete SwiftUI view for a user profile card.
|
||||
|
||||
The view should be named `UserProfileCard` and be initialized with a simple `User` struct containing `name: String`, `handle: String`, and `avatarURL: URL`.
|
||||
|
||||
Requirements:
|
||||
- Use an `AsyncImage` to load the user's avatar from the URL.
|
||||
- Display the user's name in a `.headline` font and their handle (e.g., "@username") in a `.subheadline` font with a secondary color.
|
||||
- Include a "Follow" button that uses the "person.badge.plus" SF Symbol.
|
||||
- Arrange the elements cleanly inside an HStack with appropriate spacing.
|
||||
- The entire card should have a subtle shadow and rounded corners.
|
||||
@@ -0,0 +1,23 @@
|
||||
I have this old networking code that uses a completion handler. Please refactor it to use modern Swift Concurrency with async/await.
|
||||
|
||||
The new function should be marked with `async throws` and return a `[Post]` object upon success. Also, include an example of how to call this new async function inside a `Task` with a `do-catch` block.
|
||||
|
||||
**Old Code:**
|
||||
struct Post: Codable {
|
||||
let id: Int
|
||||
let title: String
|
||||
}
|
||||
|
||||
func fetchPosts(completion: @escaping (Result<[Post], Error>) -> Void) {
|
||||
guard let url = URL(string: "https://api.example.com/posts") else { return }
|
||||
URLSession.shared.dataTask(with: url) { data, _, error in
|
||||
if let error = error { completion(.failure(error)); return }
|
||||
guard let data = data else { return }
|
||||
do {
|
||||
let posts = try JSONDecoder().decode([Post].self, from: data)
|
||||
completion(.success(posts))
|
||||
} catch {
|
||||
completion(.failure(error))
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Create a complete SwiftData example for a macOS 26 app.
|
||||
|
||||
You must define two models: `Author` and `Book`. An `Author` can have many `Book`s (a one-to-many relationship).
|
||||
|
||||
Then, create a SwiftUI view that displays a list of all authors. When an author's name is tapped, it should navigate to a detail view that shows a list of all the books written by that specific author. Use a SwiftData `@Query` to fetch the data.
|
||||
@@ -0,0 +1,7 @@
|
||||
Write a thread-safe counter class in Swift using an `actor`.
|
||||
|
||||
The actor should be named `SafeCounter`. It must have a private property to hold the current count and two public methods:
|
||||
1. `func increment() async`
|
||||
2. `func getCount() async -> Int`
|
||||
|
||||
Also, provide a simple example of how to create an instance of the actor and call its methods concurrently from two different `Task`s.
|
||||
@@ -0,0 +1,9 @@
|
||||
Create the code for a simple, non-configurable watchOS 26 complication that displays the current date in the `.accessoryRectangular` family.
|
||||
|
||||
The code must include:
|
||||
1. A `TimelineProvider` to generate the timeline entries.
|
||||
2. A `TimelineEntry` struct.
|
||||
3. The main `Widget` struct.
|
||||
4. A SwiftUI view for the complication's appearance.
|
||||
|
||||
Ensure the code correctly uses the modern WidgetKit framework.
|
||||
@@ -0,0 +1,17 @@
|
||||
Refactor this SwiftUI view and its `ObservableObject` to use the modern `@Observable` macro introduced in Swift 5.9. The refactored code should be simpler and should not use the `@Published` property wrapper or the `ObservableObject` protocol.
|
||||
|
||||
**Old Code:**
|
||||
class UserSettings: ObservableObject {
|
||||
@Published var score: Int = 0
|
||||
@Published var username: String = "Guest"
|
||||
}
|
||||
|
||||
struct SettingsView: View {
|
||||
@StateObject private var settings = UserSettings()
|
||||
var body: some View {
|
||||
Form {
|
||||
TextField("Username", text: $settings.username)
|
||||
Stepper("Score: \(settings.score)", value: $settings.score)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Create the code for a simple, configurable WidgetKit widget for iOS 26. The widget should display a single "Note" string. The configuration logic must use the modern App Intents framework, allowing the user to edit the note's text directly from the widget's configuration screen. Do not use the old `INIntent` based system.
|
||||
@@ -0,0 +1,7 @@
|
||||
Write a complete SwiftUI view for visionOS 26 that presents a fully immersive space when a button is tapped.
|
||||
|
||||
The view must:
|
||||
1. Have a button labeled "Enter Immersive Space".
|
||||
2. Use the `@Environment(\.openImmersiveSpace)` and `@Environment(\.dismissImmersiveSpace)` variables.
|
||||
3. Be able to open an immersive space with the ID "MyImmersiveScene".
|
||||
4. Include a second button inside the immersive space to dismiss it.
|
||||
Reference in New Issue
Block a user