From 0d56a04d770c2df492ecf59c941e8d90578b0b60 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 3 Jan 2026 00:33:56 +0900 Subject: feat(study): shuffle cards when starting study session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cards are now randomized using Fisher-Yates algorithm to improve learning by preventing users from memorizing card order. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/client/utils/shuffle.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/client/utils/shuffle.ts (limited to 'src/client/utils/shuffle.ts') diff --git a/src/client/utils/shuffle.ts b/src/client/utils/shuffle.ts new file mode 100644 index 0000000..a2b8fec --- /dev/null +++ b/src/client/utils/shuffle.ts @@ -0,0 +1,14 @@ +/** + * Fisher-Yates shuffle algorithm. + * Returns a new shuffled array (does not mutate the original). + */ +export function shuffle(array: T[]): T[] { + const result = [...array]; + for (let i = result.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + const temp = result[i] as T; + result[i] = result[j] as T; + result[j] = temp; + } + return result; +} -- cgit v1.2.3-70-g09d2