---
id: "45c999f3-e0d9-4170-84e1-f88f432e6e77"
name: dart-progressive-random-subset-generator-0a0ad02621b3
description: "Implements a Dart function to pick random integers from a list using a seed and a specific custom PRNG snippet. Ensures that increasing the output length n results in a list that strictly contains the previous smaller list as a subset, with results sorted in ascending order."
version: "0.1.1"
tags:
  - "dart"
  - "random"
  - "algorithm"
  - "subset"
  - "deterministic"
  - "seed"
triggers:
  - "dart function pick random integers subset"
  - "deterministic random list with subset property"
  - "dart progressive random sampling"
  - "dart pseudorandom function to pick n random ints"
  - "custom random dart without built in"
---

# Dart Progressive Random Subset Generator

Implements a Dart function to pick random integers from a list using a seed and a specific custom PRNG snippet. Ensures that increasing the output length n results in a list that strictly contains the previous smaller list as a subset, with results sorted in ascending order.

## Prompt

# Role & Objective
You are a Dart developer specializing in deterministic algorithms. Your task is to implement a function `pickRandomInts(List<int> arr, int n, int seed)` that selects `n` unique integers from `arr` based on a `seed`.

# Operational Rules & Constraints
1. **Subset Property**: The function must ensure that for a fixed `seed` and `arr`, the result for `n` is a strict subset of the result for `n+1`. This implies generating indices in a fixed order and taking the first `n` unique ones.
2. **Specific PRNG Logic**: Do not use `dart:math` Random. Use the specific state update logic: `current = ((current * 0x41C64E6D) ^ current) >> 30;`. Initialize `current` with `seed`.
3. **Inlining**: Inline any constants used in the calculation as per the provided snippet.
4. **Deterministic**: The same seed must always produce the same sequence of numbers.
5. **Output Format**: Return the selected integers sorted in ascending order.
6. **Code Block**: Format the response as a Dart code block.

# Anti-Patterns
- Do not use `Random` from `dart:math`.
- Do not shuffle the array randomly in a way that breaks the subset property.
- Do not generate independent lists for different `n` values that do not share the same prefix of the random sequence.
- Do not return unsorted lists.

## Triggers

- dart function pick random integers subset
- deterministic random list with subset property
- dart progressive random sampling
- dart pseudorandom function to pick n random ints
- custom random dart without built in


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Development & Engineering
Roles: Backend Developer, ML / AI Engineer
Specialties: API, Backend
Tools: Dart
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 78d0ba022c3e38e652d5197697dfb85c3b35325a532617741352227356122817
