Post History
Python 3, 149 bytes g=lambda r:r>1and g(r-1)+g(r-2)or r lambda n:[i for(i)in map(g,range(2*n+2))if(lambda*l:all(abs(n-i)!=1for(n,i)in zip(l,l[1:])))(*map(int,str(i)))][n] Try it online! ...
Answer
#2: Post edited
- # [Python 3], 149 bytes
- <!-- language-all: lang-python -->
- g=lambda r:r>1and g(r-1)+g(r-2)or r
- lambda n:[i for(i)in map(g,range(2*n+2))if(lambda*l:all(abs(n-i)!=1for(n,i)in zip(l,l[1:])))(*map(int,str(i)))][n]
- [Try it online!][TIO-ltbli504]
- Based on @isaacg's idea of mapping to twice the input, I had a similar thought, but I wasn't sure about the growth rate of the non-adjacent sequence...
- Here's a mashed up version of my previous attempt:
while len(l:=[*filter(g,[*map(lambda i:[*map(int,str(i))],map(h,range(j:=j+1)))])])<n+1:0- print(l[:-1])
- [Python 3]: https://docs.python.org/3/
- [TIO-ltbli504]: https://tio.run/##NY9NboMwEIX3nGK6wpNMJGz@kdyLEBaEGIJKHGS7UtsoZ6eGUs9iPPJ7n@fN3@720PEyyKm9X64tmMq881ZfYWDmxPG4NoEPAybo5XnZVbqqR@gfho04ari3MxvItHpQTBz0USCOPfuTHqaqnSbWXizTpxHfJF9tmjbjzziziaaaVw0issMKGrUj61YyYlPrZnHKOit3OsdAfc2qc@oq64i4L0ExpVQQ9y0lniQU5znxtMxJpEVCCS@8LM85pySLs4LyNBJeWGb@hVKeCFF6WxlHcepZZVQUPCuboLup7kMZkMDC86fIky4k2G48DjHwMcCRgj3GtiXB/3JYBeCP9e6eOdyG2fhsrA@f7gUVPO0LnvsftZLSNi9PXX4B "Python 3 – Try It Online"
- # [Python 3], 149 bytes
- <!-- language-all: lang-python -->
- g=lambda r:r>1and g(r-1)+g(r-2)or r
- lambda n:[i for(i)in map(g,range(2*n+2))if(lambda*l:all(abs(n-i)!=1for(n,i)in zip(l,l[1:])))(*map(int,str(i)))][n]
- [Try it online!][TIO-ltbli504]
- Based on @isaacg's idea of mapping to twice the input, I had a similar thought, but I wasn't sure about the growth rate of the non-adjacent sequence...
- Here's a mashed up version of my previous attempt:
- j=n
- while len(l:=[*filter(lambda*l:all(abs(n-i)!=1for(n,i)in zip(l,l[1:])),[*map(lambda i:[*map(int,str(i))],map(g,range(j:=j+1)))])])<n+1:0
- print(l[:-1])
- [Python 3]: https://docs.python.org/3/
- [TIO-ltbli504]: https://tio.run/##NY9NboMwEIX3nGK6wpNMJGz@kdyLEBaEGIJKHGS7UtsoZ6eGUs9iPPJ7n@fN3@720PEyyKm9X64tmMq881ZfYWDmxPG4NoEPAybo5XnZVbqqR@gfho04ari3MxvItHpQTBz0USCOPfuTHqaqnSbWXizTpxHfJF9tmjbjzziziaaaVw0issMKGrUj61YyYlPrZnHKOit3OsdAfc2qc@oq64i4L0ExpVQQ9y0lniQU5znxtMxJpEVCCS@8LM85pySLs4LyNBJeWGb@hVKeCFF6WxlHcepZZVQUPCuboLup7kMZkMDC86fIky4k2G48DjHwMcCRgj3GtiXB/3JYBeCP9e6eOdyG2fhsrA@f7gUVPO0LnvsftZLSNi9PXX4B "Python 3 – Try It Online"
#1: Initial revision
# [Python 3], 149 bytes <!-- language-all: lang-python --> g=lambda r:r>1and g(r-1)+g(r-2)or r lambda n:[i for(i)in map(g,range(2*n+2))if(lambda*l:all(abs(n-i)!=1for(n,i)in zip(l,l[1:])))(*map(int,str(i)))][n] [Try it online!][TIO-ltbli504] Based on @isaacg's idea of mapping to twice the input, I had a similar thought, but I wasn't sure about the growth rate of the non-adjacent sequence... Here's a mashed up version of my previous attempt: while len(l:=[*filter(g,[*map(lambda i:[*map(int,str(i))],map(h,range(j:=j+1)))])])<n+1:0 print(l[:-1]) [Python 3]: https://docs.python.org/3/ [TIO-ltbli504]: https://tio.run/##NY9NboMwEIX3nGK6wpNMJGz@kdyLEBaEGIJKHGS7UtsoZ6eGUs9iPPJ7n@fN3@720PEyyKm9X64tmMq881ZfYWDmxPG4NoEPAybo5XnZVbqqR@gfho04ari3MxvItHpQTBz0USCOPfuTHqaqnSbWXizTpxHfJF9tmjbjzziziaaaVw0issMKGrUj61YyYlPrZnHKOit3OsdAfc2qc@oq64i4L0ExpVQQ9y0lniQU5znxtMxJpEVCCS@8LM85pySLs4LyNBJeWGb@hVKeCFF6WxlHcepZZVQUPCuboLup7kMZkMDC86fIky4k2G48DjHwMcCRgj3GtiXB/3JYBeCP9e6eOdyG2fhsrA@f7gUVPO0LnvsftZLSNi9PXX4B "Python 3 – Try It Online"