Write Swift code algorithm to like and repost posts of models on a fashion website until someone responds. Liking adds 1 point, reposting adds 2 points, watching a story 0.1 points. An average model expects 100 points. Probability of reaction is 10%.

14 upvotes

3 years and 8 months later

GPT-3.5

func interactWithModels(pointsNeeded: Int, reactionProbability: Double) { var points = 0 var modelsLiked = 0 var modelsReposted = 0 var storiesWatched = 0 while points < pointsNeeded { points += 1 modelsLiked += 1 if Double.random(in: 0...1) <= reactionProbability { print("Model responded!") break } if points >= pointsNeeded { break } points += 2 modelsReposted += 1 if Double.random(in: 0...1) <= reactionProbability { print("Model responded!") break } if points >= pointsNeeded { break } points += 0.1 storiesWatched += 1 if Double.random(in: 0...1) <= reactionProbability { print("Model responded!") break } } print("Liked \(modelsLiked) models, reposted \(modelsReposted) models, watched \(storiesWatched) stories.") } interactWithModels(pointsNeeded: 100, reactionProbability: 0.1)
104 words

GPT-6 Astra

The missing detail is when the 10% reaction probability applies. Below, assume it applies independently after each 100 points earned for a model. Actual responses must be checked through the website—not generated randomly.

Use the website’s official API where automation is permitted. The API adapter should exclude previously completed actions and respect rate limits.

import Foundation

enum Engagement {
    case like(postID: String)
    case repost(postID: String)
    case watchStory(storyID: String)

    // Integer units avoid floating-point rounding: 1 unit = 0.1 points.
    var units: Int {
        switch self {
        case .like:       return 10
        case .repost:     return 20
        case .watchStory: return 1
        }
    }
}

protocol FashionAPI {
    /// Check for an actual response to the authenticated user.
    func hasResponded(modelID: String) async throws -> Bool

    /// Return an eligible, uncompleted action, or nil if none remain.
    func nextEligibleAction(modelID: String) async throws -> Engagement?

    /// Return true only if the action was newly completed.
    /// Watching a story must represent a genuine supported viewing action.
    func perform(
        _ action: Engagement,
        modelID: String
    ) async throws -> Bool
}

struct RunResult {
    let respondingModel: String?
    let pointsByModel: [String: Double]
}

func engageUntilResponse(
    modelIDs: [String],
    api: any FashionAPI,
    maxActions: Int = 500,
    delaySeconds: UInt64 = 30
) async throws -> RunResult {
    // Deduplicate while preserving order.
    var seen = Set<String>()
    let models = modelIDs.filter { seen.insert($0).inserted }

    var units = Dictionary(
        uniqueKeysWithValues: models.map { ($0, 0) }
    )

    func result(responder: String? = nil) -> RunResult {
        RunResult(
            respondingModel: responder,
            pointsByModel: units.mapValues { Double($0) / 10 }
        )
    }

    guard !models.isEmpty, maxActions > 0 else {
        return result()
    }

    var attemptedActions = 0

    while attemptedActions < maxActions {
        var foundAction = false

        // Round-robin engagement across models.
        for model in models {
            try Task.checkCancellation()

            // Stop as soon as any actual response is detected.
            for candidate in models {
                if try await api.hasResponded(modelID: candidate) {
                    return result(responder: candidate)
                }
            }

            guard let action = try await api.nextEligibleAction(
                modelID: model
            ) else {
                continue
            }

            foundAction = true
            attemptedActions += 1

            if try await api.perform(action, modelID: model) {
                units[model, default: 0] += action.units
            }

            try await Task.sleep(for: .seconds(Double(delaySeconds)))

            if attemptedActions >= maxActions {
                break
            }
        }

        // Stop instead of spinning when there is nothing left to do.
        if !foundAction {
            break
        }
    }

    // Check once more after the final action.
    for model in models {
        if try await api.hasResponded(modelID: model) {
            return result(responder: model)
        }
    }

    return result()
}

Implement FashionAPI using the site’s documented endpoints. maxActions provides a finite engagement budget; errors and task cancellation stop execution.

Under the assumed probability model:

  • 100 points = 100 likes, 50 reposts, 1,000 story views, or a mixture.
  • Chance of at least one reaction after nn independent 100-point opportunities:
1−0.9n1 - 0.9^n
  • Expected expenditure before a reaction: 1,000 points, not a guarantee.

If the 10% probability is instead per model, repeated engagement with the same model cannot be assumed to create additional independent chances.

493 words

What changed

GPT-3.5’s code would not compile. It declares var points = 0, which Swift treats as an integer, then tries points += 0.1 for watching a story. Even if fixed, its logic barely uses the 100-point target: it rolls the 10% chance after every single like, repost and view, so a “response” almost always arrives within a dozen actions. Astra sidesteps the decimal trap by counting in tenths (“1 unit = 0.1 points”) and correctly flags the real ambiguity, when the 10% applies.

Astra also changes the task, though. The prompt reads like a request for a simulation, and GPT-3.5’s random rolls were the right idea. Astra declares that responses “must be checked through the website, not generated randomly.” It builds a polite, rate-limited bot around a hypothetical API, and the probability shows up only in a closing note, “Expected expenditure before a reaction: 1,000 points.” That math is sound and the code is careful, but anyone who wanted to run the numbers gets no simulation at all.

From December 2022 to March 2023, visitors to LearnGPT, the earlier version of Emergent Mind, shared ChatGPT conversations they found useful or funny. On October 19, 2026, each prompt went to GPT-6 Astra exactly as it was shared: one message, no system prompt, default reasoning effort. Claude Opus 5.5 wrote the analysis under each pair after reading both answers. Original answers appear as the people who shared them pasted them. A few examples are left out because they depended on missing context or weren't appropriate to republish.

More from Emergent Mind Labs