HTC Global Services Interview Question
Software DevelopersCountry: India
Interview Type: Written Test
// ZoomBA
def prime_factors( n ){
select ( lfold ( [2:n+1] , dict() ) -> {
continue ( exists ( $.p.keySet ) :: { $.o /? $.$.o } )
$.p[$.o] = 0
for ( x = n ; $.o /? x ; x/= $.o ){ $.p[$.o] += 1 }
$.p
} ) :: { $.o.value > 0 }
}
println( prime_factors ( 36 ) )
Making it inhuman, and thus lovers of succinct syntax should like it.
We have made it a bit human readable. Feedback of inhuman came.
- NoOne October 09, 2016Next post, we would optimize it for math lovers.