Le Monde puzzle [#1075]

A new Le Monde mathematical puzzle in the digit category:

Find the largest number such that each of its internal digits is strictly less than the average of its two neighbours. Same question when all digits differ.

For instance, n=96433469 is such a number. When trying pure brute force (with the usual integer2digits function!)

this is actually the largest number returned by the R code. There is no solution with 9 digits. Adding an extra condition

produces n=9520148 (seven digits) as the largest possible integer.

Related