What Comes Next?

September 20, 2019

I couldn’t figure out the answer, but OEIS knows; the sequence is the list of numbers that are represented in Roman numerals by exactly four letters. We wrote a roman-numeral converter a long time ago, so this is easy:

> (filter (lambda (s) (= (string-length s) 4))
          (map number->roman (range 1 100)))
("VIII" "XIII" "XVII" "XXII" "XXIV" "XXVI" "XXIX" "XXXI"
 "XXXV" "XLII" "XLIV" "XLVI" "XLIX" "LIII" "LVII" "LXII"
 "LXIV" "LXVI" "LXIX" "LXXI" "LXXV" "LXXX" "XCII" "XCIV"
 "XCVI" "XCIX")

Or, if you prefer arabic numerals:

> (map roman->number
       (filter (lambda (s) (= (string-length s) 4))
               (map number->roman (range 1 100))))
(8 13 17 22 24 26 29 31 35 42 44 46 49 53 57 62 64 66 69 71
 75 80 92 94 96 99)

The answer to the puzzle question is 42. You can run the program at https://ideone.com/09fKbI, where you will also see the roman-numeral converters. As an interview question, I’m pretty sure that sucks.

Pages: 1 2

5 Responses to “What Comes Next?”

  1. Tom Magee said

    Just looking at the ones digit I see the following:

    8 3 7 2 4 6 9 1 5

    Which is 1 to 9 in an unusual arrangement. If the pattern holds the next ten numbers would be

    38 43 47 etc.

  2. Anonymous said

    How are you supposed to figure this out in an interview?

  3. Milbrae said

    Or maybe the ones from oeis.org/a178968…..

  4. Diego Osvaldo Solorio Lara said

    I found this relationship between these numbers.
    If you separate numbers from 4 to 4, you add the fourth and the first and you add the second and the third you get the same exact number

    13 + 17 = 30
    8 + 22 = 30

    24 + 31 = 55
    26 + 29 = 55

    then there is a relationship between the separated 4 numbers the first and second and the third and fourth have the same exact difference in both cases and the difference between second and third
    is different

    8,13,17,22
    5 4 5

    24,26,29,31
    2 3 2

    following this logic the differences can create a succession

    5, 4, 5
    2, 3, 2
    -1, 2,-1

    and using the nineth number (35) following this logic the next 3 numbers will be:

    35,34,36,35

    and then you add the first and fourth and the second and third you get the same exact number as in the first and second case

    35 + 35 = 70
    34 + 36 = 70

    So i guess the answer is 34

    i dont know if actually is the answer or i was overthinking

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: