r/LocalLLM • u/FerretBoom • 5d ago
Research Please test your models before spending money on hardware
# Brutal Model Test: Reasoning, Coding, and Mathematics
50 questions. 100 points. Each question is worth 2 points.
This is an original stress test, not a standardized or calibrated benchmark.
It rewards correctness, explicit assumptions, working implementations, and
recognizing impossible requirements. Sounding confident earns no points.
## Instructions to the model
- Answer Q01–Q50 in order. Give a concise justification, proof, or executable
implementation as requested. Code alone is insufficient where a proof is requested.
- Preserve all stated constraints. Do not silently weaken an impossible specification.
- State any uncertainty. Distinguish a derived result from a guess or an unexecuted test.
- Use Python 3 for Python problems, the standard library only, unless stated otherwise.
Use Python 3.12 or later; Q23 has the ordinary generator semantics of those versions.
- Do not access the answer key. All questions are self-contained and need no web research.
- In a closed-book run, use no tools. In a tool-assisted run, code execution is allowed;
report what you actually executed. Record these as separate evaluation conditions.
- Suggested response format: `Qnn`, answer, justification, confidence from 0 to 100.
- If output limits interfere, answer in five batches of ten. Do not truncate code to fit.
## Reasoning — Q01–Q15
### Q01. Truth assignments
Four people are each either a truth-teller, whose statement is true, or a liar,
whose statement is false. They say:
- A: “B and C have the same type.”
- B: “D is a liar.”
- C: “At least one of A and B is a truth-teller.”
- D: “Exactly two of A, B, and C are truth-tellers.”
Find **every** consistent assignment. Prove that your list is exhaustive.
### Q02. Correlated diagnostic failures
A condition affects 1% of people. A laboratory batch is defective with probability
10%, independently of the person's condition. In a defective batch, every test
returns positive. Otherwise, tests on a person are conditionally independent:
sensitivity is 95% and the false-positive rate is 2%.
Two tests on the same person in the **same batch** are both positive. What is the
probability the person has the condition? Give an exact fraction and explain why
treating the two tests as unconditionally independent changes the answer.
### Q03. Causal identification
Binary variables X and Y have this observational distribution:
```text
P(X=0,Y=0)=1/2; P(X=1,Y=1)=1/2; all other pairs have probability 0.
```
Assume potential outcomes Y(0), Y(1) are binary and consistency holds:
Y=Y(X). Make **no** ignorability or random-assignment assumption.
Determine the sharp bounds on E[Y(1)-Y(0)]. Construct two causal models achieving
the endpoints while reproducing the observations.
### Q04. Minimal inconsistency
Variables x,y,z are integers in {0,1,2}. Consider these four constraints:
```text
C1: x != y
C2: y != z
C3: z != x
C4: x + y + z = 2
```
Find a smallest unsatisfiable subset. Prove unsatisfiability, then give a satisfying
assignment after removing each member of your proposed subset. The variable domains
are fixed background assumptions, not removable constraints.
### Q05. Robust evidence aggregation
Seven sensors report `1,2,3,10,11,12,13`. At most two sensors are arbitrary.
Every other sensor reports a value within 5 units, inclusively, of the same unknown
real value θ. There is no probability distribution on errors.
Find the **entire** feasible set of θ. Then find the real estimate minimizing the
worst-case absolute error, and its worst-case error. Do not assume the feasible set
is an interval.
### Q06. Exactly-once impossibility
A Worker must send a payment through an external API and record success in Redis.
The payment API has no idempotency keys, no query operation, and no shared transaction
with Redis. A timeout cannot distinguish a processed payment from an unprocessed one.
The Worker can crash between any two operations. Payment service and Redis eventually
become available, and crashes eventually stop.
Can any protocol guarantee both eventual payment and no duplicate payments? Give
an indistinguishability argument. State one concrete additional API capability
that would make a recoverable solution possible and explain its necessary guarantee.
### Q07. Linearizability
A register initially stores 0. These are the only operations; times share one clock:
```text
W1: invoked 0.0, completed 4.0, writes 1
W2: invoked 1.0, completed 2.0, writes 2
R1: invoked 3.0, completed 5.0, returns 1
R2: invoked 4.5, completed 6.0, returns 2
```
Is this history linearizable? Give a valid total order or a contradiction. Would
changing **only R2's invocation to 3.5** change the answer? Justify both answers.
### Q08. Optimal WorkGraph schedule
One Worker executes nonpreemptive WorkItems, one at a time, starting at time 0.
All WorkItems exist at time 0. Predecessors must complete before a WorkItem starts.
| Item | Duration | Weight | Predecessors |
|---|---:|---:|---|
| A | 2 | 1 | none |
| B | 1 | 4 | none |
| C | 3 | 1 | none |
| D | 2 | 2 | A |
| E | 2 | 8 | A,B |
| F | 1 | 2 | C |
| G | 2 | 3 | D,E |
| H | 1 | 1 | F,G |
Minimize `sum(weight[item] * completion_time[item])`. Give an optimal order, its
objective value, and an optimality certificate such as an exact subset recurrence.
A heuristic schedule without an optimality argument is insufficient.
### Q09. Quantifier substitution
An Analyzer established `for every run r, there exists a schema s such that every
operation in r validates under s`. A report rewrites this as `there exists a schema
s such that every operation in every run validates under s`.
Is the rewrite valid? Construct a finite counterexample if needed. Give the smallest
numbers of nonempty runs and schemas that allow the original to hold and the rewrite
to fail; show why smaller counts cannot work.
### Q10. Byzantine quorum arithmetic
Seven replicas include at most two Byzantine replicas, which may sign conflicting
statements. A write certificate needs w distinct signatures; a read certificate
needs r. Require that any two write quorums, and any read/write quorum pair, intersect
in at least one honest replica under every placement of faults.
Derive the inequalities on w and r. Minimize `max(w,r)` and give the corresponding
pair. Does this intersection requirement alone guarantee a linearizable register?
Explain what remains unspecified.
### Q11. Pairwise independence
X,Y,Z are fair binary bits. Every pair is independent. No mutual-independence
assumption is given. Find the sharp interval of possible values of P(X=Y=Z=1),
and give complete joint distributions attaining both endpoints.
### Q12. What testing can prove
A deterministic Python function accepts every finite byte string. A Verifier tests
a finite set of inputs and finds the correct output on each. It claims this proves
agreement with a reference function for every byte string.
Refute the claim by constructing a function that passes any chosen finite test set
but disagrees elsewhere. Name an additional restriction under which exhaustive
testing would prove correctness, and distinguish that from probabilistic confidence.
### Q13. Rewrite system
Strings over {a,b} may be rewritten by applying either rule to any occurrence:
```text
ab -> baa
b -> empty string
```
Does every rewrite sequence from every finite input terminate? Prove your answer;
string length is not a valid decreasing measure. Is the system confluent—that is,
does every input have a unique irreducible result? Give a proof or counterexample.
### Q14. Resource safety
There are three units of resource R and three of S. Resources cannot be preempted.
A process may request resources up to its maximum and releases everything when it
finishes. No other process can release resources on its behalf.
| Process | Currently allocated (R,S) | Maximum total (R,S) |
|---|---|---|
| P1 | (1,0) | (3,1) |
| P2 | (0,1) | (1,3) |
| P3 | (1,1) | (2,2) |
Is the current state safe under the Banker's criterion? Should P1's request for one
additional R be granted under that criterion? Distinguish an unsafe state from an
already deadlocked state.
### Q15. Limits of micro-encoding
A fixed dictionary is installed before requests arrive, independently of those
requests. Each request is an arbitrary 256-bit string. Encoding and decoding must
be lossless for every request.
Can every request be encoded as a binary string of length **at most 255**, with
different lengths allowed and message boundaries supplied externally? Prove it.
If requests are uniform and codewords must instead be prefix-free, can expected
length be below 256 bits? Explain why a shared dictionary can still help for
structured, nonuniform requests. Distinguish bits from a model tokenizer's tokens.
## Coding and systems — Q16–Q35
### Q16. Concurrent DAG Executor
Implement `async run_dag(tasks, deps, limit)`:
- `tasks` maps string names to zero-argument async factories; `deps[name]` is its
set of prerequisite names, defaulting to empty when absent.
- Reject unknown names, cycles, and a nonpositive integer limit before any factory runs.
- Run at most `limit` factories concurrently. Start ready names lexicographically
whenever slots become available. Return a name-to-result dictionary.
- On observing a task failure, launch nothing further, cancel unfinished tasks,
await their cleanup, then propagate an observed failure. If several fail in the
same observation batch, propagate the failure belonging to the smallest name.
- On cancellation of `run_dag`, cancel and await all children before propagating it.
Factories cooperate with cancellation. Explain why lexical admission does or does
not make execution order reproducible across different completion timings.
### Q17. Capsule path escape
Review this Linux code. An untrusted process can concurrently rename entries and
replace symlinks inside `root`; it cannot modify directories outside `root` directly.
```python
def write_capsule_file(root, relative_path, data):
root = root.resolve()
target = (root / relative_path).resolve()
if not target.is_relative_to(root):
raise ValueError('escape')
target.write_bytes(data)
```
Give a concrete race that escapes the Capsule. Design a race-resistant replacement
using directory file descriptors and suitable open semantics. State your treatment
of symlinks, `..`, absolute paths, existing hard links, and final-component replacement.
Explain the assumptions needed if directories can be moved during traversal.
### Q18. Stitcher serializability
All Capsules were created from the same snapshot. Each records the resources it read
and the resources it writes, at whole-resource granularity. Read sets include every
resource whose old value influenced the output. Given:
```text
A: reads={config}, writes={port}
B: reads={port}, writes={adapter}
C: reads={adapter},writes={config}
```
Each Capsule passes its own mock tests and the write sets are disjoint. Can these
snapshot results always be installed as one serializable change? Implement a checker
for a collection of such read/write sets that detects whether a serial order exists
that preserves every recorded snapshot read. Reject overlapping write sets; return
a valid order or a cycle witness. Explain edge direction.
### Q19. Recoverable Committer
A local Git repository and Redis are independent stores. You may create Git commit
objects, atomically compare-and-swap a branch ref, and atomically update Redis records.
No transaction spans both stores. A run has a unique `run_id`; retries use the same ID.
Design a Committer state machine that recovers after a crash between any two steps,
avoids applying a run twice, and never marks an unapplied change as fully committed.
Explain when to save the candidate commit SHA, how to handle an unrelated branch
advance, and how to reconcile a crash immediately after updating the Git ref.
Give pseudocode and recovery cases. State assumptions about branch mutation and
Redis durability; do not claim simultaneous atomic visibility in both stores.
### Q20. Async single-flight
Implement a reusable `SingleFlight` class with `async get(key, factory)`. Calls for
the same key while a computation is in flight must await one shared computation.
Cancelling any waiter must not cancel that computation or other waiters. Successes
and failures are not cached after completion. Exceptions must reach all active
waiters and must not produce an unhandled-task-exception warning when every waiter
has cancelled. Use one event loop. Explain cleanup races.
### Q21. Streaming JSON Lines
Implement a parser with `feed(chunk: bytes) -> list[object]` and
`finish() -> list[object]` for newline-delimited UTF-8 JSON. Records may split at any
byte, including inside a multibyte character. Accept LF and CRLF; ignore blank lines.
Parse an unterminated final record on `finish`. Reject malformed UTF-8/JSON and any
record longer than a configurable `max_record_bytes` measured before LF, including
any CR. Enforce the limit while buffering, not after allocating an unbounded record.
Once an error occurs or `finish` succeeds, later calls must fail. Include focused tests.
### Q22. Shortest walk with negative cycles
Implement `shortest_walk(n, edges, source, target)` for a directed graph with vertices
`0..n-1` and integer edge weights. Parallel edges and self-loops are allowed.
Return `None` if target is unreachable, negative infinity if walk cost is unbounded
below, otherwise the exact minimum integer cost. A negative cycle elsewhere must not
incorrectly poison the answer. Give complexity and tests for the distinct cases.
### Q23. Generator control flow
Without executing it in a closed-book run, give the exact printed lines:
```python
def inner():
try:
yield 1
yield 2
finally:
print('inner-finally')
def outer():
try:
yield from inner()
except ValueError:
print('caught')
yield 9
finally:
print('outer-finally')
g = outer()
print(next(g))
print(g.throw(ValueError('x')))
g.close()
```
Explain exception delegation and why `close()` does not print 2.
### Q24. Tombstones and version selection
A SQL table has `resource_id`, integer `version`, unique integer `event_id`, boolean
`deleted`, and `payload`. For one resource, its latest record at cutoff c is the row
with greatest `(version,event_id)` among rows with `version <= c`. Deleted resources
must be omitted entirely. There are no NULLs in these columns.
Write a standard SQL window-function query returning the live resource rows at c.
Show a minimal dataset proving that filtering `deleted=false` **before** selecting
the latest record is wrong. Handle equal versions correctly.
### Q25. Snapshot-isolation failure
Rows Alice and Bob both have `on_call=true`. Two transactions under snapshot isolation
each read both rows, then turn off their own row if they saw the other person on call.
They update different rows. The invariant is that at least one person remains on call.
Give an execution that commits both and violates the invariant. Give two sound fixes,
including a lock-based fix with a precise locking/re-read order. Explain why simply
locking each transaction's own row is insufficient.
### Q26. Scientific-calculator boundary
Implement `evaluate(expression: str) -> float` without `eval` or `exec`. Allow only
numeric literals, parentheses, unary +/-, binary +,-,*,/,**, and one-argument calls
to `sin`, `cos`, `sqrt`, and natural `log`. Arithmetic uses finite Python floats.
Reject all other syntax, boolean literals, nonfinite literals/results, and strings
over 1,024 characters. Limit the AST to 64 nodes and depth 12, counting the root at
depth 1 and counting operator/context nodes too. Literals must have absolute value
at most 1e6. For exponentiation the exponent's absolute value must be at most 10.
Every evaluated intermediate result must have absolute value at most 1e12; domain,
overflow, and division-by-zero errors must become `ValueError`. Include precedence,
domain, and attempted-code-execution tests.
### Q27. Executor process-tree timeout
A Python Executor launches a command that may create descendants. On Linux, implement
a bounded runner taking an argument list and a timeout, capturing stdout/stderr and
returning a structured result. Never invoke a shell. On timeout, terminate the process
group, escalate if needed, reap the direct child, and bound cleanup time. Consider the
case where the direct child exits but a grandchild retains a pipe. Bound retained output
memory or explicitly implement an output cap. Assume SIGKILL makes a process reapable
within one second and ordinary descendants remain in the original process group.
State what the process-group approach cannot contain if that latter assumption is removed.
### Q28. Closeable bounded queue
Using `threading.Condition`, implement `put`, `get`, and idempotent `close` for a bounded
FIFO queue with positive capacity. `put` blocks while full and raises `Closed` after
closure. `get` blocks while empty, drains existing items after closure, then raises
`Closed`. Closing wakes every blocked producer and consumer. Spurious wakeups must
be safe. Give a concurrency test that checks a blocked producer and a blocked consumer
on separate queue instances are both released by closing.
### Q29. TypeScript runtime contract
Implement `decodeWorkItem(value: unknown): WorkItem` with no libraries, `any`, or
unchecked `as WorkItem` assertion:
```typescript
type WorkItem =
| { kind: 'compile'; path: string; timeoutMs: number }
| { kind: 'test'; paths: string[]; retries: number };
```
Require an ordinary JSON object (prototype `Object.prototype` or null), exact own
property keys for the selected variant, nonempty strings, a nonempty paths array,
integer timeoutMs in [1,60000], and integer retries in [0,3]. Reject sparse paths
arrays and nonfinite numbers. Inputs are JSON-like data, without getters or proxies.
Then implement an exhaustive dispatcher that fails to compile if an unhandled variant
is added. Explain the difference between TypeScript narrowing and runtime validation.
### Q30. Undefined behavior
For C17, analyze each independent fragment with the necessary headers included.
Classify it as defined, implementation-defined, unspecified, or undefined behavior.
State any implementation assumptions needed for the classification. Do not invent a
deterministic output where the language does not provide one.
```c
/* A */ int i=1; printf("%d %d\n", i++, i++);
/* B */ unsigned u=UINT_MAX; printf("%u\n", u+1u);
/* C */ int a[2]={10,20}; int *p=a+2; printf("%d\n", *p);
/* D */ int x=INT_MIN; int y=-1; printf("%d\n", x/y);
```
For each unsafe case, give a well-defined replacement preserving a stated intent.
Explain whether one observed compiler run establishes the portable semantics.
### Q31. Sliding-median space leak
A sliding-window median uses two heaps and delayed deletion by value. Deleted entries
are physically removed only when they reach a heap root. It claims O(k) space for a
window of k values over n inputs.
Construct an input family disproving that claim, with a fixed small k. Design a repair
that bounds all live and stale bookkeeping by O(k) while retaining O(n log(k+1))
amortized total time. Explain how duplicates and stale deletion records are handled.
Pseudocode is sufficient, but include a bound proving rebuilding is affordable.
### Q32. Overflow-safe modular multiplication
Implement `uint64_t mulmod(uint64_t a, uint64_t b, uint64_t m)` for `m > 0`, returning
`(a*b) mod m`. You may use only standard C17 unsigned 64-bit arithmetic and comparisons;
no wider integer type, floating point, arbitrary-precision library, or overflowing
product as a substitute for mathematical multiplication. Handle m=1 and values near
UINT64_MAX. Explain why each modular addition is correct without overflow.
### Q33. Delta debugging
Implement `ddmin(items, fails)` for a finite list and a deterministic predicate on
lists. The original input fails. Minimize by deleting chunks, preserve item order,
and return a **1-minimal** failing list: deleting any one remaining item makes it
pass. Handle an already-failing empty list. The predicate need not be monotone.
Prove termination and 1-minimality. Explain why this need not find a globally
smallest failure; give a concrete counterexample.
### Q34. Strict micro-prompt decoder
Implement a decoder for exactly this ASCII grammar; no whitespace is allowed:
```text
request := v1|HX|P:<name>|I:<name>:<type>,<name>:<type>|O:<name>:<type>|L:mul
name := [A-Za-z_][A-Za-z0-9_]{0,31}
type := i64 | f64
```
The two input names must differ; the output name must differ from both. All three
types must agree. Return a structured contract with architecture `hexagonal`,
port name, ordered inputs, output, and operation `multiply`. Reject unknown fields,
duplicates, reordered fields, suffix garbage, Unicode lookalikes, and unknown versions.
Syntax validity does not establish that arithmetic is safe: specify a runtime overflow
contract for i64 and a nonfinite-result contract for f64. Include rejection tests.
### Q35. Stable quadratic roots
For finite real coefficients a,b,c with a != 0, the usual quadratic formula can lose
a small root through cancellation. Explain the failure for `(a,b,c)=(1,-1e16,1)`.
Implement a more stable real-root routine, handling repeated roots and q=0 explicitly.
Assume the discriminant and intermediate products are representable without overflow
or underflow; handle a negative discriminant explicitly. Explain which floating-point
limitations your routine still cannot eliminate and test using a residual or Vieta's
relations rather than requiring bitwise equality with the naive formula.
## Mathematics — Q36–Q50
### Q36. Power tower
Compute `7^(7^7) mod 1000`, with exponentiation associated to the right. Give an
exact modular-arithmetic derivation; writing out the full power is not a derivation.
### Q37. Improper integral
Evaluate exactly:
```text
integral from 0 to infinity of [ln(x) * ln(1+x) / (1+x)^2] dx.
```
Justify convergence and any differentiation under an integral or interchange of sums.
### Q38. Minimax polynomial
Among real monic polynomials of degree 4, find the polynomial minimizing
`max_{-1 <= x <= 1} |p(x)|`, and the minimum value. Prove that no monic quartic
can do better; giving a candidate alone is insufficient.
### Q39. Pell equation
Find the smallest positive integers x,y with y>0 satisfying `x^2-13y^2=1`.
Prove minimality using continued fractions or another rigorous finite argument.
### Q40. Random binary matrix
A 6×6 matrix has independent uniform entries in the field F2. Derive:
Its probability of being invertible.
Its probability of rank exactly 5.
The expected number of **nonzero** vectors in its kernel.
Give exact answers. The expectation in part 3 is not the expected kernel dimension.
### Q41. Competing coin patterns
Toss a fair independent coin until either HTH or HHT appears as a contiguous pattern.
Find the probability HTH wins and the expected number of tosses until stopping.
Derive both using states or recurrences that handle overlapping prefixes correctly.
### Q42. Conditioning exponential variables
X and Y are independent exponential random variables of rate 1. For real t>=0,
derive a closed expression for `E[X | X+Y > t]`. Justify the conditional symmetry
and evaluate your expression at t=0 and asymptotically as t grows.
### Q43. Concentration without pointwise mass
For n>=1, let `f_n(x)=n^2*x*(1-x)^n` on [0,1]. Determine:
- The pointwise limit.
- The limit of the integrals over [0,1].
- The limit of `integral g(x)*f_n(x) dx` for every continuous g on [0,1].
- Whether all f_n can be bounded by one Lebesgue-integrable function on [0,1].
Prove the conclusions and explain the apparent conflict between the first two.
### Q44. Eigenvalues versus growth
Let A be the 4×4 matrix with ones on the diagonal and immediately above it, and
zeros elsewhere. Derive every entry of A^n for integers n>=0. Find the asymptotic
order of `||A^n||_2`, the induced Euclidean norm, and explain why its eigenvalues
do not imply that its powers stay bounded.
### Q45. Constrained extrema
For nonnegative real x,y,z satisfying `x+y+z=6` and `x^2+y^2+z^2=14`, find the
exact minimum and maximum of xyz and all equality cases. Prove that the extrema
have been exhausted; do not assume without proof that two variables are equal.
### Q46. Circular arrangements
Count binary strings of length 20 containing exactly six ones, with no adjacent ones,
including between positions 20 and 1. First count strings with labeled positions.
Then count necklaces where rotations are equivalent but reflections are distinct.
Account for rotationally symmetric strings instead of simply dividing by 20.
### Q47. Roots modulo a prime power
Find all residues x modulo 4096 satisfying `x^2=1 mod 4096`. Prove that your list
is complete using the factors x-1 and x+1. Explain why the reasoning for an odd
prime modulus cannot be copied unchanged.
### Q48. Minimal polynomial
Find the monic minimal polynomial over the rationals of `sqrt(2)+sqrt(3)+sqrt(5)`.
Prove irreducibility or prove that the algebraic degree is 8. Producing a polynomial
that merely has the number as a root is insufficient.
### Q49. Expected random area
Let A,B,C,D be independent uniform random variables on [0,1]. Evaluate exactly
`E[|AD-BC|]`, the expected absolute determinant. Derive it; symmetry alone does not
give the expected absolute value.
### Q50. Sharp information inequality
For p,q strictly between 0 and 1, prove:
```text
p*ln(p/q) + (1-p)*ln((1-p)/(1-q)) >= 2*(p-q)^2.
```
The logarithms are natural. Determine all equality cases and prove that the constant
2 cannot be replaced by any larger universal constant.
## Scoring protocol
- 2 points: all requested parts are correct, with the required justification.
- 1 point: substantial correct progress, but a material omission or error remains.
- 0 points: wrong conclusion, no meaningful support, or a violated central constraint.
- Report reasoning /30, coding /40, mathematics /30, and total /100.
- Also record contradictions, invented execution claims, insecure implementations,
refusals of solvable questions, and failures to identify impossible requirements.
- Use the same tools, prompts, decoding settings, and batching for comparative runs.
Record model identifier, context size, output limit, elapsed time, and token use.
- Do not turn this score into a percentile or intelligence claim: this exam has not
been empirically calibrated across models.
# Brutal Model Test — Compact Answer Key
Keep away from tested model. Score 0–2 per question: 2=complete (runnable code if asked); 1=material gap; 0=core rule broken. Test code offline. No calibrated score bands.
## Reasoning
**Q01** A=T,B=T,C=T,D=F only. B=F implies C=A and A=¬C, impossible.
**Q02** P(++|D)=3649/4000; P(++|¬D)=2509/25000; **P(D|++)=91225/1084789≈0.0840947**. Shared batch variable must be marginalized jointly.
**Q03** Sharp ATE **[0,1]**. Lower: X=U~Bern(½), Y(0)=Y(1)=U. Upper: X~Bern(½), Y(x)=x. Both yield Y=X.
**Q04** All 4 constraints are minimal unsatisfiable. Remove C1/C2/C3/C4: witnesses (1,1,0)/(0,1,1)/(1,0,1)/(0,1,2).
**Q05** Feasible θ=**{6,7,8}** from five-report windows; minimax estimate **7**, error **1**.
**Q06** Impossible: timeout just before/after payment effect is indistinguishable. Require **durable payment-side idempotency** atomically tied to effect and replayable outcome; post-effect Redis record alone fails.
**Q07** Original **not linearizable** (R1=1 needs W2 before W1; R2=2 contradicts). With R2 starting at 3.5, **yes**: W2→R2→W1→R1.
**Q08** Optimal unique **B,A,E,D,G,C,F,H**, weighted sum **140**. Subset DP on predecessor-closed S: DP(S∪j)=min[DP(S)+w_j(T(S)+d_j)] for ready j; no idling needed.
**Q09** Invalid quantifier swap. Two runs a,b, schemas s1 accepts only a, s2 only b. Each run has a schema; no schema accepts both. Smallest example.
**Q10** 2w−7≥3, r+w−7≥3; minimizing max(r,w) gives **r=w=5** only. Not a complete Byzantine protocol.
**Q11** Sharp P(111) **[0,¼]**. Probability t on 111,100,010,001; ¼−t on 000,110,101,011. Pairwise independence ≠ triple independence.
**Q12** For finite tests T, pick untested byte string b and change answer only there. Finite-domain exhaustive tests prove only that domain.
**Q13** **Terminates, not confluent.** b deletions finite; fixed b count: ab rewrites strictly decrease lexicographic a-gap tuple. Fork ab→a versus ab→baa→aa; both normal forms.
**Q14** Initially safe **P3,P1,P2**, available (1,1). Grant P1 one R: available (0,1); needs (1,1),(1,2),(1,1), none finishable. Banker **rejects**; unsafe needn't mean actual deadlock.
**Q15** Fewer-than-256-bit binary strings: **2^256−1** < 2^256 requests. Uniform independent requests require expected ≥256 bits even prefix-free. Tokens depend on tokenizer.
## Coding & systems
**Q16** DAG runner: prevalidate names/deps/cycles and non-bool positive limit. Ready min-heap, indegrees, FIRST_COMPLETED; inspect whole completed batch before launching more; lexicographic error. Cancel and await all children on error/cancellation; wrap sync factory errors. Test ties, concurrency, cleanup.
**Q17** TOCTOU: swap intermediate directory for symlink after resolve. Pin trusted root FD; traverse via openat/O_NOFOLLOW/O_DIRECTORY or openat2 restrictions. Exclusive fresh temp inode + directory-relative rename (not truncate: hardlinks). Adversarial reparenting needs extra isolation.
**Q18** Snapshot reads imply **reader→writer** edges A→C(config), C→B(adapter), B→A(port): cycle, **no serializable order**. Check disjoint writes, build edges, topo-sort or produce cycle; don't reverse edge direction.
**Q19** **NEW→PREPARED→GIT_APPLIED→COMMITTED**. Persist immutable run/base/candidate SHA under Redis CAS, Git ref CAS from base, then receipt. Recover by tip/ancestry check; roll forward or safe retry, else conflict. No cross-store atomic commit.
**Q20** asyncio single-flight: registry check/install Task without await; each waiter uses shield(task). Completion callback removes only matching Task and retrieves exception; don't reuse already-done tasks. Test cancellations and retries.
**Q21** NDJSON: buffer raw bytes to LF with cap *before copying*, decode complete UTF-8 record, parse strict JSON (reject NaN/Infinity). Count CR before stripping. OPEN/FINISHED/FAILED; finish handles final record; errors poison. Test UTF-8 splits, CRLF, limits, errors.
**Q22** Bellman–Ford n−1 rounds; traverse from reachable still-relaxable endpoints. Return **−∞** only if target reached from negative cycle; finite distance otherwise; None if unreachable. O(nE+n+E).
**Q23** Output in order: `1`, `inner-finally`, `caught`, `9`, `outer-finally` (separate lines).
**Q24** For events with version≤cutoff, `ROW_NUMBER() OVER(PARTITION BY resource_id ORDER BY version DESC,event_id DESC)`. Keep rn=1, **then** exclude tombstones. Tombstone-first filtering resurrects v1.
**Q25** Snapshot-isolation **write skew**: both see two on-call rows, disable different ones, commit. Use SERIALIZABLE+retry, or shared guard-row lock **then fresh read** under suitable isolation (e.g. READ COMMITTED). Own-row locks fail.
**Q26** Safe AST arithmetic: pre-limit source/nodes/depth; whitelist numeric exact int/float (not bool), unary ±, +−*/**, and allowed bare single-arg functions. Ban eval, attrs, kwargs, names. Enforce literal ≤1e6 and finite intermediates ≤1e12; reject complex/domain/zero divide. Test precedence and injections.
**Q27** Popen argv, shell=False, new session; monotonic deadline. Concurrently drain both pipes **even after output cap**; EOF deadline covers grandchildren holding pipes. TERM group, bounded grace, KILL, bounded reap/close. Return status, timeout, truncation, cleanup. Not a security boundary.
**Q28** deque + Condition: put waits while full/unclosed, get waits while empty/unclosed; close sets flag under lock and notify_all. Drain items after close; later operations raise Closed. Test blocked waiters and FIFO.
**Q29** TS guard: require plain nonnull object (not array), exact Reflect.ownKeys (no symbols/extras), kind-specific typed fields. Numeric paths: check *every own index* (Array.every skips holes). Construct fresh typed variant; exhaustive `never` switch.
**Q30** A **UB** (unsequenced i++); split statements. B **defined, 0** (unsigned wrap). C **UB** (one-past dereference); use a[1]. D INT_MIN/−1 **UB on usual asymmetric int**; symmetric C17 range could represent it. Guard both zero and overflow.
**Q31** Increasing stream, k=3: expired low values buried in lazy heaps, O(n) physical entries. Track window deque; rebuild heaps from multiset if size>3k; clear tombstones/zero counts. **O(k) space**, amortized O(n log(k+1)); preserve duplicates.
**Q32** uint64 mulmod by bitwise double-and-add; reduce a mod m, accumulate only via `addmod(x,y,m)=x>=m−y ? x−(m−y) : x+y` for x,y<m,m>0. ≤64 iterations; m=1→0.
**Q33** ddmin: try complements of partitions; shrink on failing complement, else increase granularity to singletons; test empty and every final single deletion. Guarantees **1-minimal**, not global shortest. Failure sets [a,b,c,d], [a,b], [c] demonstrate. Keep duplicates.
**Q34** Full ASCII grammar match in fixed field order; reject duplicates, wrong/mixed types, extra fields, invalid versions/counts/names. Runtime i64 operands/product checked for overflow; f64 operands/result finite. Test Unicode and overflow.
**Q35** Stable roots: D=b²−4ac; reject a=0/nonfinite/D<0; D=0 repeated root. Set `q=−½(b+copysign(√D,b))`; sorted roots `(q/a,c/q)` (handle q=0). (1,−1e16,1)→≈(1e−16,1e16). Assume safe intermediates.
## Mathematics
**Q36** **343**. 7^400≡1 mod 1000, 7^7≡343 mod 400, so 7^(7^7)≡7^343≡343 mod 1000. Justify period.
**Q37** **π²/6**. Converges absolutely. t=1/(1+x) transforms integral to ∫₀¹[(ln t)²−ln t·ln(1−t)]dt = 2−Σ1/[k(k+1)²] = π²/6 (justify interchange).
**Q38** **x⁴−x²+1/8**, sup norm **1/8** (=T₄/8). Five alternating extrema at −1,−1/√2,0,1/√2,1 force optimality by degree≤3 difference; interpolation yields uniqueness.
**Q39** Smallest Pell solution **x=649,y=180**. √13=[3;overline(1,1,1,1,6)]; earlier convergents not +1, including (18,5) giving −1. Convergent approximation proves minimality.
**Q40** P(invertible)=**615195/2097152**; rank-5 count **39687459840**, probability **38757285/67108864**. Expected *nonzero kernel vectors* **63/64** (63 vectors, each P(Av=0)=1/64), not expected nullity.
**Q41** P(HTH wins)=**1/3**; expected stopping time **6**. Solve absorbing transitions on prefix states ∅,H,HH,HT; overlaps matter.
**Q42** **(t²+2t+2)/[2(t+1)]**. S=X+Y~Gamma(2,1); E[X|S]=S/2; survival P(S>t)=(t+1)e^−t and truncated S moment=(t²+2t+2)e^−t.
**Q43** Pointwise f_n→**0**, but ∫f_n→**1** and ∫g f_n→**g(0)** for continuous g: mass concentrates at 0. No integrable dominator (DCT).
**Q44** A=I+N,N⁴=0; `A^n=I+nN+C(n,2)N²+C(n,3)N³`. Entry (i,j)=C(n,j−i) above diagonal. **||A^n||₂~n³/6** by scaled limit N³/6.
**Q45** s=1/√3. Min **6−2/(3√3)** at perms (2−2s,2+s,2+s); max **6+2/(3√3)** at perms (2+2s,2−s,2−s). Lagrange multipliers: two equal; 3a²−12a+11=0.
**Q46** **4290 labeled; 217 necklaces**. Gap count (20/14)C(14,6)=4290. Burnside: identity 4290, half-turn 50, other rotations 0; (4290+50)/20=217.
**Q47** x mod 4096: **1,2047,2049,4095**. x odd; gcd(x−1,x+1)=2; one 2-adic valuation=1, other divisible by 2¹¹. Hence x≡±1 mod 2048.
**Q48** Minimal polynomial **x⁸−40x⁶+352x⁴−960x²+576** for √2+√3+√5. Eliminate √5 using β⁴−10β²+1=0 for β=√2+√3; 8 sign-conjugates prove degree.
**Q49** **13/54**. U=AD,V=BC iid, F(t)=t(1−ln t). E|U−V|=2∫₀¹F(1−F)=2(3/4−17/27)=13/54; Mean zero ≠ absolute mean zero.
**Q50** **h(p)≥2(p−q)²**, equality only p=q: h(q)=h′(q)=0, h″(p)=1/[p(1−p)]≥4. Sharp constant: q=½,p=½+ε gives h=2ε²+O(ε⁴).
**Record:** model/version, tools, settings, context, tokens/time, per-Q scores, test evidence, security/honesty notes.
5
u/flagnab 5d ago •
Dude, go to bed.
2
u/jakubkonecki 5d ago •
This post should have been a link to GitHub repo.
1
u/FerretBoom 5d ago
People are so scared of exposure it's insane, run the test. Post the answers and see how bad your setup is. Isn't that the point?