|
Message-ID: <20140421082604.GA1903@openwall.com> Date: Mon, 21 Apr 2014 12:26:05 +0400 From: Aleksey Cherepanov <lyosha@...nwall.com> To: john-users@...ts.openwall.com Subject: Re: one decimal digit adder using rules (2+3 -> 5) On Mon, Apr 21, 2014 at 01:14:50AM +0200, magnum wrote: > On 2014-04-20 17:08, Aleksey Cherepanov wrote: > >I made an adder using rules. It works for 2 numbers of 1 decimal > >digit each. I'll describe two approaches. > ... > >/+ {\[} M s0w s1e s2r s3t s4y s5u s6i s7o s8p s9\[ \[ X010 Az"9a" > >va01 /9 vbp0 vcba R M L Dc Xc1c L M R Xb1b Dc /8 vbp0 vcba R M L Dc > >Xc1c L M R Xb1b Dc /7 vbp0 vcba R M L Dc Xc1c L M R Xb1b Dc /6 vbp0 > >vcba R M L Dc Xc1c L M R Xb1b Dc /5 vbp0 vcba R M L Dc Xc1c L M R > >Xb1b Dc /4 vbp0 vcba R M L Dc Xc1c L M R Xb1b Dc /3 vbp0 vcba R M L > >Dc Xc1c L M R Xb1b Dc /2 vbp0 vcba R M L Dc Xc1c L M R Xb1b Dc /1 > >vbp0 vcba R M L Dc Xc1c L M R Xb1b Dc sw0 se1 sr2 st3 sy4 su5 si6 so7 > >sp8 s\[9 \[ \]\] > > Pretty much hopeless finding a typo in that one :-) No, debugging of rules is not that hard: 1) Comment out other rules. 2) Clone rule many times. 3) Reduce rules incrementally going from bottom to the top. So we have # other rules aa aabb aabbcc # other rules instead of other rules aabbcc other rules 4) Add unique labels for each output to bypass dupes suppression aa Az" (variant 1)" aabb Az" (variant 2)" aabbcc Az" (variant 3)" One could use a one-liner to do the job: perl -lpe 's/$/$k++; qq{ Az" (variant $k)"}/e' Editors like emacs and vim allow user to pass some region through a filter easily (emacs: having active region C-u M-| ..., vim: V <selection> ! ...). 5) Run failing test and see where is the problem, dig there. ... aa Az" (variant 1)" aab Az" (variant 1.5)" aabb Az" (variant 2)" ... > An external filter might be another viable approach for this. Multiline expressions could be evaluated too using global vars to store state between candidates / lines of input. So Turing complete interpreter could implemented. When external mode will get ability to produce many candidates from one line of input such interpreter could be used to generate candidates or something else. Maybe john would be able to compile itself someday. %-) Thanks! -- Regards, Aleksey Cherepanov
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.