Skip to content

Commit d5921e5

Browse files
committed
Fix second round review feedback
- Add step-arrow marker to result SVG to fix missing arrow heads - Unify time complexity to O(√n + d·log n) across all HTML sections - Remove unnecessary stepsData.length from useEffect dependencies - Refactor test code to use show_divisor_details helper function
1 parent 28d40da commit d5921e5

2 files changed

Lines changed: 39 additions & 23 deletions

File tree

Mathematics/Fundamentals/HackerRank/Claude/Easy/Best Divisor/BestDivisor.html

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
>
8484
<h1 class="text-[2.5rem] font-bold text-teal-800 mb-2">Best Divisor</h1>
8585
<p class="text-xl text-cyan-700 font-semibold mt-2">
86-
√n約数列挙+桁和比較 による O(√n) 実装
86+
√n約数列挙+桁和比較 による O(√n + d·log n) 実装
8787
</p>
8888
<nav class="flex flex-wrap gap-4 mt-6">
8989
<a
@@ -171,8 +171,8 @@ <h3 class="text-xl font-bold text-teal-800 mt-6 mb-3">戦略</h3>
171171
<h3 class="text-xl font-bold text-teal-800 mt-6 mb-3">主要ポイント</h3>
172172
<ul class="list-disc list-inside space-y-2 text-slate-700 ml-4">
173173
<li>
174-
<strong>時間計算量:</strong> O(√n) - √n までのループ + O(d log d)
175-
の桁和計算(d は約数の個数)
174+
<strong>時間計算量:</strong> O(√n + d·log n) - √n までのループ +
175+
各約数の桁和計算 O(log n)
176176
</li>
177177
<li><strong>空間計算量:</strong> O(d) - 約数リストの保存</li>
178178
<li>
@@ -1085,10 +1085,10 @@ <h3 class="text-lg font-bold text-slate-700 mb-3">📖 フローチャートの
10851085
<td class="border-2 border-slate-200 px-4 py-3">
10861086
<span
10871087
class="px-3 py-1 bg-emerald-100 text-emerald-800 rounded-full font-mono font-bold"
1088-
>O(√n)</span
1088+
>O(√n + d·log n)</span
10891089
>
10901090
<div class="text-sm text-slate-600 mt-1">
1091-
√n までループ + O(d log d) 桁和計算
1091+
√n までループ + 各約数の桁和計算 O(log n)
10921092
</div>
10931093
</td>
10941094
<td class="border-2 border-slate-200 px-4 py-3">
@@ -1967,6 +1967,19 @@ <h3 class="text-xl font-bold text-teal-800 mt-8 mb-3">具体例での計算量</
19671967
viewBox="0 0 600 250"
19681968
style={{ maxWidth: '100%', height: 'auto', marginTop: '20px' }}
19691969
>
1970+
<defs>
1971+
<marker
1972+
id="step-arrow"
1973+
markerWidth="10"
1974+
markerHeight="10"
1975+
refX="9"
1976+
refY="3"
1977+
orient="auto"
1978+
markerUnits="strokeWidth"
1979+
>
1980+
<path d="M0,0 L0,6 L9,3 z" fill="#64748b" />
1981+
</marker>
1982+
</defs>
19701983
{/* Input */}
19711984
<rect
19721985
x="50"
@@ -2131,7 +2144,7 @@ <h3 class="text-xl font-bold text-teal-800 mt-8 mb-3">具体例での計算量</
21312144
return () => {
21322145
if (timerRef.current) clearTimeout(timerRef.current);
21332146
};
2134-
}, [isPlaying, activeStep, stepsData.length]);
2147+
}, [isPlaying, activeStep]);
21352148

21362149
const handlePlay = () => {
21372150
if (isPlaying) return;

Mathematics/Fundamentals/HackerRank/Claude/Easy/Best Divisor/BestDivisor.ipynb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,26 @@
112112
" status = \"\" if result == expected else \"\"\n",
113113
" print(f\"{status} n={n}: expected={expected}, got={result}\")\n",
114114
"\n",
115-
"# 詳細デバッグ用\n",
116-
"print(\"\\n=== n=12 の詳細 ===\")\n",
117-
"n = 12\n",
118-
"divisors = []\n",
119-
"i = 1\n",
120-
"while i * i <= n:\n",
121-
" if n % i == 0:\n",
122-
" divisors.append(i)\n",
123-
" if i != n // i:\n",
124-
" divisors.append(n // i)\n",
125-
" i += 1\n",
126-
"\n",
127-
"print(f\"約数: {sorted(divisors)}\")\n",
128-
"for d in sorted(divisors):\n",
129-
" digit_sum = sum(int(digit) for digit in str(d))\n",
130-
" print(f\" {d} → 桁和 = {digit_sum}\")\n",
131-
"print(f\"最良約数: {findBestDivisor(n)}\")"
115+
"# 詳細デバッグ用(n=12 の例)\n",
116+
"def show_divisor_details(n):\n",
117+
" \"\"\"約数とその桁和を表示するヘルパー関数\"\"\"\n",
118+
" divisors = []\n",
119+
" i = 1\n",
120+
" while i * i <= n:\n",
121+
" if n % i == 0:\n",
122+
" divisors.append(i)\n",
123+
" if i != n // i:\n",
124+
" divisors.append(n // i)\n",
125+
" i += 1\n",
126+
" \n",
127+
" print(f\"\\n=== n={n} の詳細 ===\")\n",
128+
" print(f\"約数: {sorted(divisors)}\")\n",
129+
" for d in sorted(divisors):\n",
130+
" digit_sum = sum(int(digit) for digit in str(d))\n",
131+
" print(f\" {d} → 桁和 = {digit_sum}\")\n",
132+
" print(f\"最良約数: {findBestDivisor(n)}\")\n",
133+
"\n",
134+
"show_divisor_details(12)"
132135
]
133136
},
134137
{

0 commit comments

Comments
 (0)