Last active
May 2, 2023 15:44
-
-
Save newtykip/0a31694cfe267c0c83fff054e196a9bb to your computer and use it in GitHub Desktop.
one-line full adder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i,r,z,l,g,a=int,range,bin,len,lambda x,m,b:(y:=list(map(lambda t:i(t),("0"if(x>=0)else"1")+z(x&m)[2:])),[y.insert(0,0)for _ in r(100)if l(y)<b],y)[2],lambda x,y:(b:=max(l(z(x)[2:]),l(z(y)[2:]))+1,m:=i("1"*b,2),p:=g(x,m,b),q:=g(y,m,b),p.reverse(),q.reverse(),w:=0,o:=[(w^(a^b),w:=(a&b)|(w&((~a&b)|(a&~b))))[0]for(a,b)in zip(p,q)],o.append(w)if(x>0)and(y>0)else(),o.reverse(),(s:=0 if(o[0]==0)else-(2**(l(o)-1)),o.pop(0),o.reverse(),[s:=s+(2**i if(o[i]==1)else 0)for(i)in r(l(o))][-1])[3])[10] | |
print(a(5,-6)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec(bytes('ⱩⱲⱺⱬⱧ㵡湩ⱴ慲杮ⱥ楢Ɱ敬Ɱ慬扭慤砠洬戬⠺㩹氽獩⡴慭⡰慬扭慤琠椺琨Ⱙ∨∰晩砨㴾⤰汥敳ㄢ⤢稫砨洦嬩㨲⥝Ⱙ祛椮獮牥⡴ⰰ⤰潦 湩爠ㄨ〰椩⡬⥹戼ⱝ⥹せ孝㨺ㄭⱝ慬扭慤砠礬⠺㩢洽硡氨稨砨嬩㨲⥝氬稨礨嬩㨲⥝⬩ⰱ㩭椽∨∱截㈬Ⱙ㩰朽砨洬戬Ⱙ㩱朽礨洬戬Ⱙ㩷〽漬㴺⡛幷愨扞Ⱙ㩷⠽♡⥢⡼♷⠨慾戦簩愨縦⥢⤩嬩崰潦⡲ⱡ⥢湩稠灩瀨焬崩漬愮灰湥⡤⥷晩砨〾愩摮礨〾攩獬⡥Ⱙ㩯漽㩛ⴺ崱猬㴺‰晩漨せ㵝〽攩獬ⵥ㈨⨪氨漨⤱Ⱙ㩯漽ㅛ㨺孝㨺ㄭⱝ獛㴺⭳㈨⨪晩漨楛㵝ㄽ攩獬⤰潦⡲⥩湩爠氨漨⤩孝ㄭ⥝ㅛ崰','u16')[2:]) | |
print(a(5,-6)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment