Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
geo / geo-h3-grid-diskOpenRuns on Liberas

H3 grid disk

Every H3 (version 4) cell within grid distance k of cell, as H3's gridDisk defines it: the cell itself and its rings out to k steps, the same resolution, pentagon distortion included (a disk around or near a pentagon has fewer cells than 3k(k + 1) + 1). k is 0 to 50, else an error. Each cell appears once and the list is sorted ascending by index (which, all being 15 hex digits, is ascending as strings). A cell is written as its 64-bit index in lowercase hexadecimal, 15 digits (every cell index lies in 2^59 … 2^60 − 1). A cell argument is 1 to 16 hex digits in either case and must be a valid H3 cell index (H3's isValidCell: high bit 0, mode 1, resolution 0 … 15, a valid base cell, digits 0 … 6 up to the resolution and 7 after it, no deleted subsequence of a pentagon), else an error. The answer is pure integer arithmetic on indexes, so it matches bit for bit.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init geo-h3-grid-disk --lang rust
cd geo-h3-grid-disk && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)11 lines›
geo-h3-grid-disk.wit
package root:component;

world root {
  export liberas:geo/h3-grid-disk@0.1.0;
}
package liberas:geo@0.1.0 {
  interface h3-grid-disk {
    grid-disk: func(cell: string, k: u32) -> result<list<string>, string>;
  }
}
Test vectors15›
geo-h3-grid-disk.cases.json
[
  {
    "args": {
      "k": 1,
      "cell": "85283473fffffff"
    }
  },
  {
    "args": {
      "k": 0,
      "cell": "85283473fffffff"
    }
  },
  {
    "args": {
      "k": 2,
      "cell": "8928308280fffff"
    }
  },
  {
    "args": {
      "k": 1,
      "cell": "8009fffffffffff"
    }
  },
  {
    "args": {
      "k": 2,
      "cell": "8009fffffffffff"
    }
  },
  {
    "args": {
      "k": 3,
      "cell": "8075fffffffffff"
    }
  },
  {
    "args": {
      "k": 4,
      "cell": "821c07fffffffff"
    }
  },
  {
    "args": {
      "k": 5,
      "cell": "8c195da49a2d9ff"
    }
  },
  {
    "args": {
      "k": 1,
      "cell": "8fbe0e35cbad0a8"
    }
  },
  {
    "args": {
      "k": 2,
      "cell": "83f293fffffffff"
    }
  },
  {
    "args": {
      "k": 51,
      "cell": "85283473fffffff"
    }
  },
  {
    "args": {
      "k": 1,
      "cell": "89283082807ffff"
    }
  },
  {
    "args": {
      "k": 1,
      "cell": "8f28308280fffff"
    }
  },
  {
    "args": {
      "k": 1,
      "cell": ""
    }
  },
  {
    "args": {
      "k": 1,
      "cell": "zz"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 15 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 50,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.