7 kyu

Enumerable Magic #5- True for Just One?

1,886 of 4,313bellmyer

Description:

Task

Create a function called one that accepts two params:

  • a sequence
  • a function

and returns true only if the function in the params returns true for exactly one (1) item in the sequence.

Example

one([1, 3, 5, 6, 99, 1, 3], bigger_than_ten) -> true
one([1, 3, 5, 6, 99, 88, 3], bigger_than_ten) -> false
one([1, 3, 5, 6, 5, 1, 3], bigger_than_ten) -> false

If you need help, here is a resource ( in Ruby ).

Fundamentals

Stats:

CreatedNov 5, 2014
PublishedNov 5, 2014
Warriors Trained6634
Total Skips319
Total Code Submissions11346
Total Times Completed4313
Ruby Completions789
JavaScript Completions1886
C# Completions353
C Completions193
NASM Completions18
Python Completions1207
Haskell Completions76
Total Stars48
% of votes with a positive feedback rating92% of 861
Total "Very Satisfied" Votes755
Total "Somewhat Satisfied" Votes82
Total "Not Satisfied" Votes24
Total Rank Assessments9
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • bellmyer Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • siebenschlaefer Avatar
  • user5036852 Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Souzooka Avatar
  • FArekkusu Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • albertogcmr Avatar
  • ejini战神 Avatar
Ad