← Back to reading
Lab

Observation and mental models

Report a problem in this lab

For typos, mistakes and things that don’t work. We read every report and fix what’s wrong, but we don’t reply here, so a question won’t get an answer.

F-OBS-V4-1easy · review

Compare two import previews

Two attempts to import a document-label catalog show the same short preview. The source export contains five registered labels.

What needs to change

Review which import report detects a missing registration, and state what the shared preview can establish.

Reproduce

  1. Compare the two supplied expected reports with the five-label source export before recording your import review.

Acceptance criteria

  • Import comparison
  • Evidence still needed

Notes

Each input starts with its label count followed by that many names; these inputs each contain at least two labels.

Attempt A and B are separate process inputs. Expected reports are authored from the displayed source, not newly captured runs.

The Source tab uses TypeScript with Node and supplies the complete input reader.

Read only

Sign in with access to this level to check your decisions. You can still inspect the supplied evidence.

Sign in →
main.ts
import { readFileSync } from "node:fs";

const tokens = readFileSync(0, "utf8").trim().split(/\s+/);
let at = 0;

function readCounts(): Map<string, number> {
    const size = Number(tokens[at++]);
    const result = new Map<string, number>();
    for (let i = 0; i < size; i++) {
        const key = tokens[at++];
        result.set(key, Number(tokens[at++]));
    }
    return result;
}

function total(counts: Map<string, number>): number {
    let sum = 0;
    for (const value of counts.values()) sum += value;
    return sum;
}

const size = Number(tokens[at++]);
const labels = tokens.slice(at, at + size);

console.log("preview", labels[0], labels[1]);
console.log("count", labels.length);
Native command
npx tsc main.ts --noEmit --skipLibCheck --target es2022 --module nodenext --types node && node main.ts
Not checked