From 8501263a248e2fb31422010de032e08abfe27464 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 13 Jun 2026 21:23:45 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20optimize=20random=20number?= =?UTF-8?q?=20generation=20in=20random.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implement hybrid sampling strategy: Fisher-Yates for high density, Set-based rejection for low density. - Replace innerText with textContent for faster DOM updates. - Add CSS overflow and max-height to results container to handle large outputs. - Fix validation logic to allow single-value ranges. Co-authored-by: babelman97 <186798789+babelman97@users.noreply.github.com> --- .jules/bolt.md | 3 +++ random.html | 69 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..60ae5b8 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-05-15 - [Random unique sampling density optimization] +**Learning:** Rejection sampling (Set) for unique random numbers collapses at high density (Coupon Collector's Problem). Hybrid approaches using Fisher-Yates shuffle for high density (count > 50% of range) ensure O(N) complexity. Also, strict range validation (minValue >= maxValue) prevents single-value generation which is sometimes desired. +**Action:** Always check sampling density for unique random generation and use hybrid strategies. Ensure range validation allows single values (minValue === maxValue) if requested count is 1. diff --git a/random.html b/random.html index 2609ac8..4b7afaa 100644 --- a/random.html +++ b/random.html @@ -10,9 +10,11 @@ flex-direction: column; align-items: center; justify-content: center; - height: 100vh; + min-height: 100vh; background-color: #f0f0f0; font-family: Arial, sans-serif; + padding: 20px; + box-sizing: border-box; } .button { padding: 20px 40px; @@ -23,11 +25,23 @@ background-color: #4CAF50; color: white; border-radius: 10px; + transition: background-color 0.3s; + } + .button:hover { + background-color: #45a049; } .number { - font-size: 36px; + font-size: 1.2rem; color: #333; - margin-top: 10px; + margin-top: 20px; + max-width: 800px; + max-height: 50vh; + overflow-y: auto; + word-break: break-all; + background: white; + padding: 15px; + border-radius: 10px; + box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .input-field { margin: 10px 0; @@ -49,22 +63,51 @@