6 kyu

Sum Up to Target Non Adjacents elements

112 of 168knotman90

Description:

Given an array of ints, check if is it possible to choose a group of some of the ints, such that the group sums to the given target with this additional constraint: If a value in the array is chosen to be in the group, the value immediately following it in the array must not be chosen.

For example:

[2, 5, 10, 4], 12 → true

[2, 5, 10, 4], 14 → false

[2, 5, 10, 4], 7 → false


Note: input length from 0 to 20.

Lists
Recursion
Fundamentals

More By Author:

Check out these other kata created by knotman90

Stats:

CreatedNov 1, 2014
PublishedNov 1, 2014
Warriors Trained550
Total Skips102
Total Code Submissions1706
Total Times Completed168
Haskell Completions112
JavaScript Completions62
Total Stars7
% of votes with a positive feedback rating84% of 48
Total "Very Satisfied" Votes35
Total "Somewhat Satisfied" Votes11
Total "Not Satisfied" Votes2
Ad
Contributors
  • knotman90 Avatar
  • jhoffner Avatar
  • Unnamed Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • user8436785 Avatar
Ad