8 kyu

Count the number of cubes with paint on

4,492 of 12,271jackchambers

Description:

Upon arriving at an interview, you are presented with a solid blue cube. The cube is then dipped in red paint, coating the entire surface of the cube. The interviewer then proceeds to cut through the cube in all three dimensions a certain number of times.

Your function takes as parameter the number of times the cube has been cut. You must return the number of smaller cubes created by the cuts that have at least one red face.

To make it clearer, the picture below represents the cube after (from left to right) 0, 1 and 2 cuts have been made.

Examples:
If we cut the cube 2 times, the function should return 26
If we cut the cube 4 times, the function should return 98
Puzzles

Stats:

CreatedJun 17, 2016
PublishedJun 17, 2016
Warriors Trained27311
Total Skips662
Total Code Submissions37651
Total Times Completed12271
JavaScript Completions4426
Ruby Completions423
Python Completions4492
C# Completions822
Shell Completions276
C++ Completions1241
Reason Completions23
C Completions439
Haskell Completions144
Julia Completions39
NASM Completions28
SQL Completions631
TypeScript Completions142
Factor Completions11
Dart Completions165
Scala Completions13
CoffeeScript Completions13
Total Stars264
% of votes with a positive feedback rating83% of 1537
Total "Very Satisfied" Votes1150
Total "Somewhat Satisfied" Votes240
Total "Not Satisfied" Votes147
Ad
Contributors
  • jackchambers Avatar
  • Unnamed Avatar
  • raulbc777 Avatar
  • aryan-firouzian Avatar
  • donaldsebleung Avatar
  • Dentzil Avatar
  • JohanWiltink Avatar
  • kzm Avatar
  • rowcased Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • ejini战神 Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • yLaWy Avatar
  • XoRMiAS Avatar
  • gifti Avatar
  • KayleighWasTaken Avatar
  • Leo_768 Avatar
Ad