let x be total number of boys, so 36-x gals.
we need to maximize:
x/3 + (36-x)/4 or x/12 + 9
to maximize, x should be maximum.
x should also be divisible by 12
as question says there are "some" gals, we cannot take x=36
so, x = 24
max students walking = 24/12 + 9 = 11
Whether you think you can or think you can't. You're right! - Henry Ford (1863 - 1947)