{
  "app": {
    "name": "Mokabla",
    "url": "https://www.mokabla.com",
    "description": "Real interview questions from companies in Egypt, organised by company. Access is sold per company for 30 days."
  },
  "page": {
    "kind": "question",
    "title": "Question · set-bits-counter",
    "humanPath": "/en/c/valeo/set-bits-counter",
    "humanOnly": false
  },
  "identity": {
    "class": "declared",
    "agent": "ClaudeBot",
    "operator": "Anthropic",
    "verified": false,
    "reason": "The user agent is ClaudeBot (Anthropic), which identifies itself as an AI agent.",
    "signals": [
      "Known agent user agent"
    ],
    "claimable": false
  },
  "state": {
    "question": {
      "slug": "set-bits-counter",
      "title": "Set Bits Counter",
      "difficulty": "easy",
      "tags": [
        "coding",
        "embedded",
        "oa",
        "intern"
      ],
      "is_free": true,
      "locked": false,
      "frequency": 1,
      "last_reported_at": "2026-08-06T20:55:05.914254Z",
      "url": "https://www.mokabla.com/en/c/valeo/set-bits-counter",
      "agent": {
        "page": "https://www.mokabla.com/agent/en/c/valeo/set-bits-counter",
        "question": "https://www.mokabla.com/agent/_call/get_question?company=valeo&question=set-bits-counter"
      },
      "company": {
        "slug": "valeo",
        "name_en": "Valeo"
      },
      "body_md": "## Problem\nThree small functions on an unsigned 32-bit value, no library calls, no lookup tables unless you build them yourself:\n\n1. `popcount(x)`, number of bits set to 1.\n2. `swapNibbles(b)`, for a byte, exchange the high and low 4 bits.\n3. `isPowerOfTwo(x)`, true if exactly one bit is set (`0` is not a power of two).\n\nThis is the first screen for embedded roles. I care less about the answer than about whether you reach for the bit tricks naturally.\n\n## Examples\n**Example 1**, `popcount(0b1011_0001) = 4`, `popcount(0) = 0`, `popcount(0xFFFFFFFF) = 32`.\n\n**Example 2**, `swapNibbles(0xAB) = 0xBA`, `swapNibbles(0x0F) = 0xF0`. `isPowerOfTwo(64) = true`, `isPowerOfTwo(96) = false`, `isPowerOfTwo(0) = false`.\n\n## Constraints\n- Inputs are unsigned 32-bit (or 8-bit for the nibble swap). In C, use `uint32_t` / `uint8_t` and mask results.\n- `popcount` should be `O(number of set bits)` per the classic `x &= x - 1` trick; the naive 32-iteration loop is accepted as a warm-up.\n- No `__builtin_popcount`; but tell me it exists and when you would use it.\n\n## What they look for\n`x & (x - 1)` clears the lowest set bit, which gives both `popcount` and `isPowerOfTwo` (`x && !(x & (x - 1))`). Shifts and masks for the nibble swap, with awareness of integer promotion in C (`(b << 4)` becomes an `int`, so mask with `0xFF`). Follow-ups go to reversing bits, counting trailing zeros, and the parallel-prefix popcount used by compilers.",
      "follow_ups_md": "- Reverse the bits of a 32-bit word in `O(log n)` operations.\n- Count trailing zeros without a loop.\n- Why does `(b << 4)` need a mask in C but not in Python?"
    },
    "paid": false,
    "access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
  },
  "actions": [
    {
      "name": "get_question",
      "description": "One question with its body. Bodies are paid content unless the question is free.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "question": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/get_question?company=valeo&question=set-bits-counter",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "list_questions",
      "description": "The questions reported at a company: titles, tags, difficulty, whether each is free or paid.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "page": "number?"
      },
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=valeo",
      "ready": true,
      "missing": []
    },
    {
      "name": "buy_access",
      "description": "Buy 30 days of access to a company.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "payment",
      "input": {
        "company": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/buy_access?company=valeo",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "post_comment",
      "description": "Comment on a question.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "write",
      "input": {
        "question": "string",
        "text": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/post_comment?question=set-bits-counter",
      "ready": false,
      "missing": [
        "text"
      ],
      "humanPath": "https://www.mokabla.com/en/companies"
    }
  ],
  "navigate": [
    {
      "label": "This question, as data (free questions only)",
      "href": "https://www.mokabla.com/agent/_call/get_question?company=valeo&question=set-bits-counter"
    },
    {
      "label": "All questions at this company",
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=valeo"
    },
    {
      "label": "The company page",
      "href": "https://www.mokabla.com/agent/en/c/valeo"
    },
    {
      "label": "Set Bits Counter · page",
      "href": "https://www.mokabla.com/agent/en/c/valeo/set-bits-counter"
    }
  ],
  "notices": [
    {
      "severity": "info",
      "message": "This classification is final for the session: it came from a strong signal, not a guess. The human pages are not served to agents."
    },
    {
      "severity": "info",
      "message": "Unverified agents are read-only. Signed requests (Web Bot Auth) are the path to write access."
    }
  ],
  "meta": {
    "requestId": "ag_17c01273cd7b",
    "policyVersion": "mokabla-2026-11-03",
    "generatedAt": "2026-11-03T17:41:15.896Z",
    "jsonUrl": "https://www.mokabla.com/agent/en/c/valeo/set-bits-counter?format=json",
    "manifestUrl": "https://www.mokabla.com/.well-known/agentgate.json",
    "humanUrl": "https://www.mokabla.com/en/c/valeo/set-bits-counter",
    "humanClaimUrl": "https://www.mokabla.com/agent/_claim/human?to=%2Fen%2Fc%2Fvaleo%2Fset-bits-counter"
  }
}