Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
barcode / barcode-itfOpenRuns on Liberas

Interleaved 2 of 5

Interleaved 2 of 5 (ISO/IEC 16390) of text: an even number of digits, 2 to 80; an odd count (never zero-padded), another character or another length is an error. No check digit is added, no bearer bars. Each pair of digits: the first digit's five elements are bars, the second's spaces, interleaved bar first; narrow = 1 module, wide = 3. Digit patterns (N narrow, W wide): 0 NNWWN, 1 WNNNW, 2 NWNNW, 3 WWNNN, 4 NNWNW, 5 WNWNN, 6 NWWNN, 7 NNNWW, 8 WNNWN, 9 NWNWN. modules: start 1010, the pairs, stop 11101; no quiet zones. text echoes the input.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init barcode-itf --lang rust
cd barcode-itf && 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)21 lines›
barcode-itf.wit
package root:component;

world root {
  import liberas:barcode/types@0.1.0;

  export liberas:barcode/linear-encode@0.1.0;
}
package liberas:barcode@0.1.0 {
  interface types {
    record linear {
      text: string,
      modules: string,
    }
  }
  interface linear-encode {
    use types.{linear};

    encode: func(text: string) -> result<linear, string>;
  }
}
Test vectors14›
barcode-itf.cases.json
[
  {
    "args": {
      "text": "12"
    }
  },
  {
    "args": {
      "text": "00"
    }
  },
  {
    "args": {
      "text": "1234567890"
    }
  },
  {
    "args": {
      "text": "34"
    }
  },
  {
    "args": {
      "text": "567890"
    }
  },
  {
    "args": {
      "text": "0123456789"
    }
  },
  {
    "args": {
      "text": "1357924680"
    }
  },
  {
    "args": {
      "text": "98765432109876"
    }
  },
  {
    "args": {
      "text": "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
    }
  },
  {
    "args": {
      "text": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111"
    }
  },
  {
    "args": {
      "text": "123"
    }
  },
  {
    "args": {
      "text": ""
    }
  },
  {
    "args": {
      "text": "12a4"
    }
  },
  {
    "args": {
      "text": "١٢"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 14 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 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.