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 Find all unique quintuplets in an array that sum to a given target

BQN, 31 bytes {⍷(+´⊸=⟜𝕩∧5=≠)¨⊸/⥊(↕2¨𝕨)/¨<∧𝕨}´ This block function returns the empty array ⟨⟩ if the conditions cannot be satisfied. It works by sorting the input list to prevent having to fi...

posted 12d ago by panadestein‭

Answer
#1: Initial revision by user avatar panadestein‭ · 2025-03-18T18:36:00Z (12 days ago)
# [BQN], 31 bytes

    {⍷(+´⊸=⟜𝕩∧5=≠)¨⊸/⥊(↕2¨𝕨)/¨<∧𝕨}´

This block function returns the empty array ⟨⟩ if the conditions cannot be satisfied. It works by sorting the input list to prevent having to filter additional combinations, then we generate the power set and filter the length 5 lists that satisfy the sum criteria, and then deduplicate.

[BQN online REPL][Try]

[BQN]: https://mlochbaum.github.io/BQN/
[Try]: https://mlochbaum.github.io/BQN/try.html#code=RiDihpAge+KNtygrwrTiirg94p+c8J2VqeKIpzU94omgKcKo4oq4L+KliijihpUywqjwnZWoKS/CqDziiKfwnZWofcK0Cgp0ZXN0IOKGkCDin6gKICBbLTUsLTIsLTIsMSwzLDQsNl3igL8wCiAgWy01LC00LC0yLDAsMSwyLDZd4oC/MQogIFswLC0xLDIsM13igL80CiAgWzAsMSwtOSw2LDdd4oC/NgogIFswLDEsOSw5LDVd4oC/NDUKICBbMSw0LDYsOSwtNF3igL8xNgogIFsxLDAsOSw2LDUsMF3igL8yMQogIFsxLDAsOSw2LDUsNCw3XeKAvzIxCiAgWzEsMCw5LDYsNSw0LDQsN13igL8yMQogIFsxLDEsMiwyLDMsMyw0LDRd4oC/MTEKICBbLTEsMSwxLDEsMSwxLDNd4oC/NQrin6kKCkbCqCB0ZXN0