7 kyu

Enumerable Magic #5- True for Just One?

1,260 of 4,426bellmyer

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 Trained6792
Total Skips323
Total Code Submissions11596
Total Times Completed4426
Ruby Completions793
JavaScript Completions1926
C# Completions358
C Completions207
NASM Completions19
Python Completions1260
Haskell Completions79
Total Stars51
% of votes with a positive feedback rating92% of 876
Total "Very Satisfied" Votes767
Total "Somewhat Satisfied" Votes84
Total "Not Satisfied" Votes25
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
  • KayleighWasTaken Avatar
Ad