login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Number of segments lit to display the number n on a 9-segment display used by the Russian postal service.
2

%I #53 Nov 20 2024 09:52:20

%S 6,3,4,4,4,5,5,3,7,5,9,6,7,7,7,8,8,6,10,8,10,7,8,8,8,9,9,7,11,9,10,7,

%T 8,8,8,9,9,7,11,9,10,7,8,8,8,9,9,7,11,9,11,8,9,9,9,10,10,8,12,10,11,8,

%U 9,9,9,10,10,8,12,10,9,6,7,7,7,8,8,6,10,8

%N Number of segments lit to display the number n on a 9-segment display used by the Russian postal service.

%H Bartlomiej Malarz, <a href="/A350131/b350131.txt">Table of n, a(n) for n = 0..99999</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Postal_codes_in_Russia#/media/File:Russian_postal_codes.svg">Postal code template</a>.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Postal_codes_in_Russia">Postal codes in Russia</a>.

%e The Russian postal service uses a special template for entering postal codes, which makes automatic sorting of their parcels faster. It has nine segments, and digits looks like this (please check the first link in the Links section for a more readable, graphical example):

%e ._ _ _ _ _ _ _

%e | | /| | /_ |_| |_ /_ / |_| |_|

%e |_| | /_ / | _| |_| | |_| /

%e The template for a single digit contains nine segments: four vertical, three horizontal and two diagonal:

%e Vertical Horizontal Diagonal

%e _

%e | | _ /

%e | | _ /

%e Using a combination of vertical, horizontal and/or diagonal segments, it is possible to create digits:

%e .

%e number of segments

%e =====================================

%e digit total vertical horizontal diagonal

%e ----- ----- -------- ---------- --------

%e 0 6 4 2 0

%e 1 3 2 0 1

%e 2 4 1 2 1

%e 3 4 0 2 2

%e 4 4 3 1 0

%e 5 5 2 3 0

%e 6 5 2 2 1

%e 7 3 1 1 1

%e 8 7 4 3 0

%e 9 5 2 2 1

%t Table[Total[IntegerDigits[n]/.{0->6, 1->3, 2->4, 3->4, 6->5, 7->3, 8->7, 9->5}], {n, 0, 79}] (* _Stefano Spezia_, Dec 17 2021 *)

%o (PHP)

%o <?php

%o $segments = [6, 3, 4, 4, 4, 5, 5, 3, 7, 5];

%o $maxvalue = 100;

%o for ($i = 0; $i <= $maxvalue; $i++) {

%o $usedSegments = array_sum(array_map(fn($n) => $segments[$n], str_split($i)));

%o echo $usedSegments . "\n";

%o } // Simplified by _Bartlomiej Malarz_, Oct 30 2024

%o (Python)

%o segments = [6, 3, 4, 4, 4, 5, 5, 3, 7, 5]

%o def a(n): return sum(segments[int(d)] for d in str(n))

%o print([a(n) for n in range(80)]) # _Michael S. Branicky_, Dec 22 2021

%Y Cf. A006942, A010371, A063720, A074458.

%Y Cf. A350177 (histogram).

%K nonn,base

%O 0,1

%A _Bartlomiej Malarz_, Dec 16 2021