OFFSET
0,1
LINKS
Bartlomiej Malarz, Table of n, a(n) for n = 0..99999
Wikipedia, Postal code template.
Wikipedia, Postal codes in Russia.
EXAMPLE
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):
._ _ _ _ _ _ _
| | /| | /_ |_| |_ /_ / |_| |_|
|_| | /_ / | _| |_| | |_| /
The template for a single digit contains nine segments: four vertical, three horizontal and two diagonal:
Vertical Horizontal Diagonal
_
| | _ /
| | _ /
Using a combination of vertical, horizontal and/or diagonal segments, it is possible to create digits:
.
number of segments
=====================================
digit total vertical horizontal diagonal
----- ----- -------- ---------- --------
0 6 4 2 0
1 3 2 0 1
2 4 1 2 1
3 4 0 2 2
4 4 3 1 0
5 5 2 3 0
6 5 2 2 1
7 3 1 1 1
8 7 4 3 0
9 5 2 2 1
MATHEMATICA
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 *)
PROG
(PHP)
<?php
$segments = [6, 3, 4, 4, 4, 5, 5, 3, 7, 5];
$maxvalue = 100; // how many integers needs to be generated
for($i=0; $i<=$maxvalue; $i++) {
$number = str_split($i);
$usedSegments = 0;
foreach($number as $n) {
$usedSegments += $segments[$n];
}
echo $usedSegments."\n";
}
(Python)
segments = [6, 3, 4, 4, 4, 5, 5, 3, 7, 5]
def a(n): return sum(segments[int(d)] for d in str(n))
print([a(n) for n in range(80)]) # Michael S. Branicky, Dec 22 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bartlomiej Malarz, Dec 16 2021
STATUS
approved