You've answered 0 of 46 questions correctly. (Clear)

Question #33 Difficulty: 3

According to the Solidity 0.8.17 compiler (200 optimization runs)

    // What does this assembly return when f([1,2,3]) is called

contract C {
  function f(uint[] memory data) public pure returns (uint u) {
    for (uint i = 0; i < data.length; ++i) {
      assembly {
        u:= add(u, mload(add(add(data, 0x20), mul(i, 0x20))))
      }
    }
  }
}

Hint:

The first 0x20 (32 byte) add instruction gets you to the start of the array and contained the length.

Answer:

Problems? View a hint or try another question.

I give up, show me the answer (make 3 more attempts first).

Mode : Training

You are currently in training mode, answering random questions. Why not Start a new quiz? Then you can boast about your score, and invite your friends.

Contribute

Create your own!