7 kyu

Painted Sides

165 of 256anusha.j

Description:

Task

You are given a big cube, made up of several little cubes. You paint the outside of the big cube and are now supposed to find out how many of the little cubes have zero faces painted, one face painted, two faces painted, etc.

Write a function which accepts two parameters:

  1. length: the side length of the big cube (in little cubes), 0 <= length <= 50
  2. n: the number of faces painted, 0 <= n <= 7

You have to figure out how many of the little cubes have n faces painted.

Example

paintedFaces(4,3)

=> result: 8  -- Only the vertices of the big cube will have three faces painted
painted_faces(4,3)

=> result: 8  // Only the vertices of the big cube will have three faces painted
painted_faces(4,3)

=> result: 8  # Only the vertices of the big cube will have three faces painted
paintedFaces(4,3)

=> result: 8  // Only the vertices of the big cube will have three faces painted

If n > 3 then return 0 as it is not possible for a painted cube to have more than 3 sides painted (unless s == 1, in that case it will have 6 faces painted).

Mathematics
Logic
Puzzles

More By Author:

Check out these other kata created by anusha.j

Stats:

CreatedMar 4, 2024
PublishedMar 4, 2024
Warriors Trained723
Total Skips14
Total Code Submissions1435
Total Times Completed256
Python Completions165
C Completions33
λ Calculus Completions4
Haskell Completions25
JavaScript Completions64
Total Stars12
% of votes with a positive feedback rating91% of 57
Total "Very Satisfied" Votes48
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes1
Total Rank Assessments18
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • anusha.j Avatar
  • JohanWiltink Avatar
  • rowcased Avatar
Ad