id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

peter@norvig.com > apartment_puzzle
prev  |  next  |  chance

Here's an old puzzle: Baker, Cooper, Fletcher, Miller and Smith live on different floors of an apartment house that contains only five floors. Baker does not live on the top floor. Cooper does not live on the bottom floor. Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper. Smith does not live on a floor adjacent to Fletcher's. Fletcher does not live on a floor adjacent to Cooper's. Where does everyone live? The function apartment_puzzle() should return a list of five floor numbers, each 1 through 5, denoting the floor of Baker, Cooper, Fletcher, Miller and Smith.


apartment_puzzle() → [3, 2, 4, 5, 1]

...Save, Compile, Run (ctrl-enter)

def apartment_puzzle():

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 258 Post-solution available

Copyright Nick Parlante 2017 - privacy