Post History
Python 3, 49 47 44 35 bytes a=lambda x,y:+(x>=0)and(1+a(y,x-y)) Try it online! -3 bytes thanks to @Hakerh400 -9 bytes thanks to @Jo King Python 2, 50 bytes x,y=input() a=0 while...
Answer
#7: Post edited
- # [Python 3], <strike> 49 47 44</strike> 35 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:+(x>=0)and(1+a(y,x-y))
- [Try it online!][TIO-khlfbe2n]
- [Python 3]: https://docs.python.org/3/
- [TIO-khlfbe2n]: https://tio.run/##VcxNCsIwEEDhvacYcDOhE5hJUtoK9S4jXShoLNJFcvrYHwm4/Xi8OS/3d/Sl6PjU121SSJQvDabryEbjhNIoZko2G1PmzyMuqCiOCToxBuAM7akyCwW36cq@cstMYRiOOlT2fUf74r/2ZMX1v4lUto78Ea/M5Qs "Python 3 – Try It Online"
- _-3 bytes thanks to @Hakerh400_
_-9 bytes thanks to @Hakerh400_- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], <strike> 49 47 44</strike> 35 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:+(x>=0)and(1+a(y,x-y))
- [Try it online!][TIO-khlfbe2n]
- [Python 3]: https://docs.python.org/3/
- [TIO-khlfbe2n]: https://tio.run/##VcxNCsIwEEDhvacYcDOhE5hJUtoK9S4jXShoLNJFcvrYHwm4/Xi8OS/3d/Sl6PjU121SSJQvDabryEbjhNIoZko2G1PmzyMuqCiOCToxBuAM7akyCwW36cq@cstMYRiOOlT2fUf74r/2ZMX1v4lUto78Ea/M5Qs "Python 3 – Try It Online"
- _-3 bytes thanks to @Hakerh400_
- _-9 bytes thanks to @Jo King_
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#6: Post edited
# [Python 3], <strike>49 47</strike> 44 bytes- <!-- language-all: lang-python -->
a=lambda x,y:(x>=0)*(1if y<0else 1+a(y,x-y))- _-3 bytes thanks to @Hakerh400_
[Try it online!][TIO-khkxumxy][Python 3]: https://docs.python.org/3/[TIO-khkxumxy]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0kqjws7WQFNLwzAzTaHSxiA1pzhVwVA7UaNSp0K3UlPzf0FRZl6JRqKGoZGBjoK5IVAEAA "Python 3 – Try It Online"- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], <strike> 49 47 44</strike> 35 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:+(x>=0)and(1+a(y,x-y))
- [Try it online!][TIO-khlfbe2n]
- [Python 3]: https://docs.python.org/3/
- [TIO-khlfbe2n]: https://tio.run/##VcxNCsIwEEDhvacYcDOhE5hJUtoK9S4jXShoLNJFcvrYHwm4/Xi8OS/3d/Sl6PjU121SSJQvDabryEbjhNIoZko2G1PmzyMuqCiOCToxBuAM7akyCwW36cq@cstMYRiOOlT2fUf74r/2ZMX1v4lUto78Ea/M5Qs "Python 3 – Try It Online"
- _-3 bytes thanks to @Hakerh400_
- _-9 bytes thanks to @Hakerh400_
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#5: Post edited
# [Python 3], ~~49 47~~ 44 bytes- <!-- language-all: lang-python -->
- a=lambda x,y:(x>=0)*(1if y<0else 1+a(y,x-y))
- _-3 bytes thanks to @Hakerh400_
- [Try it online!][TIO-khkxumxy]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkxumxy]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0kqjws7WQFNLwzAzTaHSxiA1pzhVwVA7UaNSp0K3UlPzf0FRZl6JRqKGoZGBjoK5IVAEAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], <strike>49 47</strike> 44 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:(x>=0)*(1if y<0else 1+a(y,x-y))
- _-3 bytes thanks to @Hakerh400_
- [Try it online!][TIO-khkxumxy]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkxumxy]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0kqjws7WQFNLwzAzTaHSxiA1pzhVwVA7UaNSp0K3UlPzf0FRZl6JRqKGoZGBjoK5IVAEAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#4: Post edited
# [Python 3], ~~49~~ 47 bytes- <!-- language-all: lang-python -->
a=lambda x,y:0if x<0else 1if y<0else 1+a(y,x-y)[Try it online!][TIO-khkt9bm0][Python 3]: https://docs.python.org/3/[TIO-khkt9bm0]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsYgNac4VcEQyK6EsbUTNSp1KnQrNf8XFGXmlWgkahgaGegomBtqav4HAA "Python 3 – Try It Online"- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], ~~49 47~~ 44 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:(x>=0)*(1if y<0else 1+a(y,x-y))
- _-3 bytes thanks to @Hakerh400_
- [Try it online!][TIO-khkxumxy]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkxumxy]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0kqjws7WQFNLwzAzTaHSxiA1pzhVwVA7UaNSp0K3UlPzf0FRZl6JRqKGoZGBjoK5IVAEAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#3: Post edited
# [Python 3], <s>49</s> 47 bytes- <!-- language-all: lang-python -->
- a=lambda x,y:0if x<0else 1if y<0else 1+a(y,x-y)
- [Try it online!][TIO-khkt9bm0]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkt9bm0]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsYgNac4VcEQyK6EsbUTNSp1KnQrNf8XFGXmlWgkahgaGegomBtqav4HAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], ~~49~~ 47 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:0if x<0else 1if y<0else 1+a(y,x-y)
- [Try it online!][TIO-khkt9bm0]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkt9bm0]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsYgNac4VcEQyK6EsbUTNSp1KnQrNf8XFGXmlWgkahgaGegomBtqav4HAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#2: Post edited
# [Python 3], 49 bytes- <!-- language-all: lang-python -->
a=lambda x,y:0if x<0 else 1if y<0 else 1+a(y,x-y)Independently arrived at, but basically exact same format as test.[Try it online!][TIO-khkt32em]- [Python 3]: https://docs.python.org/3/
[TIO-khkt32em]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsZAITWnOFXBEMiphHO0EzUqdSp0KzX/FxRl5pVoJGoYGhnoKJgbamr@BwA "Python 3 – Try It Online"- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
- # [Python 3], <s>49</s> 47 bytes
- <!-- language-all: lang-python -->
- a=lambda x,y:0if x<0else 1if y<0else 1+a(y,x-y)
- [Try it online!][TIO-khkt9bm0]
- [Python 3]: https://docs.python.org/3/
- [TIO-khkt9bm0]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsYgNac4VcEQyK6EsbUTNSp1KnQrNf8XFGXmlWgkahgaGegomBtqav4HAA "Python 3 – Try It Online"
- # [Python 2], 50 bytes
- <!-- language-all: lang-python -->
- x,y=input()
- a=0
- while x>0:x,y,a=y,x-y,a+1
- print(a)
- An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently.
- [Try it online!][TIO-khkt3pl0]
- [Python 2]: https://docs.python.org/2/
- [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"
#1: Initial revision
# [Python 3], 49 bytes <!-- language-all: lang-python --> a=lambda x,y:0if x<0 else 1if y<0 else 1+a(y,x-y) Independently arrived at, but basically exact same format as test. [Try it online!][TIO-khkt32em] [Python 3]: https://docs.python.org/3/ [TIO-khkt32em]: https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRoUKn0sogM02hwsZAITWnOFXBEMiphHO0EzUqdSp0KzX/FxRl5pVoJGoYGhnoKJgbamr@BwA "Python 3 – Try It Online" # [Python 2], 50 bytes <!-- language-all: lang-python --> x,y=input() a=0 while x>0:x,y,a=y,x-y,a+1 print(a) An alternate solution I also came up with that I swear I should be able to make shorter, but can't think of it currently. [Try it online!][TIO-khkt3pl0] [Python 2]: https://docs.python.org/2/ [TIO-khkt3pl0]: https://tio.run/##K6gsycjPM/r/v0Kn0jYzr6C0REOTK9HWgKs8IzMnVaHCzsAKKKOTaFupU6ELpLUNuQqKMvNKNBI1//83NDLQMTcEAA "Python 2 – Try It Online"