Timeline for Count of "a"s and "b"s must be equal. Did you get it computer?
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 26, 2016 at 22:02 | comment | added | anatolyg | @ninjalj You should post that in an answer - it's sufficiently different from mine, and I suspect is significantly shorter! | |
Jul 26, 2016 at 21:26 | comment | added | ninjalj |
The same thing using string ops, with ESI pointing to the input string, and returning the result in AL (uses SETcc, requires 386+): xor eax,eax | xor ecx,ecx | l1: inc ecx | lodsb | cmp al, 'a' | jz l1 | dec esi | l2: lodsb | cmp al,'b' | loopz l2 | or eax,ecx | setz al | ret
|
|
Jul 22, 2016 at 21:40 | comment | added | Jules |
I think you can improve your negation. Try: neg eax to set the carry flag as before, cmc to invert the carry flag and salc to set AL to FFh or 0 depending on whether the carry flag is set or not. Saves 2 bytes, although does end up with an 8-bit result rather than 32-bit.
|
|
Jul 21, 2016 at 20:23 | history | edited | anatolyg | CC BY-SA 3.0 |
golfing
|
Jul 21, 2016 at 19:55 | history | answered | anatolyg | CC BY-SA 3.0 |