Labels: medium-difficulty, yul, math, gasguard
Difficulty: Medium
Module: contracts/math/
🧠 Concept
Build an assembly algorithm (Find First Set / De Bruijn multiplication approach) in Yul to locate the position of the most significant bit (MSB) or least significant bit (LSB) in a uint256 word.
⚠️ Problem
Finding bit indices using high-level while loops iterates byte-by-byte or bit-by-bit, consuming high execution gas on large numbers.
📁 Implementation Scope
contracts/math/YulBitSearch.sol
test/math/YulBitSearch.test.ts
🛠️ Requirements
- Implement De Bruijn lookup or binary-search bitwise shifts in Yul assembly.
- Return bit index ($0\text{--}255$) in $O(1)$ constant time.
🎯 Acceptance Criteria
Labels:
medium-difficulty,yul,math,gasguardDifficulty: Medium
Module:
contracts/math/🧠 Concept
Build an assembly algorithm (Find First Set / De Bruijn multiplication approach) in Yul to locate the position of the most significant bit (MSB) or least significant bit (LSB) in a
uint256word.Finding bit indices using high-level
whileloops iterates byte-by-byte or bit-by-bit, consuming high execution gas on large numbers.📁 Implementation Scope
contracts/math/YulBitSearch.soltest/math/YulBitSearch.test.ts🛠️ Requirements
🎯 Acceptance Criteria