# Minecraft XP Orb Amounts

In the video game Minecraft, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the player various amounts of XP. The possible orbs are shown in the image below, along with the smallest and largest amount of XP that orb can contain:

Source

In this challenge, you should output (as a finite sequence) the minimum units of XP that these orbs can contain; specifically, output the sequence

-32768
3
7
17
37
73
149
307
617
1237
2477


Standard loopholes are forbidden. As this is , the shortest program wins.

• Is there a trick to this that I'm missing, or is this just a simple kolmogorov-complexity problem? Oct 22, 2023 at 21:15
• This is not a KC challenge. KC is literally "output a constant value". If you're following standard sequence rules, then it's just a regular sequence challenge. Oct 23, 2023 at 1:46
• @hyper-neutrino It is a KC challenge. Challenges which output a constant finite sequence of values can be KC: codegolf.meta.stackexchange.com/a/9909/56656 Oct 23, 2023 at 16:28
• I thought I spotted the pattern, but there is one outlier, maybe a mistake was made during its construction?! Each positive lower bound is the next prime after double the prior term, except $37\times 2$ is $74$ (which would give $79$ as the next prime) rather than $72$ (giving $73$). Oct 23, 2023 at 17:32
• (...and, strictly speaking, $3$ I suppose :p) Oct 23, 2023 at 17:41

# JavaScript (Node.js), 37 bytes

n=>2.42*2**n-'21221452221'[n]|-!n<<15


Try it online!

# JavaScript (ES6), 39 bytes

Expects an integer $$\n\$$ and returns the $$\n\$$-th term, 0-indexed.

n=>309<<n>>7^"50954381462"[n]^7||-32768


Try it online!

# JavaScript (ES6), 46 bytes

The obvious method that returns a hard-coded array.

_=>[-32768,3,7,17,37,73,149,307,617,1237,2477]


Try it online!

# Jelly, 16 bytes

“Ḣƈ¤’b6ḄƤ+.⁽Ṭḥ;Ḥ


Try it online!

Outputs the full sequence, with trailing .0s due to a horrifyingly scuffed golf on the only way I could figure out how to compress -32768 that doesn't only break even as chained.

Based on the common doubling observation, this abuses the binary conversion builtin to compress a pattern in the maxima rather than the minima; before figuring out the +. trick “Ŀ¶ƈR’Do-ḄƤ⁽ṬḥḤ¤; tied (with “Ḣƈ¤’b6ḄƤḤ‘⁽ṬḥḤ¤;) by compressing the same pattern for the minima directly.

“Ḣƈ¤’               12414254
b6             converted to base 6:
“Ḣƈ¤’b6             [1, 1, 2, 2, 0, 2, 5, 2, 2, 2].
ḄƤ           "Convert" each prefix "from binary";
Ḅ            i.e. multiply and sum with powers of 2.
+.         Add 0.5 to each result,
⁽Ṭḥ;     prepend -16384,
Ḥ    and double.


# Nibbles, 14 bytes (28 nibbles)

:-32768 +~ =\ D6 *+@$~ 157332e  Attempt This Online! Similar 'difference-from-doubling-sequence' concept to leo848's answer & unrelated string's answer, but slightly different logic at each step. :-32768 +~ =\ D6 *+@$~ 157332e
D6       157332e  # convert from base-6
# to get:
# [2,1,2,2,0,2,5,2,2,2];
=\                    # now scan across this,
+@\$           #   adding each number to result-so-far
*   ~          #   and doubling
+~                       # add 1 to every element
:-32768                          # and prepend -32768


(Trivial compression would be 20.5 bytes)

# Rust, 49 bytes

Trivial solution. Takes a number and returns the sequence at that index.

|i|[-32768,3,7,17,37,73,149,307,617,1237,2477][i]


Attempt This Online!

# Rust, 76 bytes

Nontrivial solution. Relies on the fact that the numbers mostly double and then add to a fixed amount. This array could perhaps be golfed more, or be constructed in a different way. The scan also looks like it could be shortened somehow. Returns an iterator that contains the sequence.

||[-32768,65539,1,3,3,-1,3,9,3,3,3].iter().scan(0,|s,x|{*s=*s*2+x;Some(*s)})


Attempt This Online!

# Rust, 67 bytes

Same approach, but uses fold to automatically exhaust the iterator. Yes, the extra 3 is there on purpose although the value of the number is irrelevant. The output is cluttered with line numbers and debug stuff though, I am not aware on the consensus of this for .

||[65539,1,3,3,-1,3,9,3,3,3,3].iter().fold(-32768,|s,x|dbg!(s)*2+x)


Attempt This Online!

# 05AB1E, 15 14 bytes

•δ«иé•ηC·>žG(š


-1 byte thanks to @CommandMaster.

Try it online.

Explanation:

•δ«иé•         # Push compressed integer 1122025222
η        # Pop and push a list of its prefixes
C       # Convert each prefix from a binary-string to a base-10 integer
·      # Double each
>     # Increase each by 1
žG   # Push builtin integer 32768
(  # Negate it
š # Prepend this -32678 to the list
# (after which the list is output implicitly as result)


See this 05AB1E tip of mine (section How to compress large integers?) to understand why •δ«иé• is 1122025222.

• Ž€€ can be žG for -1 Oct 24, 2023 at 3:59
• @CommandMaster Woops.. completely forgot we have 2-byte builtins for almost all powers of 2. Thanks. Oct 24, 2023 at 6:45

# ARBLE, 40 bytes

-2^15,3,7,17,37,73,149,307,617,1237,2477


Ultra trivial solution. Outputs the first number with a trailing .0

Try it online!

# Charcoal, 23 bytes

⁺-”)‴⧴1³∧◨¤›✂⊗＆→⁵⊖；⁹WＴ∧


Try it online! Link is to verbose version of code. Outputs the entire sequence. Explanation: Simply compressing the whole string would have taken 27 bytes, but removal of the leading - allows Charcoal to compress the remainder into a 22-byte string (21 without the trailing delimiter) and then two bytes are used to prefix the - again.

Without string compression, the best I can do is 31 to port @UnrelatedString's Jelly answer for 26 bytes:

-32768¶ＩＥχ⍘⪫11…122025222ι²


Attempt This Online! Link is to verbose version of code. Outputs the entire sequence. Explanation:

-32768¶                     Literal string -32768\n
Implicitly print
χ                  Predefined variable 10
Ｅ                   Map over implicit range
11              Literal string 11
⪫                Join characters with
122025222    Literal string 122025222
…             Truncated to length
ι   Current value
⍘                 Converted from "base"
²  Literal integer 2
Ｉ                    Cast to string
Implicitly print


My previous 31-byte answer translated into a 40-byte ES6 solution, which has since been beaten by a couple of similar-looking answers:

f=
n=>n--?(155<<n>>5)-"1221463333"[n]:n<<15
<input type=number min=0 max=10 oninput=o.textContent=f(this.value)><pre id=o>

Returns the nth value (0-indexed).

# MathGolf, 20 bytes

cE#37FY_x5ò_∞ï┴)3▬+]


Try it online.

Explanation:

c          # Push -2
E         # Push 15
#        # Pop both, and push -2**15: -32768
3          # Push 3
7          # Push 7
F          # Push 17
Y          # Push 37
_          # Duplicate the 37
x         # Pop and reverse it to 73
5ò         # Loop 5 times,
ò         # using the following eight characters as inner code-block:
_        #  Duplicate the top
∞       #  Pop and double it
ï      #  Push the 0-based index
┴     #  Check whether it's equal to 1 (1 if index=1; 0 otherwise)
)    #  Increase it by 1 (2 if index=1; 1 otherwise)
3   #  Push a 3
▬  #  Pop both, and push 3**((index==1)+1)
+ #  Add it to the doubled value
]          # Wrap all values on the stack into a list
# (after which the entire stack is output implicitly as result)
`