Beta

Ferris Wheel Cabins

Description:

Challenge: The lockdown has ended and a group of friends want to take their families to the fairground.

They all want to ride on the main attraction: the ferris wheel!

                   __  __
               __ [_|]'_|] __
              [_|].-'-_-_'-._]
            _.'.'-.-''   '-.-'__
           [_|]-.'.  '   ' .'.-_]
          _/ /_/ '.'. ' ' .  .' -_
         [_|]_'    '.'_'_. .'  '._]
          |_|_| = = (.-_o) = = :-_'
         [_|] _    .//\/_\.    .-_]
           \_\_\ .'//_//_\\'. .-.
           [_|]_`./.-/.-.-.\_'-_]
             '.'.-'-//__.\.\\.'
              [_|]-/.-_ .-[_\\
               // // [_|]  \.\\
         _____//_//_________\.\\_____                                wheeeee!

However, there are some conditions:

  • Each cabin on the ferris wheel can hold up to 3 people, and each cabin must have at least 1 adult.

  • They all want to ride at the same time and don't want to leave anybody out, otherwise they wont ride at all.

  • Let's pretend the ferris wheel has an infinite number of cabins available.

Task:

Given two integers as arguments (number of adults, number of children) return the mininum number of cabins needed for the group to ride, otherwise return -1 if they decide not to ride at all.

Algorithms

Stats:

CreatedApr 1, 2021
PublishedApr 1, 2021
Warriors Trained132
Total Skips30
Total Code Submissions310
Total Times Completed57
JavaScript Completions57
Total Stars3
% of votes with a positive feedback rating77% of 37
Total "Very Satisfied" Votes25
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes5
Total Rank Assessments38
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Tiarama Avatar
Ad