Công cụ xáo trộn danh sách theo thuật toán Fisher-Yates rồi chia thành N nhóm có quy mô gần bằng nhau. Dán danh sách tên, chọn số đội, bấm Trộn là ra kết quả. Dùng để chia đội bóng, bốc thăm trò chơi, phân công trực nhật, hay chọn ngẫu nhiên người phát biểu trong buổi họp.
Fisher-Yates duyệt mảng từ cuối về đầu và đổi chỗ mỗi phần tử với một phần tử ngẫu nhiên phía trước nó. Mỗi hoán vị trong n! hoán vị có xác suất bằng nhau, điều mà cách sắp xếp bằng hàm random không đảm bảo. Công cụ lấy số ngẫu nhiên từ crypto.getRandomValues chứ không dùng Math.random, nên kết quả không thể đoán trước kể cả khi biết mã nguồn.
Cách sử dụng
- Dán danh sách vào ô nhập liệu, mỗi dòng một mục.
- Chọn số nhóm cần chia, hoặc để trống nếu chỉ muốn trộn.
- Bấm Trộn để tạo kết quả mới.
- Xem từng nhóm và số thành viên trong mỗi nhóm.
- Bấm Sao chép để lấy kết quả hoặc sao chép từng nhóm riêng.
This shuffles a list with the Fisher-Yates algorithm and deals it into N groups of near-equal size. Paste names, choose how many teams, press shuffle. It is for splitting sides for a match, drawing lots for a game, assigning chores, or picking who speaks next in a meeting.
Fisher-Yates walks the array from the end and swaps each element with a random one at or before it. Every one of the n! permutations is equally likely, which sorting with a random comparator does not guarantee. Randomness comes from crypto.getRandomValues rather than Math.random, so the outcome is not predictable even with the source in hand.
How to use
- Paste the list into the input box, one item per line.
- Set the number of groups, or leave it blank to only shuffle.
- Press Shuffle to generate a new result.
- Review each group and its member count.
- Copy the whole result, or copy one group at a time.