cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-5 of 5 results.

A172006 Shortest SNUSP representation of a number using only +, - and @.

Original entry on oeis.org

1, 2, 3, 4, 4, 5, 5, 5, 6, 7, 6, 7, 6, 7, 7, 8, 7, 7, 8, 8, 7, 8, 8, 9, 8, 8, 8, 8, 8, 9, 9, 9, 9, 8, 9, 10, 9, 9, 10, 10, 9, 10, 9, 10, 9, 10, 9, 10, 10, 10, 10, 10, 10, 10, 9, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 11, 10, 10, 10, 11, 11, 11, 10, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 12
Offset: 1

Views

Author

Darrell Plank (jar_czar(AT)msn.com), Jan 22 2010

Keywords

Comments

SNUSP is a programming language where each command is an individual letter. The four of concern here are +, -, @ and #. + increments the current data value, - decrements it, @ is a "subroutine call" and # is a "return". When an @ is encountered, a record of the location is put on a stack and execution continues. When a # is encountered, if there is a return point on the stack, the execution continues at that a single character beyond that return point. If there is no return point on the stack, execution terminates.
Thus "@@++#" would put the first two "@" return points on the stack, increment data twice, return from the second "@" to the last "+", increment the data once more, return from the first "@" to the first "+", increment the data two more times and finally terminate when it hits the "#" with no return points on the stack. The data is always initialized to zero so this effectively puts 5 into the data. In order to place a particular value into the data, there is a minimal string of these characters. The i-th element of the sequence gives the minimal number of characters (excluding the "#" which is always the last character) to produce an SNUSP program which sets the data to i. The string above is a minimal string to produce 5 and has four characters before the # so the 5th item in the sequence is 4.
Sequence A172005 is the same as this one but disallows the '-' command. Many values have smaller sequences by allowing the -. There are some sequences that can cut up to two characters off by using the -. I don't know if larger savings are possible or if the savings can become arbitrarily large.

Examples

			To produce 10, there are 4 minimal sequences, each of length 7 (as always, excluding the #): +@+++++# ++@@+++# +@++@++# ++@@@++# Thus a(10)=7. The first value that requires a - in its minimal representation is 25 which requires 8 characters. If we disallow the '-' command (as in sequence A172005), it requires 9 characters.
		

Crossrefs

Cf. A172005.

Programs

A172007 Numbers which require a - in their minimal SNUSP representation.

Original entry on oeis.org

25, 32, 40, 49, 50, 51, 52, 54, 62, 64, 67, 72, 79, 81, 82, 85, 92, 96, 100, 102, 122, 127, 128, 129
Offset: 1

Views

Author

Darrell Plank (jar_czar(AT)msn.com), Jan 22 2010

Keywords

Comments

SNUSP is a programming language where each command is an individual letter. The four of concern here are +, -, @ and #. + increments the current data value, - decrements it, @ is a "subroutine call" and # is a "return". When an @ is encountered, a record of the location is put on a stack and execution continues. When a # is encountered, if there is a return point on the stack, the execution continues at that a single character beyond that return point. If there is no return point on the stack, execution terminates.
Thus "@@++#" would put the first two "@" return points on the stack, increment data twice, return from the second "@" to the last "+", increment the data once more, return from the first "@" to the first "+", increment the data two more times and finally terminate when it hits the "#" with no return points on the stack. The data is always initialized to zero so this effectively puts 5 into the data. In order to place a particular value into the data, there is a minimal string of these characters. In some cases, allowing the '-' command can shorten this minimal string. This sequence is a list of numbers which require a - in their minimal sequence. All the numbers represented in the above sequence save at most 2 characters by allowing the -. Whether this is a maximum savings and whether the savings can be arbitrarily large is not known (at least not to me).

Examples

			Using both + and -, 25 can be represented as @-@@@+++# but if we only allow +, the minimal program is @++@@++++# so we only need 8 characters if we allow both + and - but 9 if we allow only + so that 25 requires a - in its minimal representation. It is the first value with this property and so is the first value in our sequence.
		

Crossrefs

Programs

A293771 Minimum number of steps needed to compute n using a machine that can read, write and add starting with the number 1.

Original entry on oeis.org

0, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 7, 8, 8, 8, 8, 9, 8, 9, 9, 9, 10, 10, 9, 10, 10, 9, 10, 11, 10, 11, 10, 11, 11, 11, 10, 11, 11, 11, 11, 12, 11, 12, 12, 11, 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 13, 13, 12, 12, 13, 13, 14, 13, 13, 13, 14, 12, 13, 13, 13, 13, 14, 13, 14, 13, 12, 13, 14, 13, 14, 14, 14, 14, 15
Offset: 1

Views

Author

Floris P. van Doorn, Oct 15 2017

Keywords

Comments

The machine has a cache which holds 1 integer and a memory which holds a list of integers.
The machine starts with a number 1 in cache and empty memory.
At every step, the machine can do one of three things:
(1) write the number from cache to a new position in memory;
(2) read any number from memory and put it in cache;
(3) add any number from memory to the number in cache.
a(n) is the minimum number of steps needed to get the number n in cache.
Conjecture: reading from memory (operation 2) is never needed to get to a number in the minimal number of steps.
Additional conjectures and comments by Glen Whitney, Oct 12 2021: (Start)
Conjecture II: For each n, there is a minimal-length program for n that stores numbers in memory in increasing order.
Conjecture III: For each n, there is a minimal-length program such that the difference between successive numbers stored in memory is strictly increasing.
All three conjectures are empirically verified for all programs of length 23 or less, and all values of n up to 2326. However, note that if you are allowed to specify the set of numbers that must be stored in memory, then the first conjecture fails for memory {1,3,9,27,30,54} and conjecture II fails for {1,3,9,27,30,54,60}. (These sequences of numbers in memory are similar to addition chains, see A003313.) Hence, a proof of the first conjecture might need to involve showing that every n has a "good" sequence of numbers that can be stored in memory to produce n, avoiding the need to invoke the read operation. Conjecture III supplies one speculative possibility of a property that might fill the role of "good." A proof of any of these conjectures would tremendously speed up computation of a(n) as compared to brute force. (End)
One can add a useless read instruction after the first operation of writing the initial one in cache to memory. Therefore, there is always a program one step longer than optimal that performs a read. Thus, in a numerical search, the first sign one might observe that read operations can be helpful is a tie for shortest between a program that does read and one that doesn't, for some value of n. However, no such ties occur for program length 21 or less. - Glen Whitney, Oct 23 2021

Examples

			For n = 23 we need 10 steps to get 23 in cache:
   1. Write 1 to memory
   2. Add 1 to cache (cache contains 2)
   3. Write 2 to memory
   4. Add 2 to cache (cache contains 4)
   5. Add 2 to cache (cache contains 6)
   6. Add 1 to cache (cache contains 7)
   7. Write 7 to memory
   8. Add 7 to cache (cache contains 14)
   9. Add 7 to cache (cache contains 21)
  10. Add 2 to cache (cache contains 23)
There are several other essentially different 10-step programs that result in 23 in cache, but no 9-step programs. (If a program differs just by the order of a sequence of successive additions, it's not considered essentially different.) Note that for all n < 2326, all of the numbers that have an essentially unique minimal program that puts a maximal set of numbers in memory are of the form 2^k, 1+2^k, 3^k, or 1+3^k, except for 5, 809 and 1609:
For n = 809 we need 21 steps: (1) W1; (2) A1 => 2; (3) A1 => 3; (4) W3; (5) A3 => 6; (6) A3 => 9; (7) A1 => 10; (8) W10; (9) A10 => 20; (10) W20; (11) A20 => 40; (12) W40; (13) A40 => 80; (14) W80; (15) A80 => 160; (16) A80 => 240; (17) A3 => 243; (18) W243; (19) A243 => 486; (20) A243 => 729; (21) A80 => 809.
n = 1609 can be computed most efficiently in 23 steps. The contents of memory when 1609 is reached are {1,3,10,20,40,80,160,483}; the precise steps can be inferred from these memory contents.
		

Crossrefs

Cf. A003313 (addition chains; similar except read/write are "free").

Programs

  • Mathematica
    PossibleNextStates[{n_, l_}] :=
    Join[{#, l} & /@ l,
      If[! MemberQ[l, n], {{n, Sort@Append[l, n]}}, {}], {n + #, l} & /@ l]
    states = {{1, {}}}; i = 0; c[1] = 0;
    Do[states = Union @@ PossibleNextSteps /@ states; i++;
      If[! IntegerQ[c[#[[1]]]], c[#[[1]]] = i] & /@ states, {14}];
    c /@ Range[88]

A172008 Number of minimal SNUSP programs using +, @ and # that yield n.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 2, 4, 2, 2, 4, 2, 6, 2, 2, 2, 8, 8, 4, 2, 2, 2, 2, 2, 2, 6, 2, 2, 10, 10, 4, 2, 8, 8, 2, 2, 4, 8, 2, 2, 2, 6, 14, 2, 4, 4, 8, 8, 2, 4, 2, 4, 2, 2, 2, 4, 6, 6, 2, 2, 2, 2, 4, 4, 18, 18, 2, 2, 4, 2, 8, 2, 10, 2, 2, 2, 4, 4, 6, 4, 4, 4, 2, 2, 2, 4, 6, 6, 2, 2, 2, 8, 2, 2, 6, 6, 2
Offset: 1

Views

Author

Darrell Plank (jar_czar(AT)msn.com), Jan 22 2010

Keywords

Comments

Shortest SNUSP representation of a number using only + and @ is in A172005.
SNUSP is a programming language where each command is an individual letter. The three of concern here are + and @ and #. + increments the current data value, @ is a "subroutine call" and # is a "return". When an @ is encountered, a record of the location is put on a stack and execution continues. When a # is encountered, if there is a return point on the stack, the execution continues at that a single character beyond that return point. If there is no return point on the stack, execution terminates.
Thus "@@++#" would put the first two "@" return points on the stack, increment data twice, return from the second "@" to the last "+", increment the data once more, return from the first "@" to the first "+", increment the data two more times and finally terminate when it hits the "#" with no return points on the stack. The data is always initialized to zero so this effectively puts 5 into the data. In order to place a particular value into the data, there are one or more minimal strings of these characters. The i-th term of the sequence gives the number of minimal SNUSP programs using only these characters. After 2, all sequences end in either +++ or @++, which are equivalent, so all values above a(2) are even.

Examples

			19 can be represented minimally in 6 ways using @, + and #: @+@+++++# +@@@++++# @++@@+++# @+@++@++# +@@@+@++# @++@@@++#. Thus a(19) = 6.
		

Crossrefs

Programs

A172009 Number of minimal SNUSP programs using +, -, @ and # that yield n.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 2, 2, 6, 12, 4, 8, 2, 4, 4, 10, 4, 2, 12, 4, 2, 6, 8, 10, 2, 2, 2, 2, 2, 2, 10, 2, 8, 2, 14, 22, 8, 2, 18, 8, 4, 14, 4, 12, 2, 4, 2, 8, 6, 2, 6, 6, 10, 2, 2, 4, 6, 4, 4, 2, 4, 2, 22, 8, 2, 4, 2, 2, 4, 6, 24, 6, 2, 2, 12, 2, 12, 4, 2, 2, 6, 6, 12, 18, 6, 4, 6, 6, 2, 2, 2, 2, 8, 12, 2, 2, 2
Offset: 1

Views

Author

Darrell Plank (jar_czar(AT)msn.com), Jan 22 2010

Keywords

Comments

SNUSP is a programming language where each command is an individual letter. The four of concern here are +, -, @ and #. + increments the current data value, - decrements it, @ is a "subroutine call" and # is a "return". When an @ is encountered, a record of the location is put on a stack and execution continues. When a # is encountered, if there is a return point on the stack, the execution continues at that a single character beyond that return point. If there is no return point on the stack, execution terminates.
Thus "@@++#" would put the first two "@" return points on the stack, increment data twice, return from the second "@" to the last "+", increment the data once more, return from the first "@" to the first "+", increment the data two more times and finally terminate when it hits the "#" with no return points on the stack. The data is always initialized to zero so this effectively puts 5 into the data. In order to place a particular value into the data, there are one or more minimal strings of these characters. The i-th term of the sequence is the number of minimal SNUSP programs using only these characters. After 2, all sequences end in either +++ or @++, which are equivalent, so all values above a(2) are even.

Examples

			There are 12 minimal programs which yield 10: +@+++++# @@-++++# -@@++++# -@+@+++# +@-@+++# ++@@+++# +@++@++# @@-+@++# -@@+@++# -@+@@++# +@-@@++# ++@@@++#. Thus a(10) = 12.
		

Crossrefs

Programs

Showing 1-5 of 5 results.