Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Command: tr -- '-p=v,' '_ ' <input | dc -fdc-p1.dc
- # Calculate quadrant and increment
- [
- ly dd*v/ # y /= abs(y)
- lx dd*v/ # x /= abs(x); stack: sign(x) sign(y)
- 2*3r- + # index = 3 - sign(x) * 2 + sign(y) => {0, 2, 4, 6}
- d;q 1+ r:q
- ] sQ
- ? # stack: vy vx y x
- [
- # ASSUME: velocities on (-dim,dim) and position always non-negative
- # This means we can just add dim to velocities to have mod residues be non-negative.
- A3+ A0* 3R+ A3% 51- # y+=100*vy (mod 103), residue -51..51
- r A1+ A0* 3R+ A1% 50- # x+=100*vx (mod 101), residue -50..50
- # stack: x y (moved)
- dsx r dsy* 0!=Q # if (x*y) != 0, add to quad (pass by reg for clean stack)
- ? z0<M
- ] dsMx
- [Part 1: ]n 6;q4;q*2;q*0;q*p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement