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 Are All Elements Equal?

JavaScript, 20 bytes Outputs false for truthy and true for falsey. a=>a.some(x=>x-a[0]) Try it online! Outputs true and false as normal. a=>new Set(a).size<2 Try it online!

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

Answer
#3: Post edited by user avatar Shaggy‭ · 2021-08-11T13:39:31Z (over 3 years ago)
  • # JavaScript (Node.js), 20 bytes
  • Outputs `false` for truthy and `true` for falsey.
  • <!-- language-all: lang-javascript -->
  • a=>a.some(x=>x-a[0])
  • [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzg/N1WjwtauQjcx2iBW839yfl5xfk6qXk5@uoZimka0oQ4UxmpqcqFLGoClzHTMsUmCdPwHAA)
  • # JavaScript, 20 bytes
  • Outputs `false` for truthy and `true` for falsey.
  • <!-- language-all: lang-javascript -->
  • a=>a.some(x=>x-a[0])
  • [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzg/N1WjwtauQjcx2iBW839yfl5xfk6qXk5@uoZimka0oQ4UxmpqcqFLGoClzHTMsUmCdPwHAA)
  • Outputs `true` and `false` as normal.
  • a=>new Set(a).size<2
  • [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i4vtVwhOLVEI1FTrzizKtXG6H9yfl5xfk6qXk5@ukaaRrShDhTGampyockZgGXMdMyxyIHU/wcA)
#2: Post edited by user avatar Shaggy‭ · 2021-08-11T13:37:33Z (over 3 years ago)
  • # JavaScript (Node.js), 20 bytes
  • Outputs `false` for truthy and `true` for falsey.
  • <!-- language-all: lang-javascript -->
  • a=>a.some(x=>x-a[0])
  • [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzg/N1WjwtauQjcx2iBW839yfl5xfk6qXk5@uoZimka0oQ4UxmpqcmFKGukY65jomAIl/wMA) (output is flipped in the footer for easier vaerification)
  • # JavaScript (Node.js), 20 bytes
  • Outputs `false` for truthy and `true` for falsey.
  • <!-- language-all: lang-javascript -->
  • a=>a.some(x=>x-a[0])
  • [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzg/N1WjwtauQjcx2iBW839yfl5xfk6qXk5@uoZimka0oQ4UxmpqcqFLGoClzHTMsUmCdPwHAA)
#1: Initial revision by user avatar Shaggy‭ · 2021-08-11T13:36:17Z (over 3 years ago)
# JavaScript (Node.js), 20 bytes

Outputs `false` for truthy and `true` for falsey.

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

    a=>a.some(x=>x-a[0])

[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzg/N1WjwtauQjcx2iBW839yfl5xfk6qXk5@uoZimka0oQ4UxmpqcmFKGukY65jomAIl/wMA) (output is flipped in the footer for easier vaerification)