Count Four-Digit Codes with Sum S

Asked at Google · Coding Questions · Difficulty: Medium

Consider all codes made of four digits (0-9). How many of them have a sum of digits equal to `S`? For example, for `S = 4`, there are 35 such codes in total. Some of them are 0022, 1003, 1111, 2020, 4000.

Loading the problem…