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

66%
+2 −0
Challenges Implement Rule 110

JavaScript (Node.js), 160 bytes (r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
#5: Post edited by user avatar Moshi‭ · 2021-11-17T05:55:15Z (about 3 years ago)
I'm stupid and missed the part where it said I could use a list instead of string. Cut out the converter function
  • # [JavaScript (Node.js)], 247 bytes
  • <!-- language-all: lang-javascript -->
  • g=(r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=>p(n,i-2*l-n))
  • f=(r,l,i,h=s=>[...s].map(x=>x=='+'?1:0))=>g(h(r),h(l),i).reduce((a,c)=>a+'-+'[c],'')
  • [Try it online!][TIO-kw2k3s91]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-kw2k3s91]: https://tio.run/##tVRta9swEP5c/Qoh1lmKZGM3/ZRNCfsyGAw22EdjVmMriYdmG0seGcW/PTvLzksZDUnbyMjI9/I8d@fT/Ur/pCZritr6ZZWr7XYlaSNyUQotm0CrcmXXwsh8d6wlLUXB5LxckDCKItghie8nNfV9UPgR43fw0dvwaDjwiCWzYi7D98VHs8jjIpk1MS1uNdfsVieAFQdB8Klp0r/0fqK5AYSSJcHvtKb0pyNzOP7dRPslY2jZh6hFIdbSDM5msN7I@UZKj3uLaBYy8FvRNW2YWFPNACdoVN5mitJUZKBMuedzL84S4Xlsm1WlsbhptYKMsMRLhAaRVcYaEMQIw3p0736ROrVWNSWZYeITcZDrKkt1Lz0WFmCa2gIQQRMeKdSmVplVuYOBRZyqExez8RfQ8Vfw@S9K7xw@/laEvE8QNj8nSf5WWfLxOSfTy/omOlXYV1T2YkK@X1do1@ez5Pw6F2R6ipGfX1z/wvJOny0vEP@3r3Fzpic6yv3fJ62FEoSWVYNpPxNxtRxmI4Ng0M04P5VptYVpOQ5SZxmMEQpnH7iwxvMhGPZhBKm0ApMVfUDfBzc8w@8ej3E69LWHOMgdYoe@7MEOqgNBh761tm6t0w1xdmh3wlIOAe2KgBeY/GizTBlDwIN8TgutcoH3eoL5U4/uAd1AEt32Hw "JavaScript (Node.js) – Try It Online"
  • # [JavaScript (Node.js)], 160 bytes
  • <!-- language-all: lang-javascript -->
  • (r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=>p(n,i-2*l-n))
  • [Try it online!][TIO-kw3406t4]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-kw3406t4]: https://tio.run/##tVVba9swFH62foUw6yxHsombPqVVwl4Kg40V@mjMamwlc1FlI8klI/i3Z7Js58JoSNpGQSCdy/edcyKf85y@piqTRaUDUeZss6AbJElOBOFUhpyJpf5DFM2HY0WRIIVPZ2LujqMoMnvsxjejCgWBUQSRj6/NpbXBUXfAkZ9Mixkdfy3u1DyPi2QqY1Rcccz9K54YrDgMw29Spn/RzYhjZRCEn4QvaYXQb0tmcYLrEQ@E72@yUigNZc2ZIYcUoirVmklBIC@zlBNYmFuqC2PmQzqDa@AsapG1Amh8X5nU97J8eeC1@lmIWj1qWYglMsbG0pFM11LANibVBbGisxWlHvbm0XTsA6cBg9ECHcHro/IJcOCwjpjb2A@M99LYSkPJ8jpjCKUks8mlEEMvwF6cJQR6nn8LGgC6CmmmtDL1iUHruQYDrttH5k6hG7hkJ7chtNJ94S4KoxnvKdiqYplmuYUxy7WqhpzNht9Bhz/AF7wrvVP48GcR4jZBs/EpSeLPyhL3v1MyPe/dRMcK@4HKnk2It@sCz/XtLDG@zAcyOcaITy9ucGZ5J2@W1xD/ty/x5UyOvCj7/x48LZAAsCglRG1PhOWi641twwdOP06Yqrk23bKfK9Yy3E4We@vHiz3vNefbHqTkzJgs0RN46NzgFH5Z7@M04EcLsZNbxAZ834LtVDuCBvyqdVVrq@vibMBwgpR2AQ1FgHPoPtZZxpRyjYd7nxac5QRu9a6ZGAcezRNw2rmx@Qc "JavaScript (Node.js) – Try It Online"
#4: Post undeleted by user avatar Moshi‭ · 2021-11-16T20:37:48Z (about 3 years ago)
#3: Post edited by user avatar Moshi‭ · 2021-11-16T20:37:33Z (about 3 years ago)
(Pasted a previous wrong version)
  • # [JavaScript (Node.js)], 243 bytes
  • <!-- language-all: lang-javascript -->
  • g=(r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=>p(n,i-2*l-n))
  • f=(r,l,i,h=s=>[...s].map(x=>x=='+'))=>g(h(r),h(l),i).reduce((a,c)=>a+'-+'[c],'')
  • [Try it online!][TIO-kw2jzi64]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-kw2jzi64]: https://tio.run/##tVTfa9swEH6u/gph1lmKZBM3fcqmhL0MBoMN9mjMamwl8dBsI8kjo/hvz86yE6eMhqRtZGTk@/F9d@fT/Ur/pCbTRW2DssrlbrcWRPOcl1wJHSpZru2GG5Hvj7UgJS@oWJRLbxpFEeypF99PahIEoAgiyu7go7NhUX9gEU3mxUJM3xcfzTKPi2SuY1LcKqborUoAKw7D8JPW6V9yP1HMAEJJk/B3WhPy05E5nOBuooKSUrTqQlS84BthemfTW2/FYiuEz3wKPmuyIZryDVEUMEIt8yaThKQ8A2XK/ID5cZZw36e7rCqNxbpRErLBAq8Q6kVWGmtAECMM69G9u@XVqbVSl94ce4HHR7mqslR10mNhAaapLQARNNMjhdzWMrMydzCwPKdq@cVs7AV07BV8wYvSO4ePvRUh6xKEzc5Jkr1Vlmx4zsn0sr6JThX2FZW9mJAd1hXa9fksGbvOBZmdYmTnFze4sLyzZ8sLxP/ta9yc2YmOcv/3SWuhBKFVpTHpZiKuVv1spBAMuhnmpzSNsjAth0HqLMMhQu7sQxfWcB6DoR8GkEpJMFmTB/S9d8Nz/O7xGKdFXzuIUe4QW/TlADaqRoIWfWts3Vin6@Ns0f6EhegD2hcBL7H3o8kyaYwHHt7ntFAy5/ig9zB76tE@oBtIot39Aw "JavaScript (Node.js) – Try It Online"
  • # [JavaScript (Node.js)], 247 bytes
  • <!-- language-all: lang-javascript -->
  • g=(r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=>p(n,i-2*l-n))
  • f=(r,l,i,h=s=>[...s].map(x=>x=='+'?1:0))=>g(h(r),h(l),i).reduce((a,c)=>a+'-+'[c],'')
  • [Try it online!][TIO-kw2k3s91]
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-kw2k3s91]: https://tio.run/##tVRta9swEP5c/Qoh1lmKZGM3/ZRNCfsyGAw22EdjVmMriYdmG0seGcW/PTvLzksZDUnbyMjI9/I8d@fT/Ur/pCZritr6ZZWr7XYlaSNyUQotm0CrcmXXwsh8d6wlLUXB5LxckDCKItghie8nNfV9UPgR43fw0dvwaDjwiCWzYi7D98VHs8jjIpk1MS1uNdfsVieAFQdB8Klp0r/0fqK5AYSSJcHvtKb0pyNzOP7dRPslY2jZh6hFIdbSDM5msN7I@UZKj3uLaBYy8FvRNW2YWFPNACdoVN5mitJUZKBMuedzL84S4Xlsm1WlsbhptYKMsMRLhAaRVcYaEMQIw3p0736ROrVWNSWZYeITcZDrKkt1Lz0WFmCa2gIQQRMeKdSmVplVuYOBRZyqExez8RfQ8Vfw@S9K7xw@/laEvE8QNj8nSf5WWfLxOSfTy/omOlXYV1T2YkK@X1do1@ez5Pw6F2R6ipGfX1z/wvJOny0vEP@3r3Fzpic6yv3fJ62FEoSWVYNpPxNxtRxmI4Ng0M04P5VptYVpOQ5SZxmMEQpnH7iwxvMhGPZhBKm0ApMVfUDfBzc8w@8ej3E69LWHOMgdYoe@7MEOqgNBh761tm6t0w1xdmh3wlIOAe2KgBeY/GizTBlDwIN8TgutcoH3eoL5U4/uAd1AEt32Hw "JavaScript (Node.js) – Try It Online"
#2: Post deleted by user avatar Moshi‭ · 2021-11-16T20:35:09Z (about 3 years ago)
#1: Initial revision by user avatar Moshi‭ · 2021-11-16T20:34:19Z (about 3 years ago)
# [JavaScript (Node.js)], 243 bytes

<!-- language-all: lang-javascript -->

    g=(r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=>p(n,i-2*l-n))
    f=(r,l,i,h=s=>[...s].map(x=>x=='+'))=>g(h(r),h(l),i).reduce((a,c)=>a+'-+'[c],'')

[Try it online!][TIO-kw2jzi64]

[JavaScript (Node.js)]: https://nodejs.org
[TIO-kw2jzi64]: https://tio.run/##tVTfa9swEH6u/gph1lmKZBM3fcqmhL0MBoMN9mjMamwl8dBsI8kjo/hvz86yE6eMhqRtZGTk@/F9d@fT/Ur/pCbTRW2DssrlbrcWRPOcl1wJHSpZru2GG5Hvj7UgJS@oWJRLbxpFEeypF99PahIEoAgiyu7go7NhUX9gEU3mxUJM3xcfzTKPi2SuY1LcKqborUoAKw7D8JPW6V9yP1HMAEJJk/B3WhPy05E5nOBuooKSUrTqQlS84BthemfTW2/FYiuEz3wKPmuyIZryDVEUMEIt8yaThKQ8A2XK/ID5cZZw36e7rCqNxbpRErLBAq8Q6kVWGmtAECMM69G9u@XVqbVSl94ce4HHR7mqslR10mNhAaapLQARNNMjhdzWMrMydzCwPKdq@cVs7AV07BV8wYvSO4ePvRUh6xKEzc5Jkr1Vlmx4zsn0sr6JThX2FZW9mJAd1hXa9fksGbvOBZmdYmTnFze4sLyzZ8sLxP/ta9yc2YmOcv/3SWuhBKFVpTHpZiKuVv1spBAMuhnmpzSNsjAth0HqLMMhQu7sQxfWcB6DoR8GkEpJMFmTB/S9d8Nz/O7xGKdFXzuIUe4QW/TlADaqRoIWfWts3Vin6@Ns0f6EhegD2hcBL7H3o8kyaYwHHt7ntFAy5/ig9zB76tE@oBtIot39Aw "JavaScript (Node.js) – Try It Online"