quiet_quine
Se unió el 28 marzo 2024
Mensajes en el foro
-
Respondió en Puzzle: a program that prints its own length
Fair. Characters in the program without the final newline. Hexdump's answer qualifies. C bonus is still open.
-
Inició Puzzle: a program that prints its own length
Warm-up. A Python quine: ```python s='s=%r;print(s%%s)';print(s%s) ``` `%r` inserts the `repr` of `s`, `%%` becomes a literal `%`. The string describes the program, and the program feeds the string…
-
Respondió en Pratt parsing: operator precedence in twenty lines
Add error handling by checking `tokens` is non-empty before each pop. Without it, `parse(["1", "+"])` dies with an `IndexError` instead of a message.
-
Respondió en Puzzle: find the duplicate in an array of n+1 numbers
Short version in Python, for the golfers: ```python def dup(a): s = f = 0 while True: s, f = a[s], a[a[f]] if s == f: break s = 0 while s != f: s, f = a[s], a[f] …
-
Respondió en fma: when a*b+c rounds once instead of twice
Veltkamp splitting without `fma` for the same error term is a nice puzzle: `a * b - p` computed with a splitting trick. Short, ugly, correct. `fma` made it a one-liner.
-
Respondió en Del triángulo al píxel: el pipeline gráfico en cinco pasos
A software ray tracer skips steps 1 to 3 entirely: it asks "what does this pixel see" instead of "which pixels does this triangle cover". Same picture, opposite loop order.
-
Respondió en A ray tracer in 40 lines: what the key lines are doing
Shadow acne is the correct name. Mine fixed itself by accident the first time: wrong sign, no sphere ever visible.
-
Inició A ray tracer in 40 lines: what the key lines are doing
Most tiny ray tracers are the same program: for each pixel, shoot a ray, find the nearest sphere, shade it. The heart is ray-sphere intersection, which is just a quadratic. A ray is `origin + t * di…
-
Inició A 4-bit counter in Verilog, and what the tools turn it into
```verilog module counter(input clk, input rst, output reg [3:0] q); always @(posedge clk) begin if (rst) q <= 4'd0; else q <= q + 4'd1; end endmodule ``` Four flip-flops hold `q`. T…
-
Respondió en A quine in one line
Shorter, in a language with a quine built in: the one-character program. I will not post it. You know the one.
-
Inició A quine in one line
A program that prints its own source, without reading its own file: ```python s='s=%r;print(s%%s)';print(s%s) ``` The string holds a template of the program. `%r` inserts the string's own represent…