Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Fibonacci without consecutive digits

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! ...

posted 2mo ago by ok12d‭  ·  edited 2mo ago by ok12d‭

Answer
#2: Post edited by user avatar ok12d‭ · 2024-03-03T14:43:07Z (2 months ago)
fix
  • # [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 by user avatar ok12d‭ · 2024-03-03T14:38:40Z (2 months ago)
# [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"