Compute 2018 #4

Find the smallest 9 9 -digit number a b c d e f g h i \overline{abcdefghi} with distinct non-zero digits a , b , c , d , e , f , g , h , a, b, c, d, e, f, g, h, and i , i, such that a b c + b c d + c d e + f g + g h + h i = 2018. \overline{abc} + \overline{bcd} + \overline{cde} + \overline{fg} + \overline{gh} + \overline{hi} = 2018.


The answer is 178429563.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Zeeshan Ali
May 17, 2018
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import itertools # https://docs.python.org/2/library/itertools.html#itertools.permutations

# set of all the possible 9 non-zero-digit numbers in acending order
permutations = list(itertools.permutations([i for i in range(1, 10)], 9))

for p in permutations: # for every p = (a, b, c, d, e, f, g, h, i) in above set
    if ((p[0]*100+p[1]*10+p[2]) # abc
        +(p[1]*100+p[2]*10+p[3]) # +bcd
        +(p[2]*100+p[3]*10+p[4]) # +cde
        +(p[5]*10+p[6]) # +fg
        +(p[6]*10+p[7]) # +gh
        +(p[7]*10+p[8])) == 2018: # +hi = 2018
        print (p) # print the elements or digits of that number 'p'
        break

(1, 7, 8, 4, 2, 9, 5, 6, 3)

Giorgos K.
May 17, 2018

M a t h e m a t i c a Mathematica code

(f=FromDigits)@First@Select[Permutations@Range@9,f@#[[1;;3]]+f@#[[2;;4]]+f@#[[3;;5]]+f@#[[6;;7]]+f@#[[7;;8]]+f@#[[8;;9]]==2018&]

returns 178429563 \boxed{178429563}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...