en
Feedback
ToCode

ToCode

Open in Telegram

ื˜ื™ืคื™ื ืงืฆืจื™ื ืœืžืชื›ื ืชื™ื ืžืืช ื™ื ื•ืŸ ืคืจืง

Show more
1 417
Subscribers
-224 hours
-37 days
-630 days
Posts Archive
ToCode
1 417
ืคืจื•ื™ืงื˜ ืื™ืฉื™ ื•ืžืชื•ื—ื–ืง ื”ื•ื ืœื ืจืง ืขื•ื“ ื“ืจืš ืœื”ืชืžืงืฆืข, ื”ื•ื ื”ื‘ืกื™ืก ืขืœื™ื• ืชื•ื›ืœื• ืœื ืกื•ืช ื˜ืจื™ืงื™ื ื—ื“ืฉื™ื ื‘ืœื™ ืœื“ืื•ื’ ื•ื‘ืœื™ ืœื‘ืงืฉ ืจืฉื•ืช. ื•ืžื” ืœื’ื‘ื™ ืงื‘ืœื” ืœืขื‘ื•ื“ื”? ืื ื—ื ื• ื ืžืฆืื™ื ื‘ืชืงื•ืคื” ืžืฉื•ื’ืขืช ื•ืื ื™ ืžื•ื“ื” ืฉืงืฉื” ืœื“ืขืช ืžื” ื™ืœื“ ื™ื•ื. ื™ืฉ ืกื™ื›ื•ื™ ืฉื‘ืฉื‘ื•ืขื•ืช ืื• ื—ื•ื“ืฉื™ื ื”ืงืจื•ื‘ื™ื ื”ื•ืกืคืช ื“ืฃ ืคืจื•ืคื™ืœ ืขื "ืคืจื•ื™ืงื˜ื™ื" ื™ื”ืคื•ืš ืœืกื˜ื ื“ืจื˜ ื‘ื›ืœ ืงื•ืจื•ืช ื—ื™ื™ื ื•ื›ืœ ืื—ื“ ืคืฉื•ื˜ ื™ื•ืกื™ืฃ ืคืจื•ื™ืงื˜ ืงื˜ืŸ ืฉื”ื•ื ื›ืชื‘ ื‘ base44 ืœืงื•ืจื•ืช ื—ื™ื™ื, ื•ื”ืจืžื” ืฉืœ ื”ืคืจื•ื™ืงื˜ื™ื ื”ืื•ื˜ื•ืžื˜ื™ื™ื ื”ืืœื” ืชื”ื™ื” ื›ืœ ื›ืš ื’ื‘ื•ื”ื” ืฉืื™ ืืคืฉืจ ื™ื”ื™ื” ืœื”ื‘ื“ื™ืœ ื‘ื™ื ื ืœื‘ื™ืŸ ืคืจื•ื™ืงื˜ ืืžื™ืชื™. ืื ื™ ืœื ื™ื•ื“ืข. ื›ืจื’ืข ืื ื—ื ื• ืขื•ื“ ืœื ืฉื. ื ื›ื•ืŸ ืœื”ื™ื•ื ื›ืฉืื ื™ ืžืกืชื›ืœ ืขืœ ืงื•ื“ ืฉื ื›ืชื‘ ืขืœ ื™ื“ื™ Vibe Coding ื™ืฉ ื‘ื• ื‘ืขื™ื•ืช ื•ืื ื”ื™ื™ืชื™ ืฆืจื™ืš ืœื‘ื—ื•ืŸ ืงื•ื“ ื›ื–ื” ื‘ืงื•ืจื•ืช ื—ื™ื™ื ืžื”ืจ ืžืื•ื“ ื–ื” ื”ื™ื” ื ืจืื” ืœื™ ื—ืฉื•ื“. ื‘ืฉื‘ื™ืœ ืœื”ืคืขื™ืœ ื”ื™ื•ื AI ื•ืœืงื‘ืœ ืชื•ืฆืื” ืฉืœ ืงื•ื“ ื‘ืจืžื” ื’ื‘ื•ื”ื” ืฆืจื™ืš ืœื”ื›ื™ืจ ืืช ื”ื—ื•ืžืจ ื”ืžืงืฆื•ืขื™ ื‘ืจืžื” ื˜ื•ื‘ื”, ื•ืœื›ืŸ ืœื“ืขืชื™ ื–ื” ืœื ืžืื•ื“ ืžืฉื ื”. ืžื ื”ืœื™ ืคื™ืชื•ื— ืฉื™ืงืจืื• ืืช ื”ืงื•ื“ ืฉืœ ื”ืคืจื•ื™ืงื˜ ื™ื‘ื™ื ื• ืžื” ื”ืจืžื” ื”ืžืงืฆื•ืขื™ืช ืฉืœ ื”ืžืคืชื—, ื’ื ืื ื”ื•ื ื ืขื–ืจ ื‘ AI, ื•ืœืžืขืฉื” ืื ื™ ื—ื•ืฉื‘ ืฉืจืžื” ืžืงืฆื•ืขื™ืช ื ืžื•ื›ื” ื–ื” ืžืฉื”ื• ืฉืจื•ืื™ื ืืคื™ืœื• ื™ื•ืชืจ ื‘ื‘ื™ืจื•ืจ ื›ืฉืื ืฉื™ื ื ืขื–ืจื™ื ื‘ AI. ืœื›ืŸ ืœื”ืขืจื›ืชื™ ืคืจื•ื™ืงื˜ ืื™ืฉื™ ื‘ืจืžื” ื’ื‘ื•ื”ื” ืขื“ื™ื™ืŸ ื™ื›ื•ืœ ืœืคืชื•ื— ื“ืœืชื•ืช. ื‘ื ื™ื’ื•ื“ ืœื”ืขืจื›ื” ืฉืœื™ ืขืœ ื”ืชืžืงืฆืขื•ืช ืคื” ืื ื™ ืฉื ื›ื•ื›ื‘ื™ืช ื‘ื’ืœืœ ืื™ ื”ื•ื•ื“ืื•ืช ืกื‘ื™ื‘ ื”ืขืชื™ื“. ืžืกืœื•ืœ ืœื™ื•ื•ื™ ืœืคื™ืชื•ื— ืคืจื•ื™ืงื˜ื™ื ืื– ืžื” ื™ื”ื™ื” ืœื ื• ื‘ื™ื•ื ื™-ื™ื•ืœื™? ืืœื” ืขื™ืงืจื™ ื”ื“ื‘ืจื™ื: 1. ืฉืœื•ืฉื” ืฉื‘ื•ืขื•ืช ืฉืœ ืื™ืคื™ื•ืŸ ืคืจื•ื™ืงื˜, ืกื’ื™ืจื” ื˜ื›ื ื•ืœื•ื’ื™ืช, ื›ืชื™ื‘ืช POC ื•ื›ืœ ื”ืžื—ืงืจ ืฉืžืกื‘ื™ื‘. ื”ื›ืœ ื‘ื”ื ื—ื™ื” ืžืœืื” ื•ืขื ืคื™ื“ื‘ืง ืžืคื•ืจื˜ ืขืœ ื”ืขื‘ื•ื“ื” ืฉืœื›ื ื›ื“ื™ ืœื”ื’ื™ืข ืœืื™ืคื™ื•ืŸ ื”ื›ื™ ื˜ื•ื‘ ืฉืืคืฉืจ ื•ืœื”ื™ื—ืฉืฃ ืœื˜ื›ื ื•ืœื•ื’ื™ื•ืช ื—ื“ืฉื•ืช ืฉืื•ืœื™ ืœื ื”ืชื ืกื™ืชื ื‘ื”ืŸ ืขื“ื™ื™ืŸ. 2. ื—ืžื™ืฉื” ืฉื‘ื•ืขื•ืช ืฉืœ ืคื™ืชื•ื— ืœืคื™ ืชื•ื›ื ื™ืช ืžืคื•ืจื˜ืช ื•ืื™ืฉื™ืช ืฉืื ื™ ืืขื–ื•ืจ ืœื›ื ืœื‘ื ื•ืช. ื”ืชื•ื›ื ื™ืช ื‘ื ื•ื™ื” ืขืœ ื™ืขื“ื™ื ืฉื‘ื•ืขื™ื™ื ื•ื™ืฉ ืœื›ื ื’ืžื™ืฉื•ืช ืœืขื‘ื•ื“ ื‘ื–ืžืŸ ืฉื ื•ื— ืœื›ื. 3. ืžืคื’ืฉ ื–ื•ื ืคืขื ื‘ืฉื‘ื•ืข ื‘ื• ื ืจืื” ื ืงื•ื“ื•ืช ืžืจื›ื–ื™ื•ืช ืžื”ืคืจื•ื™ืงื˜ ืฉืœื›ื ื•ืžื”ืคืจื•ื™ืงื˜ื™ื ืฉืœ ื—ื‘ืจื™ื ืœืงื‘ื•ืฆื”, ื ื“ื‘ืจ ืขืœ ืืชื’ืจื™ื ืžืจื›ื–ื™ื™ื ืฉืขืœื• ื•ืื™ืš ืคืชืจื ื• ืื•ืชื (ื”ื›ืœ ืžื•ืงืœื˜). 4. ืฉื™ืขื•ืจ ืฉื‘ื•ืขื™ ืขืœ ื ื•ืฉื ืžืฉื•ืชืฃ ืœื›ื•ืœื ื›ืžื• ื‘ื™ืฆื•ืขื™ื, ืื‘ื˜ื—ืช ืžื™ื“ืข, ืืจื›ื™ื˜ืงื˜ื•ืจื”, ื›ืœื™ AI ื•ืขื•ื“. ืื ื›ื‘ืจ ื™ืฉ ืœื›ื ืจืขื™ื•ืŸ ืœืคืจื•ื™ืงื˜ ื™ื›ื•ืœื™ื ืœืจืฉื•ื ืื•ืชื• ื‘ื“ืฃ ื”ืจื™ืฉื•ื ื›ืืŸ: https://www.tocode.co.il/mentoring ืื ืืชื ืจื•ืฆื™ื ืœื”ืฉืชืชืฃ ืื‘ืœ ืื™ืŸ ืจืขื™ื•ืŸ ืื• ืฉืœื ืžืกืคื™ืง ืกื’ื•ืจื™ื, ืื• ืืคื™ืœื• ืจื•ืฆื™ื ืœืฉืžื•ืข ืขื•ื“ ืคืจื˜ื™ื ืขืœ ื”ืžืกืœื•ืœ - ืชืฉืื™ืจื• ืœื™ ื”ื•ื“ืขื” ื•ื ืชืื ืฉื™ื—ืช ื™ื™ืขื•ืฅ ืžืกื•ื“ืจืช.

ToCode
1 417
ืื—ืจื™ ืคืกื— ื”ื’ื™ืข - ื‘ื•ืื• ื ื“ื‘ืจ ืขืœ ืคืจื•ื™ืงื˜ ืชื•ื›ื ื” ื”ืื ืคื™ืชื•ื— ืคืจื•ื™ืงื˜ ืชื•ื›ื ื” ืื™ืฉื™ ื”ื•ื ืขื“ื™ื™ืŸ ื“ืจืš ืžื•ืžืœืฆืช ืœื”ืชืงื“ื ื‘ืชื•ืจ ืžืคืชื—ื™ื? ืชื›ืฃ ื ืจื—ื™ื‘ ืขืœ ื”ืฉืืœื” ื”ื–ืืช ืื‘ืœ ืœืคื ื™ ืฉืืฉื›ื—, ืื ืชืกื›ื™ืžื• ืื™ืชื™ ืฉื”ืชืฉื•ื‘ื” ื—ื™ื•ื‘ื™ืช (ื•ืื ื™ ืžืงื•ื•ื” ืฉืชืกื›ื™ืžื•), ื‘ื™ื•ื ื™ ื”ืงืจื•ื‘ ืื ื™ ืคื•ืชื— ืงื‘ื•ืฆื” ื ื•ืกืคืช ื‘ืžืกืœื•ืœ ืคื™ืชื•ื— ื”ืคืจื•ื™ืงื˜ื™ื, ื‘ื” ืชืงื‘ืœื• ืืช ื”ืžืกื’ืจืช ื•ื”ื›ืœื™ื ืœื‘ื ื•ืช ืคืจื•ื™ืงื˜ ืชื•ื›ื ื” ืื™ืฉื™ ืฉืœื›ื ื‘ืจืžื” ื’ื‘ื•ื”ื” ื•ืขื ืฉื™ืœื•ื‘ ื›ืœื™ AI ื•ื›ืœ ืžืชื•ื“ื•ืœื•ื’ื™ื•ืช ื”ืคื™ืชื•ื— ื”ืขื“ื›ื ื™ื•ืช. ืื ื™ืฉ ืœื›ื ืจืขื™ื•ืŸ ืœืคืจื•ื™ืงื˜ ื•ืืชื ืžื—ืคืฉื™ื ื”ื–ื“ืžื ื•ืช ืœื”ื•ืฆื™ื ืื•ืชื• ืžื”ืžื’ื™ืจื” ืื ื™ ืฉืœื›ื ื‘ื™ื•ื ื™ ื•ื™ื•ืœื™ ืœืชืช ืืช ื”ื“ื—ื™ืคื” ื•ืœืขื–ื•ืจ ื‘ื›ืœ ืžื” ืฉืืคืฉืจ. ืคืจื˜ื™ื ื›ืืŸ: https://www.tocode.co.il/mentoring ื•ืขื›ืฉื™ื• ืœืคื•ืกื˜. ื”ืื ืคื™ืชื•ื— ืคืจื•ื™ืงื˜ ืื™ืฉื™ ื”ื•ื ืขื“ื™ื™ืŸ ื”ื“ืจืš ืœื”ืชืงื“ื ื‘ืชื•ืจ ืžืคืชื—ื™ื? ืœืฉืืœื” ื”ื–ืืช ืชืžื™ื“ ื”ื™ื• ื˜ื™ืขื•ื ื™ื ื˜ื•ื‘ื™ื ืœืฉื ื™ ื”ืฆื“ื“ื™ื. ืžืฆื“ ืื—ื“ ื‘ืขื‘ื•ื“ื” ืขืœ ืคืจื•ื™ืงื˜ ืื ื—ื ื• ืžืชืขืกืงื™ื ื‘ื”ืžื•ืŸ ื“ื‘ืจื™ื: ืฆืจื™ืš ื’ื ืœื›ืชื•ื‘ ืืช ื” Backend ื•ื’ื ืืช ื” Frontend, ื’ื ืœื”ืชืื™ื ืœืžื•ื‘ื™ื™ืœ ื•ื’ื ืœื“ืื•ื’ ืœื‘ื™ืฆื•ืขื™ื, ื’ื ืœื›ืชื•ื‘ ื‘ื“ื™ืงื•ืช ื•ื’ื ืœื”ืงื™ื ืชืฉืชื™ืช CI/CD, ื’ื ืœื”ื‘ื™ืŸ ืื™ืš ืœื›ืชื•ื‘ ื‘ืœื™ ืฉื™ืคืจืฆื• ืœื›ื ืœืžืขืจื›ืช ื•ื’ื ืœื›ืชื•ื‘ ืงื•ื“ ื ื›ื•ืŸ ืฉืืคืฉืจ ื™ื”ื™ื” ืœืฉื ื•ืช ื•ืœืชื—ื–ืง. ืื™ืš ืืคืฉืจ ืœืžืฆื•ื ื–ืžืŸ ืœื“ืขืช ืืช ื›ืœ ื–ื” ื•ื’ื ืœื”ืชืžืงืฆืข ื‘ืชื—ื•ื ืžืกื•ื™ื? ื•ืื ืื ื™ ืœื ืžืชืžืงืฆืข ื‘ืืฃ ืชื—ื•ื ืื™ืš ืื•ื›ืœ ืœืขื‘ื•ืจ ืจืื™ื•ืŸ ืขื‘ื•ื“ื”? ืžืฆื“ ืฉื ื™ ืื ื—ื ื• ื™ื•ื“ืขื™ื ืฉืคื™ืชื•ื— ืชื•ื›ื ื” ื”ื•ื ืชื”ืœื™ืš ื”ื•ืœื™ืกื˜ื™. ื” Backend ืžืฉืคื™ืข ืขืœ ื” Frontend, ื”ื‘ื“ื™ืงื•ืช ืžืฉืคื™ืขื•ืช ืขืœ ื”ืชื—ื–ื•ืงื”, ืื‘ื˜ื—ืช ื”ืžื™ื“ืข ืžื•ืฉืคืขืช ืžืกื’ื ื•ืŸ ื”ื›ืชื™ื‘ื”. ืžืคืชื—ื™ื ืฉืœื ืžื›ื™ืจื™ื ืืช ื›ืœ ื”ืชืžื•ื ื” ืื• ืฉืœื ืžืฆืœื™ื—ื™ื ืœืจืื•ืช ืื•ืชื” ื™ืคืกืคืกื• ื‘ื ืงื•ื“ื•ืช ืงืจื™ื˜ื™ื•ืช ืื• ืฉืœื ื™ื‘ื™ื ื• ืขื“ ื”ืกื•ืฃ ืืช ื”ืงื•ื“ ืฉื”ื ื›ื•ืชื‘ื™ื. ื™ื•ืชืจ ืžื–ื”, ืขื ื”ื›ื ื™ืกื” ืฉืœ AI ืœืชืžื•ื ื” ืื ื—ื ื• ื—ื•ื–ืจื™ื ืœืจืื•ืช ืฆื•ื•ืชื™ ืคื™ืชื•ื— ืฉืœ ืื—ื“, ืžืคืชื— ืื• ืžืคืชื—ืช ืžื•ื‘ื™ืœื™ื ืฉื ืขื–ืจื™ื ื‘ AI ื›ื“ื™ ืœืขืฉื•ืช ืขื‘ื•ื“ื” ืฉืœ 5 ืื ืฉื™ื. ื”ื”ืชืžืงืฆืขื•ืช ืงื™ื™ืžืช ื•ืงื™ื‘ืœื” ืื•ืคื™ ืื—ืจ. ื›ื ื™ืกืช ื›ืœื™ AI ืœืชืžื•ื ื” ื”ื•ืกื™ืคื” ืขื•ื“ ื ืงื•ื“ืช ืžื‘ื˜, ื‘ืžื™ื•ื—ื“ ื›ืฉืื ื—ื ื• ื—ื•ืฉื‘ื™ื ืขืœ Vibe Coding. ืื ื™ ื™ื›ื•ืœ ื”ื™ื•ื ื‘ืขื–ืจืช Prompt ืœื™ื™ืฆืจ ืงื•ื“ ืฉืœ ืžืขืจื›ืช ืžืœืื”. ื›ืœื™ื ื›ืžื• Base44 ื• Lovable ื•ื’ื bolt ื• v0 ื•ืจื‘ื™ื ื ื•ืกืคื™ื ืžืขื•ื“ื“ื™ื ืื ืฉื™ื ื‘ืœื™ ื™ื“ืข ื‘ืคื™ืชื•ื— ืœื‘ื ื•ืช ืžืขืจื›ื•ืช, ื•ืคืชืื•ื ื›ืฉืื ื™ ืžื•ืกื™ืฃ ืœืงื•ืจื•ืช ื—ื™ื™ื ืคืจื•ื™ืงื˜ ืฉื‘ื ื™ืชื™ ื–ื” ืœื ืžืจืฉื™ื ืืฃ ืื—ื“. ืžื™ ื™ื•ื“ืข ืื ื‘ืืžืช ื›ืชื‘ืชื™ ืืช ื–ื” ืœื‘ื“ ืื• ืฉื ืชืชื™ ืœ AI ืœืขืฉื•ืช ืืช ืจื•ื‘ ื”ืขื‘ื•ื“ื” ื•ื”ืคืจื•ื™ืงื˜ ืžืœื ื‘ืื’ื™ื ืื• ืžื™ืžื•ืฉื™ื ื—ืœืงื™ื™ื. ืœืžื” ื—ืฉื•ื‘ ืฉื™ื”ื™ื” ืœื›ื ืคืจื•ื™ืงื˜ ืื™ืฉื™ ื”ืจืขื™ื•ืŸ ื”ืจืืฉื•ืŸ ืฉื›ื“ืื™ ืœืงื—ืช ื›ืืŸ ื”ื•ื ืฉื”ืชืžืงืฆืขื•ืช ื”ื™ื ืœื ืœื™ื ืืจื™ืช ื•ืื™ืŸ ืœื” ืžื“ื“ ืื—ื“. ื”ื ื” ื›ืžื” ื“ื•ื’ืžืื•ืช ืœืžื™ื•ืžื ื•ื™ื•ืช ืฉื•ื ื•ืช ืฉืžืคืชื—ื™ื ื™ื›ื•ืœื™ื ืœื”ืฉืชืคืจ ื‘ื”ืŸ: 1. ื”ื™ื›ื•ืœืช ืœืงื—ืช ืžืฉื™ืžืช ืคื™ืชื•ื— ื•ืœื‘ืฆืข ืื•ืชื”, ื›ืœื•ืžืจ ืœื—ื–ื•ืจ ืขื ืงื•ื“ ืฉืขื•ื‘ื“. 2. ื”ื™ื›ื•ืœืช ืœืจืื•ืช ืžื‘ื ื” ืฉืœ ืžืขืจื›ืช ื•ืœืขื‘ื•ื“ ื‘ืชื•ืš ื”ื›ืœืœื™ื, ื›ืœื•ืžืจ ืœืขื“ื›ืŸ ืืช ื”ืงื•ื“ ื‘ืœื™ ืœืฉื‘ื•ืจ ื”ื ื—ื•ืช ื™ืกื•ื“ ืฉืœ ื”ืžืขืจื›ืช. 3. ื”ื™ื›ื•ืœืช ืœื–ื”ื•ืช ืื‘ืกื˜ืจืงืฆื™ื•ืช ื•ืœื™ืฆื•ืจ ืื•ืชืŸ ื›ื“ื™ ืœืฉืคืจ ืืช ื”ืฉืคื” ืฉืœ ื”ืžืขืจื›ืช. 4. ื”ื™ื›ื•ืœืช ืœื”ื‘ื™ืŸ ื˜ื›ื ื•ืœื•ื’ื™ื” ื—ื“ืฉื”. 5. ื”ื™ื›ื•ืœืช ืœืจืื•ืช ืžืกืคืจ ืคื™ืชืจื•ื ื•ืช ืฉืœ ื‘ืขื™ื” ื•ืœืฉืงื•ืœ ื™ืชืจื•ื ื•ืช ื•ื—ืกืจื•ื ื•ืช ืฉืœ ื›ืœ ื’ื™ืฉื”. 6. ื”ื™ื›ื•ืœืช ืœืจืื•ืช ืงื“ื™ืžื” ื•ืœื–ื”ื•ืช ืื™ืš ืฉื™ื ื•ื™ ืžืกื•ื™ื ื™ืฉืคื™ืข ืขืœ ื”ืžืขืจื›ืช ื‘ืขืชื™ื“ ืื• ืขืœ ื—ืœืงื™ื ืื—ืจื™ื ื‘ืžืขืจื›ืช. 7. ื”ื™ื›ื•ืœืช ืœื”ืขืจื™ืš ื ื›ื•ืŸ ื–ืžืŸ ื•ื”ื™ืงืฃ ืขื‘ื•ื“ื” ืขืœ ืคื™ืฆ'ืจ ืžืกื•ื™ื. 8. ื”ื™ื›ื•ืœืช ืœืขืžื•ื“ ื‘ื–ืžื ื™ื ื’ื ืขืœ ื—ืฉื‘ื•ืŸ ื‘ื™ืฆื•ืข ืคืฉืจื•ืช, ื•ื”ื”ื‘ื ื” ืื™ื–ื” ืคืฉืจื•ืช ืืคืฉืจ ืœื‘ืฆืข ื•ืขืœ ืžื” ืื™ ืืคืฉืจ ืœื”ืชืคืฉืจ. ื•ืžืื—ืจ ื•ื”ืชืžืงืฆืขื•ืช ื‘ืคื™ืชื•ื— ืชื•ื›ื ื” ืžื•ืจื›ื‘ืช ืžื”ืžื•ืŸ ื•ืงื˜ื•ืจื™ื ืฉื•ื ื™ื, ื™ืฉ ื’ื ื”ืžื•ืŸ ื“ื‘ืจื™ื ืฉืืคืฉืจ ืœืขืฉื•ืช ื›ื“ื™ ืœื”ืชืžืงืฆืข ื›ืžืคืชื—ื™ ืชื•ื›ื ื”. ื›ืœ ื”ืคืขื™ืœื•ื™ื•ืช ื”ืืœื” ื—ืฉื•ื‘ื•ืช ื•ื™ืขื–ืจื• ืœื›ื ืœื”ื™ื•ืช ืžืคืชื—ื™ื ื˜ื•ื‘ื™ื ื™ื•ืชืจ: 1. ืงืจื™ืืช ืกืคืจื™ ืชื™ืื•ืจื™ื” ื‘ืžื“ืขื™ ื”ืžื—ืฉื‘. 2. ืคื™ืชืจื•ืŸ ืชืจื’ื™ืœื™ื ืงื˜ื ื™ื ื‘ื˜ื›ื ื•ืœื•ื’ื™ื” ืฉืืชื ืœื•ืžื“ื™ื. 3. ืคื™ืชืจื•ืŸ ืชืจื’ื™ืœื™ ืืœื’ื•ืจื™ืชืžื™ืงื” ืื• ืกื™ื‘ื•ื›ื™ื•ืช. 4. ืชืจื•ืžืช ืงื•ื“ ืœืคืจื•ื™ืงื˜ ืงื•ื“ ืคืชื•ื— (ื›ื•ืœืœ ื›ืฉื”ืžืชื—ื–ืงื™ื ืžืชืœื•ื ื ื™ื ืฉื”ืงื•ื“ ืฉืœื›ื ืœื ืžืชืื™ื ื•ื ื™ื”ื•ืœ ื›ืœ ื”ื“ื™ืืœื•ื’ ืขื“ ืฉื” PR ื™ืชืงื‘ืœ). 5. ืฉื™ืคื•ืจ ื‘ื™ืฆื•ืขื™ื ืฉืœ ืžืขืจื›ืช ืงื™ื™ืžืช. 6. ื–ื™ื”ื•ื™ ื‘ืขื™ื•ืช ืื‘ื˜ื—ื” ื‘ืงื•ื“ ืฉืืชื ื›ืชื‘ืชื ืื• ืฉืžื™ืฉื”ื• ืื—ืจ ื›ืชื‘. 7. ืงืจื™ืืช ืชื™ืขื•ื“ ืฉืœ ืกืคืจื™ื”, ืื• ืงื•ืจืก ืžืงืฆื•ืขื™ ืขืœื™ื”. 8. ื”ื•ืกืคืช ืคื™ืฆ'ืจ ืœืคืจื•ื™ืงื˜ ื’ื“ื•ืœ, ืื• ืชื™ืงื•ืŸ ื‘ืื’ ื‘ืคืจื•ื™ืงื˜ ื›ื–ื”. ื•ื›ืŸ ื’ื ืคื™ืชื•ื— ืคืจื•ื™ืงื˜ ืขืฆืžืื™ ืฉืœื›ื. ืคืจื•ื™ืงื˜ ืื™ืฉื™ ืฉืžื‘ื•ืฆืข ื˜ื•ื‘ ื™ื›ื•ืœ ืœื”ื™ื•ืช ื‘ืกื™ืก ื˜ื•ื‘ ืœื›ืœ ืกื•ื’ ื”ืชืžืงืฆืขื•ืช ืฉืชื‘ื—ืจื• - ื”ื•ื ื™ืืคืฉืจ ืœื›ื ืœืœืžื•ื“ ืขืœ ืื‘ื˜ื—ืช ืžื™ื“ืข, ืขืœ ื‘ื™ืฆื•ืขื™ื, ืขืœ ื›ืชื™ื‘ืช ืงื•ื“ ืฉื ื™ืชืŸ ืœื”ืจื—ื‘ื”, ื”ื•ื ื™ืืคืฉืจ ืœื›ื ืœื‘ืขื•ื˜ ื‘ืงื•ื“ ื•ืœืจืื•ืช ืžื” ื ืฉื‘ืจ ื•ืื™ืš ืœื›ืชื•ื‘ ืงื•ื“ ืฉื™ื™ืฉื‘ืจ ืคื—ื•ืช. ื”ื•ื ื™ื™ืชืŸ ืœื›ื ืžืงื•ื ืœื”ืชื ืกื•ืช ืขืœ ื”ืืœื’ื•ืจื™ืชืžื™ื ื”ื—ื“ืฉื™ื ืฉืœืžื“ืชื ืื• ืขืœ ืกืคืจื™ื•ืช ื—ื“ืฉื•ืช ืฉื’ื™ืœื™ืชื. ื–ื” ื“ื‘ืจ ืื—ื“ ืœืœืžื•ื“ ืื™ืš ืœื”ืงื™ื ืคื•ื ืงืฆื™ื™ืช Lambda, ื•ื–ื” ื“ื‘ืจ ื”ืจื‘ื” ื™ื•ืชืจ ื’ื“ื•ืœ ื›ืฉืคื•ื ืงืฆื™ื™ืช ื” Lambda ืฆืจื™ื›ื” ืœื”ืชื—ื‘ืจ ืขื ืžืขืจื›ืช ื’ื“ื•ืœื” ืฉื™ืฉ ืœื” ื”ื™ื’ื™ื•ืŸ ืคื ื™ืžื™ ืฉืืชื ื‘ื•ื ื™ื. ืื•ืชื• ื“ื‘ืจ ืœื’ื‘ื™ ืื™ื—ืกื•ืŸ ืงื‘ืฆื™ื ืขืœ S3, ื—ื™ื‘ื•ืจ ืžืฉืชืžืฉื™ื, ื”ื˜ืžืขืช ืฉื™ืจื•ืช ืฆื“-ืฉืœื™ืฉื™ ืื• ื›ืœ ืžื ื’ื ื•ืŸ ืื—ืจ.

ToCode
1 417
ืื ืœื’ื•ื’ืœ ืžื•ืชืจ ืื—ืช ืžื”ื”ื—ืœื˜ื•ืช ืฉืื ื™ ืœื ืื•ื”ื‘ ื‘ next ื”ื™ื ืœื”ื›ืฉื™ืœ build ื›ืฉื™ืฉ ืฉื’ื™ืื•ืช TypeScript ืื• ESLint. ื›ืœื•ืžืจ ื›ืŸ ืื ื™ ืžื‘ื™ืŸ ืืช ื”ื—ืฉื™ื‘ื•ืช, ื•ื‘ืจื•ืจ ืœื™ ืœืžื” ืฆืจื™ืš ืฉื™ื”ื™ื• ืกื˜ื ื“ืจื˜ื™ื ืœืคืจื•ื™ืงื˜ ืื‘ืœ ืžืฆื“ ืฉื ื™ ื™ืฉ ืชื™ืงื•ื ื™ื ืฉืื ื™ ืžืขืœื” ื›ื™ ืขื›ืฉื™ื• ืฆืจื™ืš ืชื™ืงื•ืŸ ื•ืื ื™ ื™ื•ื“ืข ืฉืขื•ื“ ื™ื•ื-ื™ื•ืžื™ื™ื ืื ื™ ืžื—ืœื™ืฃ ื‘ืžื ื’ื ื•ืŸ ื™ื•ืชืจ ื˜ื•ื‘ ืื• ืฉื”ื ืžืžืฉ ืœื ื—ืฉื•ื‘ื™ื ื•ืื ื™ ืžื•ื›ืŸ ืœื—ื™ื•ืช ืขื ืื™ื–ื” ืžืฉืชื ื” ืฉืœื ื”ืฉืชืžืฉืชื™ ื‘ื•. ื•ื‘ื›ืœืœ ืžื™ ืฉื›ืœ ื›ืš ื—ืฉื•ื‘ ืœื• ืฉ ESLint ื™ื”ื™ื” ื”ื›ืจื—ื™ ื™ื›ื•ืœ ืชืžื™ื“ ืœื”ืคืขื™ืœ ืืช ื–ื” ืขืฆืžืื™ืช ื‘ืงื•ื ืคื™ื’ื•ืจืฆื™ื” ืื• ื“ืจืš Hooks ื‘ git. ื‘ื›ืœ ืื•ืคืŸ ืขื“ ืœืื—ืจื•ื ื” ื—ืฉื‘ืชื™ ืฉื–ื• ืคืฉื•ื˜ ื“ืขื” ืœื ืคื•ืคื•ืœืจื™ืช ืฉืœื™, ื•ื”ื ื” ื’ื•ื’ืœ ื™ื•ืฆืื™ื ืขื IDE ื—ื“ืฉ ืžืฉื•ืœื‘ AI ื‘ืฉื Firebase Studio, ืฉืขื•ืฉื” ืงืกืžื™ื ืขื ื ืงืกื˜ 15 ื•ื‘ืืžืช ื ืจืื” ืื—ืœื” ื•ื‘ื™ื ืชื™ื™ื ื’ื ืœื ื‘ื™ืงืฉื• ืขืœื™ื• ื›ืกืฃ, ื•ื”ืกื˜ืืจื˜ืจ ืฉืœ ืคืจื•ื™ืงื˜ ื—ื“ืฉ ืžืชื—ื™ืœ ืขื ืงื•ื‘ืฅ ื”ืงื•ื ืคื™ื’ื•ืจืฆื™ื” ืฉืœื™:
import type {NextConfig} from 'next';

const nextConfig: NextConfig = {
  /* config options here */
  typescript: {
    ignoreBuildErrors: true,
  },
  eslint: {
    ignoreDuringBuilds: true,
  },
};

export default nextConfig;
ืฉื ื™ ืฉื™ื“ืจื•ื’ื™ื ืฉื›ืŸ ื”ื™ื™ืชื™ ืขื•ืฉื” ื‘ืกื˜ืืจื˜ืจ ืื’ื‘ ื–ื” ืœืฉื“ืจื’ ืืช ืจื™ืืงื˜ ืœื’ื™ืจืกื” 19 ื•ืืช ื˜ื™ื™ืœื•ื•ื™ื ื“ ืœื’ื™ืจืกื” 4, ื•ื‘ IDE ืขืฆืžื• ื”ืชืœื•ื ื” ื”ื™ื—ื™ื“ื” ืฉืœื™ ื”ื™ื ืฉืฉื™ื—ื” ืขื ื’'ืžื™ื ื™ ืœื ืžืชื™ื—ืกืช ืื•ื˜ื•ืžื˜ื™ืช ืœืงื•ื‘ืฅ ืฉืขื›ืฉื™ื• ืคืชื•ื— ื‘ืขื•ืจืš. ื‘ื›ืœ ืื•ืคืŸ ืขืœ ื—ื™ื ื ืื™ ืืคืฉืจ ืœื”ืชืœื•ื ืŸ. ืืคืฉืจ ืœื”ืชื—ื™ืœ ืœืงื•ื“ื“ ืื™ืชื• ื›ืืŸ: https://firebase.studio/

ToCode
1 417
ื”ื™ื•ื ืœืžื“ืชื™: ืžื™ืœื•ืŸ ืื•ื˜ื•ืžื˜ื™ ื‘ืคื™ื™ืชื•ืŸ ืื ื™ ืœื ื‘ื˜ื•ื— ืฉืืฉืชืžืฉ ื‘ืงื•ื“ ื”ื‘ื ืื‘ืœ ื”ื•ื ื”ื™ื” ื—ืžื•ื“ ืื– ืžืฉืชืฃ ืื•ืชื• ื›ืืŸ - ื ื ื™ื— ืฉื™ืฉ ืœื›ื ื ืงื•ื“ืช ืงืฆื” ื‘ืคืœืืกืง ืฉืžื—ื–ื™ืจื” JSON, ืžืฉื”ื• ื›ื–ื”:
from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/hello', methods=['GET'])
def hello():
    message = "Hello, world!"
    return jsonify(message=message)

if __name__ == '__main__':
    app.run(debug=True)
ื•ืืชื ืžืงื ืื™ื ื‘ื™ืœื“ื™ื ื”ืžืงื•ื‘ืœื™ื ืž JavaScript ืฉื™ื›ื•ืœื™ื ืคืฉื•ื˜ ืœื›ืชื•ื‘:
return {message}
ื•ืœื ืฆืจื™ื›ื™ื ืœื—ื–ื•ืจ ืขืœ ื”ืฉื ืคืขืžื™ื™ื, ืคืขื ืื—ืช ื‘ืฉื‘ื™ืœ ื”ืžืคืชื— ื•ืคืขื ืฉื ื™ื™ื” ื‘ืฉื‘ื™ืœ ื”ืขืจืš, ืื– ืืชื ื™ื›ื•ืœื™ื ืœื›ืชื•ื‘:
@app.route('/hello', methods=['GET'])
def hello():
    message = "Hello, world!"
    return jsonify(**locals())
ื›ื“ื™ ืœืงื‘ืœ ื‘ื“ื™ื•ืง ืืช ืื•ืชื” ืชื•ืฆืื”, ื•ื‘ืœื™ ืœื”ืงืœื™ื“ ืืช ืฉื ื”ืžืฉืชื ื” ืืคื™ืœื• ืคืขื ืื—ืช. ืื•, ืื ืืชื ื—ื•ืฉืฉื™ื (ื‘ืฆื“ืง) ืฉืื™ื–ื” ืžืฉืชื ื” ืฉืœื ื”ืชื›ื•ื•ื ืชื ื™ื™ื›ื ืก ืœื›ื ืœ JSON ืชื•ื›ืœื• ืœื›ืชื•ื‘:
@app.route('/hello', methods=['GET'])
def hello():
    message = "Hello, world!"
    return jsonify(**{k: v for k, v in locals().items() if k in ['message']})
ื•ื›ืŸ ื–ื” ืงืฆืช ืืจื•ืš ืื‘ืœ ืืคืฉืจ ืœืงืฆืจ ืขื ืคื•ื ืงืฆื™ื™ืช ืขื–ืจ ื•ืื– ื ืงื‘ืœ:
def only(d, *keys):
    return {k: d[k] for k in keys}

@app.route('/hello', methods=['GET'])
def hello():
    message = "Hello, world!"
    foo = 10
    bar = 20
    return jsonify(**only(locals(), 'message', 'bar'))
ื—ืžื•ื“? ื‘ื˜ื—. ืื‘ืœ ืœื ื”ื™ื™ืชื™ ืจื•ืฆื” ืœืจืื•ืช ืืช ื–ื” ื‘ืงื•ื“ ืืžื™ืชื™. ื”ื—ื™ืกื›ื•ืŸ ืœื ืžืกืคื™ืง ื—ืฉื•ื‘ ื‘ืฉื‘ื™ืœ ืœืจืื•ืช ืงื•ื“ ืœื ืกื˜ื ื“ืจื˜ื™.

ToCode
1 417
next unless map.contains(node)
      
      # Calculate Manhattan distances from the node to each antenna
      dist1 = (node.x - p1.x).abs + (node.y - p1.y).abs
      dist2 = (node.x - p2.x).abs + (node.y - p2.y).abs
      
      # An antinode occurs when one antenna is exactly twice as far away as the other
      if dist1 == 2 * dist2 || dist2 == 2 * dist1
        # Store this antinode location (using a string key to ensure uniqueness)
        key = "#{node.x},#{node.y}"
        antinode_locations[key] = node
      end
    end
  end
end

* The answer is the number of unique antinode locations *
puts "The number of unique locations containing an antinode is: #{antinode_locations.size}"
ื”ื˜ืขื•ืช ืฉืœ ืงืœื•ื“ ื‘ืคื™ืชืจื•ืŸ ื”ืฉืœื™ืฉื™ ืžืขื ื™ื™ื ืช - ืชื—ื™ืœื” ื”ื•ื ืžืคืขื™ืœ ืืช ื”ืคื•ื ืงืฆื™ื” ืฉืœื™ ื›ื“ื™ ืœืžืฆื•ื ืืช ื” Antinodes:
antinode1, antinode2 = p1.find_antinodes(p2)
ืื‘ืœ ืื– ื”ื•ื ืžื•ื•ื“ื ืฉื”ืชื•ืฆืื•ืช ืฉืœ ื”ืคื•ื ืงืฆื™ื” ื‘ืืžืช ืžืงื™ื™ืžื•ืช ืืช ืชื ืื™ ื”ืžืจื—ืง ื”ืฉื•ื•ื”:
dist1 = (node.x - p1.x).abs + (node.y - p1.y).abs
dist2 = (node.x - p2.x).abs + (node.y - p2.y).abs

* An antinode occurs when one antenna is exactly twice as far away as the other *
if dist1 == 2 * dist2 || dist2 == 2 * dist1
  # Store this antinode location (using a string key to ensure uniqueness)
  key = "#{node.x},#{node.y}"
  antinode_locations[key] = node
end
ื›ืœ ื”ื‘ืœื•ืง ื”ื–ื” ื›ืžื•ื‘ืŸ ืžื™ื•ืชืจ ื›ื™ ืžืจืืฉ ื™ืฆืจื ื• ืืช ื”ื ืงื•ื“ื•ืช ื›ืš ืฉื–ื” ื™ื”ื™ื” ื”ืžืจื—ืง. ื’ื ื”ืกืจื™ืืœื™ื–ืฆื™ื” ืฉืœ ื”ืงื•ืื•ืจื“ื™ื ื˜ื•ืช ืœืžื—ืจื•ื–ืช ืžื™ื•ืชืจืช ื›ื™ ื‘ Ruby ืืคืฉืจ ืœืฉืžื•ืจ Data Object ื‘ืชื•ืจ ืžืคืชื— ื‘ Hash. ืžืกืงื ื•ืช ืื– ืžื” ืœืžื“ื ื• ืžื”ื ื™ืกื•ื™? ื‘ื™ื ืชื™ื™ื ืœื ื”ืจื‘ื”. ื”ื ื” ื›ืžื” ืžืกืงื ื•ืช ืฉืื ื™ ืœื•ืงื—: 1. ื‘ืขื‘ื•ื“ื” ืขื AI ื—ืฉื•ื‘ ืœื ืกื— ื‘ืฆื•ืจื” ืžื“ื•ื™ืงืช ืืช ื”ื‘ืขื™ื”. 2. ืงืœื•ื“ ืœื ืชืžื™ื“ ืžืืžื™ืŸ ืœืชื™ืขื•ื“ ืื• ืœืžื™ืžื•ืฉ ืฉืœื ื•. ื‘ื™ื ืชื™ื™ื ืœื ื”ืฆืœื—ืชื™ ืœืฉื›ื ืข ืื•ืชื• ืœื›ืชื•ื‘ ืืช ื”ืงื•ื“ ื‘ืœื™ ืœื”ื•ืกื™ืฃ ืืช ื”ื‘ื“ื™ืงื” ื”ื›ืคื•ืœื”. 3. ืžืฆื“ ืฉื ื™ ืงืœื•ื“ ืฉืžื— ืœื”ืฉืชืžืฉ ื‘ืžื™ืžื•ืฉ ืฉืœื™ ืœ Map ื•ืœื ื ื™ืกื” ืœื›ืชื•ื‘ ื‘ืขืฆืžื• ืงื•ื“ ืฉืžืคืจืกืก ืืช ื”ืงืœื˜. 4. ื™ื”ื™ื” ืžืขื ื™ื™ืŸ ืœื”ื‘ื™ืŸ ืœืžื” ืงืœื•ื“ ืฉืžื— ืœื”ืฉืชืžืฉ ื‘ืคื•ื ืงืฆื™ื•ืช ืฉื›ืชื‘ืชื™ ื‘ Map ืื‘ืœ ื”ื™ื” ืžืื•ื“ ืกืงืคื˜ื™ ืœื’ื‘ื™ ื”ืคื•ื ืงืฆื™ื•ืช ืฉื›ืชื‘ืชื™ ื‘ Point, ื•ืื™ืš ืฆืจื™ืš ืœื›ืชื•ื‘ ืื‘ืกื˜ืจืงืฆื™ื•ืช ื›ื“ื™ ืฉ AI ื™ืจืฆื• ืœื”ืฉืชืžืฉ ื‘ื”ืŸ. 5. ืื ื™ ื—ื•ืฉื‘ ืฉื‘ืžืขืจื›ืช ื’ื“ื•ืœื” ื‘ืขื‘ื•ื“ื” ืขื Cursor ื›ืฉืื ื—ื ื• ืจื•ืฆื™ื ืœื•ื•ื“ื ืฉ AI ืžืฉืชืžืฉ ื‘ืื‘ืกื˜ืจืงืฆื™ื•ืช ืฉืื ื—ื ื• ื›ื•ืชื‘ื™ื (ืœืžืฉืœ ืœื•ื•ื“ื ืฉื”ื•ื ืžืฉืชืžืฉ ื‘ Custom Hook ืฉื›ืชื‘ื ื• ื‘ืžืงื•ื ืœื›ืชื•ื‘ ื—ื“ืฉ) ื›ื“ืื™ ืœื”ื•ืกื™ืฃ ืœืงื•ื ื˜ืงืกื˜ ืฉืœ ื” Prompt ื’ื ื“ื•ื’ืžืช ืงื•ื“ ืฉืžืฉืชืžืฉืช ื‘ืื•ืชื” ืื‘ืกื˜ืจืงืฆื™ื”. ืื•ืœื™ ื–ื” ืืคื™ืœื• ื™ื•ืชืจ ื—ืฉื•ื‘ ืžื”ืงื•ื“ ื”ืžืงื•ืจื™ ืฉืœ ื”ืื‘ืกื˜ืจืงืฆื™ื”. 6. ืื ื—ื ื• ืขื“ื™ื™ืŸ ืœื•ืžื“ื™ื. ื‘ืขื‘ื•ื“ื” ืขื AI ืžื” ืฉื—ืฉื•ื‘ ื–ื” ืœืขืฉื•ืช ื›ืžื” ืฉื™ื•ืชืจ ื ื™ืกื•ื™ื™ื ื•ืœื ืœืงื—ืช "ื›ืœืœื™ ืืฆื‘ืข", ืœื ืžืฉื ื” ืžื™ ื›ื•ืชื‘ ืื•ืชื. ืชืจืื• ืžื” ืขื•ื‘ื“ ืœื›ื ื•ืชืžืฉื™ื›ื• ืœื‘ื“ื•ืง ื›ืฉื™ื•ืฆืื™ื ืžื•ื“ืœื™ื ื—ื“ืฉื™ื.

ToCode
1 417
ื”ืžืฉื›ืชื™ ืืช ื”ื‘ื“ื™ืงื” ืขื ืคืจื•ืžืคื˜ ื™ื•ืชืจ ืืจื•ืš. ื”ืคืขื ื ืชืชื™ ืœื• ืชื™ืขื•ื“ API Docs ืฉืœ ืฉืชื™ ื”ืžื—ืœืงื•ืช ืฉื›ืชื‘ืชื™ (ืงืœื•ื“ ืขืฆืžื• ื™ืฆืจ ืืช ื”ืชื™ืขื•ื“ ื‘ืฉื™ื—ื” ืื—ืจืช ืื™ืชื•) ื•ืื– ืืช ื”ื‘ืขื™ื”. ืื ื™ ืžื–ื›ื™ืจ ืฉื‘ืคื™ืชืจื•ืŸ ืฉืœื™ ืื—ืจื™ ืฉื›ืชื‘ืชื™ ืืช ื”ืงื•ื“ ืœืฉืชื™ ื”ืžื—ืœืงื•ืช ื”ืคื™ืชืจื•ืŸ ืขืฆืžื• ืœืงื— ื‘ืขืจืš 5 ืฉื•ืจื•ืช. ื›ืžื• ืฉื—ืฉื“ืชื™ ืงืœื•ื“ ื”ืกืชื‘ืš ื‘ืขื™ืงืจ ืขื ื”ื‘ื ืช ื”ืฉืืœื” ืื‘ืœ ืชื™ืขื•ื“ ื” API ื›ืŸ ืขื–ืจ ืœื• ืœื—ืฉื•ื‘ ื•ื”ืคืขื ื”ื•ื ื”ื“ืคื™ืก ืงื•ื“ ืฉื”ื™ื” ืžืจื•ืฆื” ืžืžื ื• ืื—ืจื™ 4 ืคืขืžื™ื ื‘ืœื‘ื“. ื”ื—ื™ืกืจื•ืŸ? ื”ืงื•ื“ ืœื ืขื‘ื“ ื•ื”ื“ืคื™ืก 0. ื–ื” ืžื” ืฉืงืœื•ื“ ื”ื“ืคื™ืก:
Point = Data.define(:x, :y) do
  def manhattan_distance(other)
    [
      (self.x - other.x).abs,
      (self.y - other.y).abs
    ]
  end
  
  def find_antinodes(other)
    # Calculate the differences between the two points
    dx = other.x - self.x
    dy = other.y - self.y
    
    # Create antinode points
    antinode1 = Point.new(self.x - dx, self.y - dy)
    antinode2 = Point.new(other.x + dx, other.y + dy)
    
    [antinode1, antinode2]
  end
end

class Map
  attr_reader :index_by_letter, :max_x, :max_y
  
  def initialize(input_file_name)
    @index_by_letter = Hash.new { |h, k| h[k] = [] }
    @max_x = 0
    @max_y = 0
    
    File.readlines(input_file_name).each_with_index do |line, y|
      line = line.chomp
      @max_x = [line.length - 1, @max_x].max
      @max_y = [y, @max_y].max
      
      line.chars.each_with_index do |char, x|
        unless char == '.'
          @index_by_letter[char] << Point.new(x, y)
        end
      end
    end
  end
  
  def contains(p)
    p.x >= 0 && p.x <= @max_x && p.y >= 0 && p.y <= @max_y
  end
end

def find_antinodes(map)
  antinodes = Set.new
  
  # Process each frequency (letter)
  map.index_by_letter.each do |letter, positions|
    # We need at least 2 antennas with the same frequency
    next if positions.length < 2
    
    # Check all pairs of antennas with the same frequency
    positions.combination(2).each do |p1, p2|
      # Calculate Manhattan distance components
      diff_x, diff_y = p1.manhattan_distance(p2)
      
      # Skip if the points aren't aligned (Manhattan distance check)
      next unless diff_x == 0 || diff_y == 0 || diff_x == diff_y
      
      # Calculate total Manhattan distance
      total_distance = diff_x + diff_y
      
      # Calculate distance between p1 and midpoint
      mid_x = (p1.x + p2.x) / 2.0
      mid_y = (p1.y + p2.y) / 2.0
      dist_to_mid = (p1.x - mid_x).abs + (p1.y - mid_y).abs
      
      # Check if one antenna is twice as far from the midpoint as the other
      # This is equivalent to checking if the ratio of distances is 1:2
      next unless (total_distance % 3 == 0)
      
      # Calculate antinodes
      antinode1, antinode2 = p1.find_antinodes(p2)
      
      # Add antinodes if they're within map bounds
      antinodes.add(antinode1) if map.contains(antinode1)
      antinodes.add(antinode2) if map.contains(antinode2)
    end
  end
  
  antinodes.size
end

map = Map.new("input.txt")
puts find_antinodes(map)
ื ื™ืกื™ื•ืŸ 3 - ืงื•ื“ ื”ืžื—ืœืงื•ืช ืขืฆืžืŸ ืคื” ื”ื‘ื ืชื™ ืฉ API Docs ื–ื” ืื•ืœื™ ืœื ื”ื“ืจืš ื”ื›ื™ ื˜ื•ื‘ื” ืœืขื•ื“ื“ ืืช ืงืœื•ื“ ืœืขื‘ื•ื“ ื•ื”ืœื›ืชื™ ืœื ืกื•ืช ื›ื™ื•ื•ืŸ ืื—ืจ ื•ื”ื“ื‘ืงืชื™ ืœืงืœื•ื“ ืืช ื”ืงื•ื“ ื”ืžืœื ืฉืœ ืฉืชื™ ื”ืžื—ืœืงื•ืช Map ื• Point. ื”ืคืขื ืงืœื•ื“ ื›ืชื‘ ื•ืžื—ืง 8 ืคื™ืชืจื•ื ื•ืช ื•ืจืง ื‘ืชืฉื™ืขื™ ื”ื•ื ืขืฆืจ ื•ื”ื›ืจื™ื– ืฉื”ืคื™ืชืจื•ืŸ ืขื•ื‘ื“ ื ื›ื•ืŸ. ื”ื•ื ืฆื“ืง. ืœืžืจื•ืช ื”ืื•ืจืš ื”ืคื™ืชืจื•ืŸ ืžืฆื™ื’ ืืช ื”ืชืฉื•ื‘ื” ื”ื ื›ื•ื ื”:
* Solution for the Easter Bunny antenna problem *

* Load the map *
map = Map.new('input.txt')

* Track unique antinode locations using a hash for O(1) lookup *
antinode_locations = {}

* For each frequency *
map.index_by_letter.each do |freq, antennas|
  # Skip if there's only one antenna with this frequency
  next if antennas.length < 2
  
  # Process each pair of antennas with the same frequency
  antennas.combination(2) do |p1, p2|
    # The find_antinodes method calculates potential antinode points
    # based on the relative positions of p1 and p2
    antinode1, antinode2 = p1.find_antinodes(p2)
    
    # Check both potential antinodes
    [antinode1, antinode2].each do |node|
      # Skip if the node is outside the map boundaries

ToCode
1 417
ื ื™ืกื•ื™ Advent Of Code ื™ื•ื 8 ื•ืงืœื•ื“ ืื—ืจื™ ืฉืคืชืจืชื™ ืืช ื”ื—ืœืง ื”ืจืืฉื•ืŸ ืฉืœ ื™ื•ื 8 ืฉืœ Advent Of Code ื•ืœืคื ื™ ื”ืกื™ื‘ื•ืš ืฉืœ ื”ื—ืœืง ื”ืฉื ื™ ืจืฆื™ืชื™ ืœื ืฆืœ ืืช ื”ื ื™ืกื•ื—ื™ื ื”ืžื‘ืœื‘ืœื™ื ืฉืœ ืืจื™ืง ื•ื•ืกื˜ืœ ื›ื“ื™ ืœื‘ืขื•ื˜ ืงืฆืช ื‘ืงืœื•ื“ ื•ื ืชืชื™ ืœื• ืœืคืชื•ืจ ืืช ืื•ืชื• ืชืจื’ื™ืœ ื‘ืฉืœื•ืฉ ื’ื™ืฉื•ืช ืฉื•ื ื•ืช. ื”ืืชื’ืจ ื”ืชืจื’ื™ืœ ื‘ื’ื“ื•ืœ ืœื ืžืกื•ื‘ืš ืื‘ืœ ื›ืŸ ืžื ื•ืกื— ื‘ืฆื•ืจื” ืžืื•ื“ ืžืขื™ื™ืคืช. ื™ืฉ ืœื ื• ืžื˜ืจื™ืฆื” ืขื ืื ื˜ื ื•ืช:
............
........0...
.....0......
.......0....
....0.......
......A.....
............
............
........A...
.........A..
............
............
ื ืงื•ื“ื” ืžืกืžื ืช ืžืงื•ื ืจื™ืง ื•ื›ืœ ืชื• ืื—ืจ ืžืกืžืŸ ืื ื˜ื ื”. ืœื›ืœ ืื ื˜ื ื” ื™ืฉ ืชื“ื™ืจื•ืช ืฉื–ื” ื”ืชื• ืฉืžื•ืคื™ืข ื‘ื”, ื›ืš ืฉื™ืฉ ืœื ื• ื‘ื“ื•ื’ืžื” 3 ืื ื˜ื ื•ืช ื‘ืชื“ื™ืจื•ืช A ื•ืขื•ื“ 4 ืื ื˜ื ื•ืช ื‘ืชื“ื™ืจื•ืช 0. ื›ืœ ืฉืชื™ ืื ื˜ื ื•ืช ืขื ืื•ืชื” ืชื“ื™ืจื•ืช ื™ื•ืฆืจื•ืช ื”ืชื ื’ืฉื•ืช ืฉื ืงืจืืช Antinode ื‘ืฉื ื™ ื”ืฆื“ื“ื™ื ืฉืœ ื”ืงื•. ื”ื•ื ื”ืžื—ื™ืฉ ืืช ื”ืกื™ืคื•ืจ ืขื ื”ืื™ื•ืจ ื”ืงื˜ืŸ ื”ื–ื”:
..........
...#......
..........
....a.....
..........
.....a....
..........
......#...
..........
..........
ืื– ืื ื—ื ื• ืจื•ืื™ื ืฉืฉื ื™ ื” a-ื™ื ื”ืงื˜ื ื™ื ืžืชื ื’ืฉื™ื ื•ื™ื•ืฆืจื™ื ืงื•, ื•ืื– ืžืืจื™ื›ื™ื ืืช ื”ืงื• ืงืฆืช ืœื›ืœ ืฆื“ ื•ืžืงื‘ืœื™ื ืฉืชื™ ื ืงื•ื“ื•ืช ื—ื“ืฉื•ืช ืฉื”ืŸ ื” Antinodes, ืžืกื•ืžื ื•ืช ื‘ืกื•ืœืžื™ื•ืช. ื”ืืชื’ืจ ื”ื•ื ืœืžืฆื•ื ืืช ื›ืœ ื”ื ืงื•ื“ื•ืช ื‘ืžืคื” ื‘ื”ืŸ ื™ืฉ Antinode, ื›ืฉืฆืจื™ืš ืœืฉื™ื ืœื‘ ืฉืื ื™ืฉ 3 ืื ื˜ื ื•ืช ื‘ืืชื” ืชื“ื™ืจื•ืช ืื– ื›ืœ 2 ืžื”ืŸ ื™ื™ืฆืจื• Antinode. ื”ืคื™ืชืจื•ืŸ ืฉืœื™ ืœืชืจื’ื™ืœ ื‘ืฉืคืช ืจื•ื‘ื™ ื”ื•ื:
* frozen_string_literal: true *

Point = Data.define(:x, :y) do
  def manhattan_distance(other)
    [(x - other.x).abs, (y - other.y).abs]
  end

  def find_antinodes(other)
    diff_x, diff_y = manhattan_distance(other)
    if x < other.x
      if y < other.y
        # p1 is to the left and above p2
        antinode1 = Point.new(x - diff_x, y - diff_y)
        antinode2 = Point.new(other.x + diff_x, other.y + diff_y)
      else
        # p1 is to the left and below p2
        antinode1 = Point.new(x - diff_x, y + diff_y)
        antinode2 = Point.new(other.x + diff_x, other.y - diff_y)
      end
    else
      if y < other.y
        # p1 is to the right and above p2
        antinode1 = Point.new(x + diff_x, y - diff_y)
        antinode2 = Point.new(other.x - diff_x, other.y + diff_y)
      else
        # p1 is to the right and below p2
        antinode1 = Point.new(x + diff_x, y + diff_y)
        antinode2 = Point.new(other.x - diff_x, other.y - diff_y)
      end
    end

    [antinode1, antinode2]
  end
end

class Map
  attr_accessor :matrix, :index_by_letter, :max_x, :may_y
  def initialize(input_file_name)
    @index_by_letter = Hash.new { |h, k| h[k] = [] }
    @max_x = 0
    @max_y = 0
    File.read(input_file_name).lines.each_with_index.flat_map do |line, line_index|
      line.chomp.split('').each_with_index.map do |char, column_index|
        pos = Point.new(column_index, line_index) 
        @max_y = line_index if line_index > @max_y
        @max_x = column_index if column_index > @max_x
        @index_by_letter[char] << pos if char != '.'
      end
    end
  end

  def contains(p)
    p.x <= @max_x && p.x >= 0 && p.y <= @max_y && p.y >= 0
  end
end

m = Map.new('input.txt')

antinodes = m.index_by_letter.flat_map do |_char, positions|
  positions.combination(2).flat_map { |p1, p2| p1.find_antinodes(p2) }
end


puts antinodes.filter { |p| m.contains(p) }.uniq.count
ืขื›ืฉื™ื• ืœื ื™ืกื•ื™ ืขื ืงืœื•ื“. ื ื™ืกื™ื•ืŸ ืจืืฉื•ืŸ - ืจืง ื”ื‘ืขื™ื” ื”ืชื—ืœืชื™ ืืช ื”ื ื™ืกื•ื™ ืขื ื”ืคืจื•ืžืคื˜ ื”ื‘ื:
Solve the following general problem in Ruby (input is saved in file input.txt)
ืื—ืจื™ื• ื”ื“ื‘ืงืชื™ ืคืฉื•ื˜ ืืช ื›ืœ ืขืžื•ื“ ื”ืชื™ืื•ืจ ืฉืœ ื”ื‘ืขื™ื” ืž Advent Of Code: https://adventofcode.com/2024/day/8 ืขื›ืฉื™ื• ืงืœื•ื“ ื”ื•ื ืžืขื ื™ื™ืŸ ื›ื™ ื”ื•ื ืžื“ืคื™ืก ืงื•ื“ ื•ืื– ื‘ื•ื“ืง ืืช ืขืฆืžื• ื•ืžืจื’ื™ืฉ ืฉื”ื•ื ืœื ืขืฉื” ืขื‘ื•ื“ื” ืžืกืคื™ืง ื˜ื•ื‘ื” ื•ืื– ืžื“ืคื™ืก ืขื•ื“ ื’ื™ืจืกื” ื•ื›ื›ื” ื‘ืœื•ืœืื” ืขื“ ืฉื”ื•ื ืžืจื•ืฆื”. ื‘ืคืจื•ืžืคื˜ ื”ื–ื” ืœืงื— ืœื• 6 ื ื™ืกื™ื•ื ื•ืช ื•ื‘ืกื•ืฃ ื”ื•ื ื”ื’ื™ืข ืœืคื™ืชืจื•ืŸ ืขื•ื‘ื“. ื ื™ืกื•ื™ ืฉื ื™ - ื“ื—ื™ืคื” ืงืœื” ืขื API Docs

ToCode
1 417
ืžื–ืœ ื˜ื•ื‘, ืงื™ื‘ืœืช ืงื™ื“ื•ื! ื›ืœ ืžื™ ืฉื ื™ื”ืœ ืคืขื™ืœื•ืช Outsource ืžื›ื™ืจ ืืช ื”ืืชื’ืจ - ืœื”ื‘ื™ืŸ ืžื” ืœืชืช ืœืžืคืชื—ื™ื ืฉื‘ื—ื•ืฅ, ืื™ืš ืœื•ื•ื“ื ืืช ืื™ื›ื•ืช ื”ืชื•ืฆืจ, ืžื” ื™ื”ื™ื” ืžืžืฉืง ื”ืขื‘ื•ื“ื” ืžื•ืœื, ื•ื”ื›ื™ ื—ืฉื•ื‘, ืื™ื–ื” ื”ื—ืœื˜ื•ืช ื”ื ื™ื›ื•ืœื™ื ืœืงื‘ืœ ืœื‘ื“ ื•ืื™ื–ื” ื”ื—ืœื˜ื•ืช ื—ื™ื™ื‘ ืœืงื‘ืœ ืžื™ืฉื”ื• ืžื‘ืคื ื™ื. ืื—ืจื™ ื™ื•ื ืขื GPT4.1 ื‘ Cursor ื‘ืจื•ืจ ืœื’ืžืจื™ ืฉื–ืืช ื”ืžืฆื™ืื•ืช ืฉืœ ื›ื•ืœื ื•. ื” AI ื™ื›ื•ืœ ืœื›ืชื•ื‘ ื›ืœ ืงื•ื“ ืฉื ื™ืชืŸ ืœื• ื‘ืจืžื” ืกื‘ื™ืจื”, ืื‘ืœ ืœืื•ืจืš ื–ืžืŸ ืื ืชืชื ื• ืœื• ืœื›ืชื•ื‘ ืžืกืคื™ืง ืงื•ื“ ื”ื•ื ื™ื”ืคื•ืš ืืช ื”ืžืขืจื›ืช ืœื‘ืœืชื™ ื ื™ืชื ืช ืœืชื—ื–ื•ืงื”, ื›ื™ ื”ื•ื ืจื•ืื” ืชืžื™ื“ ืจืง ืืช ื”ืžื™ืœื” ื”ื‘ืื” ื•ืœื ืืช ื”ืชืžื•ื ื” ื”ื’ื“ื•ืœื”. ืขื›ืฉื™ื• ืืชื - ืื™ื–ื” ื”ื—ืœื˜ื•ืช ืืชื ืžืชืขืงืฉื™ื ืœืงื‘ืœ ืœื‘ื“? ืขืœ ืžื” ืืชื ืœื ืžื•ื›ื ื™ื ืœื”ืชืคืฉืจ? ื•ืžื” ื™ื™ืฉืืจ ืกื™ืžืŸ ื”ื”ื™ื›ืจ ืฉืœื›ื ื‘ืงื•ื“ ืฉื” AI ืฉืœื›ื ื™ื›ืชื•ื‘?

ToCode
1 417
ืœืžื™ ืื›ืคืช ืฉ null ื”ื•ื ืื•ื‘ื™ืงื˜? ืืžื’'ื“ ืžืกื“, ื”ืžื™ื™ืกื“ ืฉืœ ืจืคืœื™ื˜, ืฆื™ื™ืฅ ืœืื—ืจื•ื ื”: > I no longer think you should learn to code. ื‘ื”ืžืฉืš ืœืชื’ื•ื‘ื•ืช ื”ื•ื ืžืคืจื˜ ื•ืžืจื—ื™ื‘ ืืช ื”ืจืขื™ื•ืŸ, ื•ืžืกื‘ื™ืจ ืฉื”ื•ื ืขื“ื™ื™ืŸ ื—ื•ืฉื‘ ืฉื™ืฉ ืžืงื•ื ืœืžื”ื ื“ืกื™ ืชื•ื›ื ื”, ืื‘ืœ ืงื™ื“ื•ื“ ื™ื”ื™ื” ืžื™ื•ืชืจ. ื‘ืฆื™ื•ืฅ ื”ืžืฉืš ื”ื•ื ื”ืกื‘ื™ืจ ืฉืฆืจื™ืš ืœื“ืขืช ืื™ืš ื“ื‘ืจื™ื ื’ื“ื•ืœื™ื ืžืชื—ื‘ืจื™ื ื™ื—ื“ ืื‘ืœ ืื™ืŸ ืฆื•ืจืš ืœื“ืขืช ืฉ null ื”ื•ื ืื•ื‘ื™ืงื˜ ื‘ JavaScript. ื›ืžื” ืžื—ืฉื‘ื•ืช ืขืœ ื–ื”- 1. ืžืกืคืจื™ื ื‘ืจื ื“ื•ืŸ ืื™ื™ ื›ืชื‘ ืืช JavaScript ื‘ืขืฉืจื” ื™ืžื™ื ื‘ 1995. ืื ื™ ืžื“ืžื™ื™ืŸ ืฉื”ืจื‘ื” ืžื”ืจืขื™ื•ื ื•ืช ื”ื™ื• ืœื• ื‘ืจืืฉ ืœืคื ื™ ืขืฉืจืช ื”ื™ืžื™ื ื”ืืœื”, ืื‘ืœ ื”ื–ืžืŸ ื‘ืืžืช ืคื—ื•ืช ืžืฉื ื”. ืžื” ืฉื›ืŸ ืžืฉื ื” ื–ื” ืฉืขื‘ื•ืจ ื‘ืจื ื“ื•ืŸ ืื™ื™ ืฉืœ 1995 ื”ืฉืืœื” ืื null ืฆืจื™ืš ืœื”ื™ื•ืช ืื•ื‘ื™ืงื˜ ืื• ืœื ื”ื™ืชื” ืฉืืœื” ืžื”ื•ืชื™ืช. ื”ื™ื• ืฉื™ืงื•ืœื™ื ื˜ื•ื‘ื™ื ืœื›ืืŸ ื•ืœื›ืืŸ ื•ื‘ืกื•ืคื• ืฉืœ ื“ื‘ืจ ื–ืืช ื”ื™ืชื” ื”ื—ืœื˜ื” ืฉื”ืชืงื‘ืœื”, ื™ื—ื“ ืขื ืขื•ื“ ืžืื•ืช ื”ื—ืœื˜ื•ืช ืงื˜ื ื•ืช, ื›ืœ ืื—ืช ืขื ื™ืชืจื•ื ื•ืช ื•ื—ืกืจื•ื ื•ืช ืžืฉืœื”, ืฉื‘ื ื• ื™ื—ื“ ืืช ื”ืื•ืคื™ ืฉืœ ื”ืฉืคื”. 2. ืžื”ื ื“ืกื™ ื”ืชื•ื›ื ื” ืฉืืžื’'ื“ ื™ืฆื˜ืจืš ื”ื ื‘ื“ื™ื•ืง ืื ืฉื™ื ืฉืืžื•ืจื™ื ืœื“ืขืช ืœืงื‘ืœ ื”ื—ืœื˜ื•ืช ืงืฉื•ืช. ื”ื ืื ืฉื™ื ื™ืฆื™ืจืชื™ื™ื, ืฉืžื›ื™ืจื™ื ืืช ื”ืžืขืจื›ืช, ืืช ื”ืื™ืœื•ืฆื™ื ืฉืœื”, ืืช ื”ื”ื™ื‘ื˜ื™ื ื”ื˜ื›ื ื™ื™ื ื‘ืžื™ืžื•ืฉ ื›ืœ ืžื ื’ื ื•ืŸ ื•ืืช ื”ื™ืชืจื•ื ื•ืช ื•ื”ื—ืกืจื•ื ื•ืช ืฉืœ ื›ืœ ื‘ื—ื™ืจื”. ื”ื ื”ืื ืฉื™ื ืฉืฆืจื™ื›ื™ื ืœื—ื‘ืจ ื‘ื™ืŸ ื”ื’ื“ืจืช ื”ื“ืจื™ืฉื•ืช ืœื‘ื™ืŸ ืงื™ื“ื•ื“ ื”ืžืขืจื›ืช, ื•ื’ื ืื ื”ื ืœื ื™ื›ืชื‘ื• ื‘ืขืฆืžื ืืช ื”ืงื•ื“ ืืœื "ืจืง" ื™ื’ื“ื™ืจื• ืœ AI ืื™ื–ื” ืงื•ื“ ืœื›ืชื•ื‘, ื”ื ืขื“ื™ื™ืŸ ื™ืฆื˜ืจื›ื• ืœื”ื™ื•ืช ืžืื•ื“ ืžืงืฆื•ืขื™ื™ื ื›ื“ื™ ืฉื” AI ื™ื›ืชื•ื‘ ืืช ื”ืงื•ื“ ื”ื ื›ื•ืŸ ืขื‘ื•ืจ ื”ืžืขืจื›ืช ื”ืกืคืฆื™ืคื™ืช ืฉืœื”ื. 3. ืืžื’'ื“, ื•ื‘ื›ื™ืจื™ื ืจื‘ื™ื ื ื•ืกืคื™ื ื›ืŸ ื—ื•ืฉื‘ื™ื ืฉื”ื ื“ืกืช ืชื•ื›ื ื” ื”ื™ื ื“ื‘ืจ ื—ืฉื•ื‘. ื”ื ื” ืขื•ื“ ืฆื™ื•ืฅ ื”ืคืขื ืฉืœ Pratik Kotkar ืฉืงื™ื‘ืœ ื”ืกื›ืžื” ืžืืžื’'ื“ ื‘ืื•ืชื• ื“ื™ื•ืŸ: > this doesnโ€™t mean engineering is obsolete. The engineering approach to solving problems is now even more crucial to make best use of AI tools. the paradigm of what the focus of engineering just changes from syntax and semantics to problem solving 4. ืขื›ืฉื™ื• ืœืฉืืœื•ืช - ืื™ืš ืœื•ืžื“ื™ื Problem Solving ื‘ื”ื ื“ืกืช ืชื•ื›ื ื”? ืื™ืš ืžืชืืžื ื™ื ืขืœ ืื•ืชืŸ ื”ืžื™ื•ืžื ื•ื™ื•ืช ืฉื™ื”ืคื›ื• ืื•ืชื ื• ืœืžื”ื ื“ืกื™ื ื”ื˜ื•ื‘ื™ื ืฉืœ ื”ืขืชื™ื“? ื”ืื ืœื ืกื‘ื™ืจ ืœื—ืฉื•ื‘ ืฉื”ืฉื™ืงื•ืœื™ื ืฉืœ ื‘ืจื ื“ื•ืŸ ืื™ื™ ื‘ 1995 ื™ื›ื•ืœื™ื ืœืœืžื“ ืื•ืชื ื• ืขืœ ืคื™ืชืจื•ืŸ ื‘ืขื™ื•ืช ื•ื”ื ื“ืกืช ืชื•ื›ื ื”? ืื•ืœื™ ืืคื™ืœื• ื™ื•ืชืจ ืžื‘ื ื™ื™ืช ืขื•ื“ ืžืขืจื›ืช SaaS ? 5. ื•ืื•ืœื™ ืื•ืชื ืžื”ื ื“ืกื™ื ืฉืœ ื”ืขืชื™ื“, ืฉื™ื•ื“ืขื™ื ืœืคืชื•ืจ ื‘ืขื™ื•ืช ื•ืžื‘ื™ื ื™ื ืืช ื”ืžื’ื‘ืœื•ืช ื•ื”ืื™ืœื•ืฆื™ื ื”ื˜ื›ื ื™ื™ื ื•ื’ื ืืช ื”ื”ื–ื“ืžื ื•ื™ื•ืช ืฉืœ ื”ื˜ื›ื ื•ืœื•ื’ื™ื”, ื”ื ื‘ืขืฆื ืื•ืชื ืื ืฉื™ื ืฉืœืžื“ื• ืœืขื•ืžืง ืื™ืš ืงื•ื“ ืขื•ื‘ื“? 6. ื›ืฉืžื™ืฉื”ื• ืžืฆื™ืข ืœื”ืชืžืงื“ ื‘"ื”ื‘ื ื”" ื•ื‘"ืคื™ืชืจื•ืŸ ื‘ืขื™ื•ืช" ื•ืœื“ืœื’ ืขืœ ื”ืงื™ื“ื•ื“, ืื ื™ ืžืจื’ื™ืฉ ื›ืื™ืœื• ื”ื•ื ืžืฆื™ืข ืœื™ ืœืœืžื•ื“ ื“ืงื“ื•ืง ืฉืœ ืฉืคื” ื‘ืœื™ ืœืœืžื•ื“ ืื™ืš ืœื“ื‘ืจ ื‘ื”. ืื ื™ ืœื ื‘ื˜ื•ื— ืฉื–ื” ืืคืฉืจื™. ื .ื‘. ืงืจื™ืื” ืžืขื ื™ื™ื ืช ืœื’ื‘ื™ null ื‘ JavaScript (ืชื•ืจื’ื ืžืงื•ืจื™ืื ื™ืช ืขืœ ื™ื“ื™ AI) https://witch.work/en/posts/javascript-why-typeof-null-is-object

ToCode
1 417
ืžืงื•ืžืคื•ื ื ื˜ื” ืงื˜ื ื” ื•ืงืœื” ืœืชื—ื–ื•ืงื” ืงื™ื‘ืœืชื™ ืžืคืœืฆืช, ื•ื”ื›ื™ ื’ืจื•ืข ืœืžืจื•ืช ืฉื‘ื˜ืงืกื˜ ื”ื•ื ื“ื™ื‘ืจ ืขืœ field-sizing ื”ื•ื ืœื ื”ืฉืชืžืฉ ื‘ื• ื‘ืคื™ืชืจื•ืŸ ื•ื ืฉืืจ ืขื ืœื•ื’ื™ืงืช ื”ืืคืงื˜. ืขื›ืฉื™ื• ืื ื™ ืžื›ื™ืจ ืืช ื”ืชื™ืื•ืจื™ื” ืฉืื ืจืง ื ื™ืชืŸ ืœ AI ืœื›ืชื•ื‘ ืืช ื”ืงื•ื“ ื”ื ื•ืจืื™ ืฉื”ื•ื ืจื’ื™ืœ ืœื›ืชื•ื‘ ืื– ื”ื•ื ื™ื•ื›ืœ ืœืชื—ื–ืง ืืช ื”ืงื•ื“ ืžืงืฆื” ืœืงืฆื” ื•ืื ื—ื ื• ื ืฉื‘ ืœืฉืชื•ืช ืงืคื” ื‘ื–ืจื™ื—ื”. ืขื“ื™ื™ืŸ ืœื ืจืื™ืชื™ ื”ื•ื›ื—ื•ืช ืœื–ื”, ืื ื›ื‘ืจ ืžื” ืฉื›ืŸ ืจืื™ืชื™ ื–ื” ืฉื›ืฉืื ื™ ื ื•ืชืŸ ืœ AI ืœืขื–ื•ืจ ืœื™ ื‘ืงื•ื“ ืคืฉื•ื˜ ืฉื’ื ืื ื™ ื™ื›ื•ืœ ืœื›ืชื•ื‘ ื”ื•ื ืžืฆืœื™ื— ืœื–ื”ื•ืช ื‘ืขื™ื•ืช ื•ืœื”ืฆื™ืข ืชื™ืงื•ื ื™ื ื—ื›ืžื™ื, ืื‘ืœ ื›ื›ืœ ืฉื”ืงื•ื“ ื™ื•ืชืจ ืืจื•ืš ื›ื›ื” ื’ื ืœ AI ื™ื•ืชืจ ืงืฉื” ืœื”ื™ืฉืืจ ืžืจื•ื›ื–. ื‘ืžื™ืœื™ื ืื—ืจื•ืช ืงื™ื‘ืœืชื™ ื‘ื™ืฆื•ืขื™ื ื˜ื•ื‘ื™ื ื™ื•ืชืจ ืื‘ืœ ื‘ืžื—ื™ืจ ืฉืœ ืงื•ื“ ื”ืจื‘ื” ื™ื•ืชืจ ืงืฉื” ืœืชื—ื–ื•ืงื” (ื’ื ืœืื ืฉื™ื ื•ื’ื ืœื‘ื•ื˜ื™ื). ื˜ื™ื™ืง 3 - ืฉื ื™ ืคืจื•ืžืคื˜ื™ื ื‘ื ื™ืกื™ื•ืŸ ืฉืœื™ืฉื™ ืื ื™ ืจื•ืฆื” ืœื›ื•ื•ืŸ ืืช ื” AI ืœื ื•ืฉื ื”ื‘ื™ืฆื•ืขื™ื ื•ืœืชืช ืœื• ืœื”ื‘ื™ืŸ ืฉื™ืฉ ื›ืžื” ื“ืจื›ื™ื ื›ื“ื™ ืœื“ื—ื•ืฃ ืื•ืชื• ืœื›ื™ื•ื•ืŸ ืคื™ืชืจื•ืŸ ื‘ CSS. ืื ื™ ืžืชื—ื™ืœ ืขื:
Code review the following component. Focus on performance. Only explain the problematic points without suggesting fixes.

Consider the larger picture. If there is a simpler way to achieve the same goal please point me to it, but don't implement yet any fixed version.

const ResizingTextArea = ({
  value,
}) => {
  const ref = useRef(null);
    React.useEffect(() => {
    if (!ref.current) return;

    ref.current.style.height = "inherit";
    ref.current.style.height = \${ref.current.scrollHeight}px\;
  }, [value]);

  return (
    <textarea ref={ref} value={value}></textarea>
  )
}
ื”ืคืขื ืื ื™ ืžืงื‘ืœ ื”ืกื‘ืจ ืฉืœ ื”ื ืงื•ื“ื•ืช ื”ื‘ืขื™ื™ืชื™ื•ืช ืฉืžืกืชื™ื™ื ื‘ืคื™ืกืงื” > There is a modern, potentially simpler, and more performant approach to achieve self-sizing textareas that relies primarily on CSS, minimizing or eliminating the need for JavaScript-based height calculations on every input change. ืื ื™ ืžืžืฉื™ืš ืืช ื”ืฉื™ื—ื” ืขื ืคืจื•ืžืคื˜ ื ื•ืกืฃ ื•ื›ื•ืชื‘:
Implement the most simple fix for the performance issue. Use inline style if you need to add CSS. Don't add new files
ื”ืชื•ืฆืื” ื”ืคืขื:
const ResizingTextArea = ({
  value,
  // It's good practice to allow passing other props like onChange, placeholder etc.
  ...props 
}) => {

  // No more useRef or useEffect needed for resizing

  return (
    <textarea
      value={value}
      style={{
        // This CSS property instructs the browser to size the field based on its content
        fieldSizing: 'content', 
        // Optional: Prevents scrollbars from briefly appearing during resize in some browsers
        // and ensures it doesn't overflow if a max-height is also applied elsewhere.
        overflow: 'hidden', 
        // You might want to add a minHeight as well
        // minHeight: '50px', // Example minimum height
      }}
      {...props} // Spread remaining props
    />
  );
};

ืกื•ืฃ ืกื•ืฃ ื”ื•ื ืงืœืข ืขื ื” field-sizing. ื”ื•ื ื”ื•ืกื™ืฃ overflow ืฉืœื ื‘ื™ืงืฉืชื™ ื•ื’ื ืืช ื” spread ืฉืœ ื›ืœ ื”ืคืจื•ืคืก ื”ืื—ืจื™ื ืฉืฉื•ื‘ ืœื ื‘ื™ืงืฉืชื™ ื•ื”ื›ื™ ื’ืจื•ืข ืื™ื ืกื•ืฃ ื”ืขืจื•ืช ืฉืจืง ืžืงืฉื•ืช ืขืœ ื”ื”ื‘ื ื” ื•ื”ืชื—ื–ื•ืงื”, ืื‘ืœ ืื™ ืืคืฉืจ ืœืงื‘ืœ ื”ื›ืœ ื‘ื—ื™ื™ื. ืžื” ืœืžื“ื ื• ื”ื“ื•ื’ืžื” ื—ื•ืฉืคืช ืืช ืื•ืชื• ืฆื“ ืฉืœ AI ืฉืื ื—ื ื• ืื•ื”ื‘ื™ื ืœื”ืกืชื™ืจ: ื”ืงื•ื ื˜ืงืกื˜ ื”ื•ื ื”ื“ื‘ืจ ื”ื—ืฉื•ื‘. AI ืœื ืžื‘ื™ืŸ ืžื” ื—ืฉื•ื‘ ื•ืžื” ืœื ื—ืฉื•ื‘ ื‘ืžืขืจื›ืช, ื”ื•ื ื‘ืกืš ื”ื›ืœ ืžื’ื‘ืจ. ื”ื‘ื—ื™ืจื” ืฉืœื ื•: ื”ืื ืœื”ืฉืชืžืฉ ื‘ื• ื›ื“ื™ ืœื”ื™ื•ืช ื˜ื•ื‘ื™ื ื™ื•ืชืจ, ื›ืžื• ืžื•ืจื” ืคืจื˜ื™ ืฉืžืกืชื›ืœ ืขืœ ื”ืงื•ื“ ื•ื™ื•ื“ืข ืœื›ื•ื•ืŸ ืื•ืชื ื• ืœืฉื™ื˜ื•ืช ืขื‘ื•ื“ื” ื˜ื•ื‘ื•ืช ืื• ืคืฉื•ื˜ื•ืช ื™ื•ืชืจ ื•ื›ืš ืœื”ืคื•ืš ืื•ืชื ื• ืœืžืคืชื—ื™ื ื™ื•ืชืจ ืžื™ื•ืžื ื™ื; ืื• ื›ื“ื™ ืœื”ื™ื•ืช ื˜ื•ื‘ื™ื ืคื—ื•ืช, ืœื›ืชื•ื‘ ื‘ืžืงื•ืžื ื• ืงื•ื“ ืฉืœื ื”ื•ื ื•ืœื ืื ื—ื ื• ื ื•ื›ืœ ืœืงืจื•ื ืื• ืœืชื—ื–ืง ืœืื•ืจืš ื–ืžืŸ.

ToCode
1 417
<textarea ref={ref} value={value}></textarea>
  )
}
ืขื›ืฉื™ื• ื”ืคืœื˜ ื”ืจื‘ื” ื™ื•ืชืจ ื˜ื•ื‘. ื”ื•ื ืฉื ืœื‘ ืœืฉื™ืžื•ืฉ ื‘ useEffect ื‘ืžืงื•ื ื‘ useLayoutEffect, ื•ื’ื ืฉื ืœื‘ ืฉืืคืฉืจ ืœื‘ื ื•ืช ืืช ืื•ืชื• ืžื ื’ื ื•ืŸ ืขื CSS, ืื‘ืœ ืื– ื”ื•ื ื”ืฆื™ืข ืชื™ืงื•ืŸ ื•ืงืœืงืœ ืืช ื›ืœ ื”ืฉื™ื—ื”. ื–ื” ื”ืงื•ื“ ื”ืžืชื•ืงืŸ ืฉ Gemini ื”ืฆื™ืข:
import React, { useState, useRef, useLayoutEffect, useCallback } from 'react';

// Simple debounce function (or use one from lodash/underscore)
const debounce = (func, wait) => {
  let timeout;
  return function executedFunction(...args) {
    const later = () => {
      clearTimeout(timeout);
      func(...args);
    };
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
  };
};

const ResizingTextArea = ({ value, onChange, style, ...props }) => {
  const ref = useRef(null);

  // Memoize the resize function using useCallback
  const resize = useCallback(() => {
    if (ref.current) {
      // Reset height - necessary to shrink correctly
      ref.current.style.height = 'inherit';
      // Set height based on scrollHeight
      ref.current.style.height = \${ref.current.scrollHeight}px\;
    }
  }, []); // No dependencies needed if it only accesses ref.current

  // Debounce the resize function
  // Adjust the delay (e.g., 150ms) as needed
  const debouncedResize = useCallback(debounce(resize, 150), [resize]);

  // Resize on value change (debounced)
  useLayoutEffect(() => {
    // Call debounced resize. It might run immediately the first time
    // or after a delay on subsequent changes.
    debouncedResize();
    // We only want this effect to run when \value\ changes or debouncedResize changes.
  }, [value, debouncedResize]);

  // Resize on window resize (debounced)
  useLayoutEffect(() => {
    // Initial resize on mount
    resize();

    window.addEventListener('resize', debouncedResize);

    // Cleanup listener on unmount
    return () => {
      window.removeEventListener('resize', debouncedResize);
      // Optional: Cancel any pending debounced calls on unmount
      // If using lodash debounce, it often has a .cancel() method.
      // For the simple debounce above, clearing the timeout isn't
      // easily exposed without modifying the debounce function itself.
      // However, the check \if (ref.current)\ inside resize handles this.
    };
  }, [resize, debouncedResize]); // Rerun if resize functions change (shouldn't often)


  // --- Enhancements for usability ---
  // Allow parent to control the textarea fully
  const handleChange = (event) => {
    // Trigger the resize immediately on change for responsiveness *before* state update
    // Note: This might cause a slight flicker if the debounced one runs later.
    // Alternatively, rely solely on the debounced effect driven by \value\ prop change.
    // For simplicity and relying on the debounced effect: comment the next line out.
    // resize(); // Optional: Immediate resize attempt

    if (onChange) {
      onChange(event);
    }
  };

  return (
    <textarea
      ref={ref}
      value={value}
      onChange={handleChange}
      style={{
        overflow: 'hidden', // Hide scrollbar that might briefly appear
        resize: 'none',     // Prevent manual resize corner if not desired
        ...style,           // Allow passing custom styles
      }}
      rows={1} // Start with minimum rows (optional but common)
      {...props} // Pass down other props like placeholder, name, etc.
    />
  );
};

export default ResizingTextArea;

ToCode
1 417
ื‘ื•ืื• ื ืฉื›ื ืข ืืช ื’'ืžื™ื ื™ ืœืฉื™ื ืœื‘ ืœื‘ืขื™ื” ื‘ืงื•ื“ ื’'ืžื™ื ื™ 2.5 ืคืจื• ื”ื•ื ื”ืžื•ื“ืœ ื”ื›ื™ ืžืงืฆื•ืขื™ ื”ื™ื•ื (ื”ื›ืœ ื™ื›ื•ืœ ืœื”ืฉืชื ื•ืช ืžื—ืจ) ื•ืœืžืจื•ืช, ื•ืื•ืœื™ ืขื ื›ืœ ื”ื™ื›ื•ืœื•ืช ืฉืœื•, ื‘ืœื™ ื”ื ื—ื™ื” ื ื›ื•ื ื” ื”ื•ื ืขืœื•ืœ ืœืคืกืคืก ื“ื‘ืจื™ื ื—ืฉื•ื‘ื™ื. ื‘ื ื™ืกื•ื™ ื”ื™ื•ื ืื ื™ ืœื•ืงื— ืงื˜ืข ืงื•ื“ ืฉืžืฆืืชื™ ืืชืžื•ืœ ื‘ื’ืืžืจื•ื“ ื•ืžื ืกื” ืœืฉื›ื ืข ืืช ื’'ืžื™ื ื™ ืœืฉื™ื ืœื‘ ืœื‘ืขื™ื™ืช ื‘ื™ืฆื•ืขื™ื ื•ืœื”ืฆื™ืข ืชื™ืงื•ืŸ ืžื—ื•ืฅ ืœืงื•ืคืกื”. ื˜ื™ื™ืง 1 - Code Review ื”ืงื•ื“ ืฉืžืขื ื™ื™ืŸ ืื•ืชื™ ื”ื•ื ื”ืงื•ืžืคื•ื ื ื˜ื” CommentTextarea ืฉืžื•ื’ื“ืจืช ื‘ืงื•ื‘ืฅ: https://github.com/antiwork/gumroad/blob/main/app/javascript/components/Post/PostCommentsSection.tsx ื™ืฉ ืฉื ืฉื™ืžื•ืฉ ืœื ืื™ื“ืืœื™ ื‘ useEffect ืฉืคื•ื’ืข ื‘ื‘ื™ืฆื•ืขื™ื ื•ืžืฉื ื” ืืช ืžืืคื™ื™ืŸ ื”ื’ื•ื‘ื” ื›ืœ ืคืขื ืฉื”ืชื•ื›ืŸ ืžืฉืชื ื” ืœืคื™ ื’ื•ื“ืœ ื’ื•ื‘ื” ื”ืชื•ื›ืŸ. ื‘ื“ืจืš ื›ืœืœ ืขื“ื›ื•ื ื™ ื’ื•ื‘ื” ื›ืืœื” ืฆืจื™ื›ื™ื ืœื”ื™ื•ืช ื‘ useLayoutEffect, ื•ื™ื•ืชืจ ืžื–ื” ื›ืฉืžื“ื•ื‘ืจ ื‘ textarea ื™ืฉ ืžืืคื™ื™ืŸ CSS ื‘ืฉื field-sizing ืฉื’ื•ืจื ืœ textarea ืœื’ื“ื•ืœ ืื•ื˜ื•ืžื˜ื™ืช ืœืคื™ ื’ื•ื“ืœ ื”ืชื•ื›ืŸ. ื”ื™ื™ืชื™ ืจื•ืฆื” ืฉ AI ื™ื–ื”ื” ืืช ื”ื‘ืขื™ื” ื•ื™ืฆื™ืข ืืช ื”ืชื™ืงื•ืŸ ื”ื ื›ื•ืŸ ื‘ืขื–ืจืช CSS, ื•ื’ื ื™ืฉืœื— ืื•ืชื™ ืœืงืจื•ื ืขืœ ื”ืงืฉืจ ื‘ื™ืŸ useEffect ืœื‘ื™ืฆื•ืขื™ื ื•ืœืžื” ืœื ื›ื“ืื™ ืœื”ืฉืชืžืฉ ื‘ืžื‘ื ื” ื–ื” ื›ื“ื™ ืฉืืœืžื“ ืœืคืขื ื”ื‘ืื”. ื”ื ื™ืกื™ื•ืŸ ื”ืจืืฉื•ืŸ ืฉืœื™ ื”ื™ื” ืœื”ื“ื‘ื™ืง ืืช ื›ืœ ื”ืงื•ื“ ืœื’'ืžื™ื ื™ ื•ืœื‘ืงืฉ Code Review. ื–ื” ื”ื™ื” ื”ืคืจื•ืžืคื˜:
const CommentTextarea = ({
  children,
  showAvatar = true,
  ...props
}: React.ComponentProps<"textarea"> & { showAvatar?: boolean }) => {
  const appDomain = useAppDomain();
  const { purchase_id } = useCommentsMetadata();
  const loggedInUser = useLoggedInUser();
  const ref = React.useRef<HTMLTextAreaElement | null>(null);
  React.useEffect(() => {
    if (!ref.current) return;

    ref.current.style.height = "inherit";
    ref.current.style.height = \${ref.current.scrollHeight}px\;
  }, [props.value]);

  return (
    <div className={cx({ comment: showAvatar })} style={showAvatar ? {} : { display: "grid", gap: "var(--spacer-3)" }}>
      {showAvatar ? (
        <img className="user-avatar" alt="Current user avatar" src={loggedInUser?.avatarUrl ?? defaultUserAvatar} />
      ) : null}
      {loggedInUser || purchase_id ? (
        <textarea ref={ref} rows={1} placeholder="Write a comment" {...props} />
      ) : (
        <div>
          <a href={Routes.login_url({ host: appDomain })}>Log in</a> or{" "}
          <a href={Routes.signup_url({ host: appDomain })}>Register</a> to join the conversation
        </div>
      )}
      {loggedInUser != null || purchase_id != null ? (
        <div style={{ display: "grid", justifyContent: "end", gap: "var(--spacer-3)", gridAutoFlow: "column" }}>
          {children}
        </div>
      ) : null}
    </div>
  );
};
ื”ืคื™ื“ื‘ืง ื”ื™ื” ืืจื•ืš ื•ืžืชื—ืฉื‘ ื•ื”ืกื‘ื™ืจ ืœื™ ื”ืžื•ืŸ ื“ื‘ืจื™ื ืœื’ื‘ื™ ื”ืงื•ื“. ื‘ืชื•ืš ื”ื˜ืงืกื˜ ื”ืื™ื ืกื•ืคื™ ื”ื•ื ื”ืชื™ื—ืก ืœ useEffect ื‘ืื•ืคืŸ ื”ื‘ื:
Auto-Resizing useEffect:

Efficiency: The effect runs on every change to props.value (i.e., every keystroke). While often fine, for very complex components or extremely rapid typing, this could potentially lead to slight performance hiccups (though usually negligible). Debouncing is an option if performance becomes an issue, but adds complexity.

Initial Render: Ensure the initial height calculation works as expected when the component mounts and props.value might be empty or undefined. The rows={1} attribute helps set a minimum size initially.

CSS box-sizing: The accuracy of scrollHeight can be affected by CSS properties like padding and box-sizing. Ensure your CSS accounts for this (box-sizing: border-box is recommended).
ื”ื”ืฆืขื” ืฉืœื•, ืœืžืจื•ืช ืฉื ืจืื™ืช ื”ื’ื™ื•ื ื™ืช, ื”ื™ื ืœื ื”ืคื™ืชืจื•ืŸ ื”ื ื›ื•ืŸ ื•ื’ื ืื™ืŸ ืคื” ื”ื‘ื ื” ืžื“ื•ื™ืงืช ืฉืœ ื”ื‘ืขื™ื”. ื˜ื™ื™ืง 2 - ืงื•ืžืคื•ื ื ื˜ื” ืงื˜ื ื” ื•ืคื•ืงื•ืก ืขืœ ื‘ื™ืฆื•ืขื™ื ื›ืชื‘ืชื™ ื’ื™ืจืกื” ืžื•ืงื˜ื ืช ืฉืœ ื”ืงื•ืžืคื•ื ื ื˜ื” ื‘ืคืœื™ื™ื’ืจืื•ื ื“ ื•ื ื™ืกื™ืชื™ ืฉื•ื‘, ื”ืคืขื ืขื ืคื•ืงื•ืก ืขืœ ื‘ื™ืฆื•ืขื™ื:
code review the following component with focus on performance:

const ResizingTextArea = ({
  value,
}) => {
  const ref = useRef(null);
    React.useEffect(() => {
    if (!ref.current) return;

    ref.current.style.height = "inherit";
    ref.current.style.height = \${ref.current.scrollHeight}px\;
  }, [value]);

  return (