7 kyu

Simple Fun #38: House Of Cats

341 of 723myjinxin2015

Description:

Task

There are some people and cats in a house. You are given the number of legs they have all together. Your task is to return an array containing every possible number of people that could be in the house sorted in ascending order. It's guaranteed that each person has 2 legs and each cat has 4 legs.

Example

For legs = 6, the output should be [1, 3].

There could be either 1 cat and 1 person (4 + 2 = 6) or 3 people (2 * 3 = 6).

For legs = 2, the output should be [1].

There can be only 1 person.

Input/Output

  • [input] integer legs

    The total number of legs in the house.

    Constraints: 2 ≤ legs ≤ 100.

  • [output] an integer array

    Every possible number of people that can be in the house.

Puzzles

Stats:

CreatedJan 25, 2017
PublishedJan 25, 2017
Warriors Trained1336
Total Skips8
Total Code Submissions1782
Total Times Completed723
JavaScript Completions263
C# Completions93
Python Completions341
Ruby Completions51
Haskell Completions32
Total Stars12
% of votes with a positive feedback rating92% of 189
Total "Very Satisfied" Votes160
Total "Somewhat Satisfied" Votes27
Total "Not Satisfied" Votes2
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad