Decode a variable-length quantityManchester encode a data streamCircular shift an arbitrary byte-array bitwiseDisplay a MIDI TrackOutput MSB-set aligned, delimited ASCIIBit Manipulator/ReaderBinary Countdown LengthThese are the Frequencies, KennethGolf a bit-reversal tableDecode a 7-segment displayCorrupting A Binary File By Interpreting It As Text

ESTA declined to the US

What is an air conditioner compressor hard start kit and how does it work?

Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?

Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday

Does this put me at risk for identity theft?

Colleagues speaking another language and it impacts work

Why do proponents of guns oppose gun competency tests?

How to draw a flow chart?

Is it a bad idea to offer variants of a final exam based on the type of allowed calculators?

Traveling from Germany to other countries by train?

Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?

The heat content of the products is more than that of the reactant in an ............. reaction

Unexpected route on a flight from USA to Europe

The actual purview of Her Majesty The Queen's Perogative?

Does this smartphone photo show Mars just below the Sun?

monolingual dictionary

Validation and verification of mathematical models

Where to pee in London?

Will a paper be retracted if a flaw in released software code invalidates its central idea?

Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?

Authenticating SOAP API via UsernameToken

How to halve redstone signal strength?

Generate a random point outside a given rectangle within a map

12V lead acid charger with LM317 not charging



Decode a variable-length quantity


Manchester encode a data streamCircular shift an arbitrary byte-array bitwiseDisplay a MIDI TrackOutput MSB-set aligned, delimited ASCIIBit Manipulator/ReaderBinary Countdown LengthThese are the Frequencies, KennethGolf a bit-reversal tableDecode a 7-segment displayCorrupting A Binary File By Interpreting It As Text






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4












$begingroup$


A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.



The way it works is fairly simple. As a big-endian series of bytes, the most significant bit (MSB) of each byte is a 1 to indicate that another VLQ byte follows. The remaining 7 bits of each byte make up the decoded value.



Example (from Wikipedia):



[ 0x86, 0xc3, 0x17 ] => 106903



enter image description here
Additional references: Wikipedia, Some Guy.



Challenge:



Given a variable-length quantity, convert it to it's integer value.



Input:



A list of one to four bytes or a 32-bit value type representing a valid VLQ of an integer.



Output:



The integer value of the VLQ input.



Rules and scoring:



  • This is code-golf, so shortest answer in bytes for each language wins.


  • Standard rules and default I/O rules apply.


  • Loopholes forbidden (of course).

  • Please provide link with a test for your code (TIO.run, etc).

  • A clear explanation for your answer is highly recommended.

  • Built-ins that handle this conversion are not banned, however not using them is a lot more interesting.

Test cases:



Input (VLQ) Output (int)

[ 0x00 ] => 0
[ 0x07 ] => 7
[ 0x7f ] => 127
[ 0x81, 0x00 ] => 128
[ 0xC0, 0x00 ] => 8192
[ 0xff, 0x7f ] => 16383
[ 0x81, 0x80, 0x00 ] => 16384
[ 0x86, 0xc3, 0x17 ] => 106903
[ 0xbd, 0x84, 0x40 ] => 1000000
[ 0xff, 0xff, 0x7f ] => 2097151
[ 0xC0, 0x80, 0x80, 0x00 ] => 134217728
[ 0xFF, 0xFF, 0xFF, 0x7F ] => 268435455


Note: you are not required to use hex literals to represent a byte as your input or output. You may use decimal literal ([ 129, 128, 0 ]), integer (0x818000) or any other reasonable byte/octet representation if better suited to your platform. Format is flexible as long as it represents 1-4 byte/octets.



Golf away!










share|improve this question









$endgroup$













  • $begingroup$
    Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
    $endgroup$
    – Arnauld
    8 hours ago










  • $begingroup$
    Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
    $endgroup$
    – gwaugh
    8 hours ago






  • 3




    $begingroup$
    @Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
    $endgroup$
    – gwaugh
    6 hours ago







  • 3




    $begingroup$
    This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
    $endgroup$
    – Arnauld
    6 hours ago

















4












$begingroup$


A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.



The way it works is fairly simple. As a big-endian series of bytes, the most significant bit (MSB) of each byte is a 1 to indicate that another VLQ byte follows. The remaining 7 bits of each byte make up the decoded value.



Example (from Wikipedia):



[ 0x86, 0xc3, 0x17 ] => 106903



enter image description here
Additional references: Wikipedia, Some Guy.



Challenge:



Given a variable-length quantity, convert it to it's integer value.



Input:



A list of one to four bytes or a 32-bit value type representing a valid VLQ of an integer.



Output:



The integer value of the VLQ input.



Rules and scoring:



  • This is code-golf, so shortest answer in bytes for each language wins.


  • Standard rules and default I/O rules apply.


  • Loopholes forbidden (of course).

  • Please provide link with a test for your code (TIO.run, etc).

  • A clear explanation for your answer is highly recommended.

  • Built-ins that handle this conversion are not banned, however not using them is a lot more interesting.

Test cases:



Input (VLQ) Output (int)

[ 0x00 ] => 0
[ 0x07 ] => 7
[ 0x7f ] => 127
[ 0x81, 0x00 ] => 128
[ 0xC0, 0x00 ] => 8192
[ 0xff, 0x7f ] => 16383
[ 0x81, 0x80, 0x00 ] => 16384
[ 0x86, 0xc3, 0x17 ] => 106903
[ 0xbd, 0x84, 0x40 ] => 1000000
[ 0xff, 0xff, 0x7f ] => 2097151
[ 0xC0, 0x80, 0x80, 0x00 ] => 134217728
[ 0xFF, 0xFF, 0xFF, 0x7F ] => 268435455


Note: you are not required to use hex literals to represent a byte as your input or output. You may use decimal literal ([ 129, 128, 0 ]), integer (0x818000) or any other reasonable byte/octet representation if better suited to your platform. Format is flexible as long as it represents 1-4 byte/octets.



Golf away!










share|improve this question









$endgroup$













  • $begingroup$
    Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
    $endgroup$
    – Arnauld
    8 hours ago










  • $begingroup$
    Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
    $endgroup$
    – gwaugh
    8 hours ago






  • 3




    $begingroup$
    @Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
    $endgroup$
    – gwaugh
    6 hours ago







  • 3




    $begingroup$
    This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
    $endgroup$
    – Arnauld
    6 hours ago













4












4








4





$begingroup$


A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.



The way it works is fairly simple. As a big-endian series of bytes, the most significant bit (MSB) of each byte is a 1 to indicate that another VLQ byte follows. The remaining 7 bits of each byte make up the decoded value.



Example (from Wikipedia):



[ 0x86, 0xc3, 0x17 ] => 106903



enter image description here
Additional references: Wikipedia, Some Guy.



Challenge:



Given a variable-length quantity, convert it to it's integer value.



Input:



A list of one to four bytes or a 32-bit value type representing a valid VLQ of an integer.



Output:



The integer value of the VLQ input.



Rules and scoring:



  • This is code-golf, so shortest answer in bytes for each language wins.


  • Standard rules and default I/O rules apply.


  • Loopholes forbidden (of course).

  • Please provide link with a test for your code (TIO.run, etc).

  • A clear explanation for your answer is highly recommended.

  • Built-ins that handle this conversion are not banned, however not using them is a lot more interesting.

Test cases:



Input (VLQ) Output (int)

[ 0x00 ] => 0
[ 0x07 ] => 7
[ 0x7f ] => 127
[ 0x81, 0x00 ] => 128
[ 0xC0, 0x00 ] => 8192
[ 0xff, 0x7f ] => 16383
[ 0x81, 0x80, 0x00 ] => 16384
[ 0x86, 0xc3, 0x17 ] => 106903
[ 0xbd, 0x84, 0x40 ] => 1000000
[ 0xff, 0xff, 0x7f ] => 2097151
[ 0xC0, 0x80, 0x80, 0x00 ] => 134217728
[ 0xFF, 0xFF, 0xFF, 0x7F ] => 268435455


Note: you are not required to use hex literals to represent a byte as your input or output. You may use decimal literal ([ 129, 128, 0 ]), integer (0x818000) or any other reasonable byte/octet representation if better suited to your platform. Format is flexible as long as it represents 1-4 byte/octets.



Golf away!










share|improve this question









$endgroup$




A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.



The way it works is fairly simple. As a big-endian series of bytes, the most significant bit (MSB) of each byte is a 1 to indicate that another VLQ byte follows. The remaining 7 bits of each byte make up the decoded value.



Example (from Wikipedia):



[ 0x86, 0xc3, 0x17 ] => 106903



enter image description here
Additional references: Wikipedia, Some Guy.



Challenge:



Given a variable-length quantity, convert it to it's integer value.



Input:



A list of one to four bytes or a 32-bit value type representing a valid VLQ of an integer.



Output:



The integer value of the VLQ input.



Rules and scoring:



  • This is code-golf, so shortest answer in bytes for each language wins.


  • Standard rules and default I/O rules apply.


  • Loopholes forbidden (of course).

  • Please provide link with a test for your code (TIO.run, etc).

  • A clear explanation for your answer is highly recommended.

  • Built-ins that handle this conversion are not banned, however not using them is a lot more interesting.

Test cases:



Input (VLQ) Output (int)

[ 0x00 ] => 0
[ 0x07 ] => 7
[ 0x7f ] => 127
[ 0x81, 0x00 ] => 128
[ 0xC0, 0x00 ] => 8192
[ 0xff, 0x7f ] => 16383
[ 0x81, 0x80, 0x00 ] => 16384
[ 0x86, 0xc3, 0x17 ] => 106903
[ 0xbd, 0x84, 0x40 ] => 1000000
[ 0xff, 0xff, 0x7f ] => 2097151
[ 0xC0, 0x80, 0x80, 0x00 ] => 134217728
[ 0xFF, 0xFF, 0xFF, 0x7F ] => 268435455


Note: you are not required to use hex literals to represent a byte as your input or output. You may use decimal literal ([ 129, 128, 0 ]), integer (0x818000) or any other reasonable byte/octet representation if better suited to your platform. Format is flexible as long as it represents 1-4 byte/octets.



Golf away!







code-golf conversion bitwise






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









gwaughgwaugh

3,9161 gold badge9 silver badges26 bronze badges




3,9161 gold badge9 silver badges26 bronze badges














  • $begingroup$
    Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
    $endgroup$
    – Arnauld
    8 hours ago










  • $begingroup$
    Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
    $endgroup$
    – gwaugh
    8 hours ago






  • 3




    $begingroup$
    @Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
    $endgroup$
    – gwaugh
    6 hours ago







  • 3




    $begingroup$
    This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
    $endgroup$
    – Arnauld
    6 hours ago
















  • $begingroup$
    Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
    $endgroup$
    – Arnauld
    8 hours ago










  • $begingroup$
    Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
    $endgroup$
    – gwaugh
    8 hours ago






  • 3




    $begingroup$
    @Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
    $endgroup$
    – gwaugh
    6 hours ago







  • 3




    $begingroup$
    This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
    $endgroup$
    – Arnauld
    6 hours ago















$begingroup$
Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
$endgroup$
– Arnauld
8 hours ago




$begingroup$
Is the last byte of the input guaranteed to be < 128? Or do we need to support cases such as [0x01, 0x80, 0x02] => 1?
$endgroup$
– Arnauld
8 hours ago












$begingroup$
Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
$endgroup$
– gwaugh
8 hours ago




$begingroup$
Inputs are guaranteed to be valid VLQ values, so last byte will always be MSB = 0.
$endgroup$
– gwaugh
8 hours ago




3




3




$begingroup$
@Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
$endgroup$
– gwaugh
6 hours ago





$begingroup$
@Arnauld I see better now what you were getting at, and in retrospect the case you mention would have been good to have required. In MIDI, for example, you'll be reading a stream of data and so you don't necessarily know which byte is the last one. The way it is written, guaranteeing that the last byte in the list is the last byte in the VLQ makes the MSB irrelevant and in fact kind of defeats the purpose of VLQ. As in, you wouldn't necessarily be able to use these (valid for the challenge) routines for MIDI file decoding. Totally my bad! Should have kept this in sandbox much longer...
$endgroup$
– gwaugh
6 hours ago





3




3




$begingroup$
This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
$endgroup$
– Arnauld
6 hours ago




$begingroup$
This is partly my bad as well because I think I've seen the challenge in the sandbox and didn't pay enough attention. But yes, that's what I had in mind: given a list of bytes, either output the first VLQ value or output all VLQ values.
$endgroup$
– Arnauld
6 hours ago










11 Answers
11






active

oldest

votes


















3












$begingroup$


Pari/GP, 24 bytes



a->fromdigits(a%128,128)


Try it online!






share|improve this answer









$endgroup$






















    2












    $begingroup$


    Jelly, 6 bytes



    %Ø⁷ḅØ⁷


    Try it online!



    Equivalent to alephalpha's Pari/GP answer.



    Method: Given $n$, output $n mod 128$, converted from base $128$ to decimal.






    share|improve this answer









    $endgroup$






















      2












      $begingroup$


      APL (dzaima/APL), 8 bytes





      128(⊣⊥|)


      Try it online!



      How:



      128(⊣⊥|) ⍝ Anonymous function
      128 | ⍝ Input modulo 128
      ⊣⊥ ⍝ Decoded from base 128





      share|improve this answer









      $endgroup$






















        1












        $begingroup$

        JavaScript (ES6), 29 bytes



        -2 bytes thanks to @Shaggy



        Takes input as an array of bytes.





        a=>a.map(p=c=>p=p<<7|c&127)|p


        Try it online!






        share|improve this answer











        $endgroup$






















          1












          $begingroup$


          05AB1E, 6 bytes



          žy%žyβ


          Try it online!



          ಠ_ಠ Why do both Jelly and 05AB1E have 2-byte constants for 128? Well... It's $2^7$. But surely those bytes could be used for something better, right?






          share|improve this answer









          $endgroup$






















            1












            $begingroup$

            APL+WIN, 22 bytes



            Prompts for a vector of integers:



            2⊥¯32↑,0 1↓⍉(8⍴2)⊤¯4↑⎕


            Try it online! Courtesy of Dyalog Classic



            Explanation:



            ¯4↑⎕ Pad the vector to 4 integers from the right.

            ⍉(8⍴2)⊤ Convert to a matrix of 8 bit values.

            ,0 1↓ drop the MSBs and flatten to a vector.

            2⊥¯32↑ pad bit vector to 32 bits starting at LSB and convert back to integer.





            share|improve this answer











            $endgroup$






















              1












              $begingroup$


              Japt, 10 8 bytes



              Takes input as an array of integers.



              muIÑ ìIÑ


              Try it or run all test cases (header in both converts from input format used in challenge)



              Saved 2 bytes by taking inspiration from alephalpha's solution.



              muIÑ ìIÑ :Implicit input of integer array
              m :Map
              u : Modulo
              I : 64
              Ñ : Multiply by 2
              ì :Convert to decimal
              IÑ : From base 64*2





              share|improve this answer











              $endgroup$






















                1












                $begingroup$


                Stax, 12 bytes



                ü╫ôà¡k2Wù}a☺


                Run and debug it at staxlang.xyz!



                Unpacked (14 bytes) and explanation:



                rk128%128i^#*+
                r Reverse 'cuz big-endian
                k Fold from the left using block:
                128% Modulize by 128
                128i^# Push 128 to the power of (one plus the iteration index)
                * Multiply
                + Add to the total
                Implicit print


                Stax has builtin base conversion, but it only works on strings. It almost works on lists of integers, though; the problem is in Stax's handling of 0.



                A string is a list of integers. When you're using such a list as a string, any zeroes are automatically converted to 32 as a nice shorthand for spaces. Since the builtin |b for base conversion treats its operand as a string rather than as a raw list of integers, any case with a zero will fail.



                10 bytes, fails on zeroes



                Ç┘_A♥∙QZ►╣
                {128%m128|b Unpacked
                 














                1












                $begingroup$


                Charcoal, 11 bytes



                I↨﹪θ¹²⁸¦¹²⁸


                Try it online! Link is to verbose version of code. Takes input as an array. Explanation:



                 θ Input array
                ﹪ ¹²⁸ Elementwise modulo 128
                ↨ ¹²⁸ Convert from base 128
                I Cast to string for implicit print





                sharea☺


                Run and debug it at staxlang.xyz!



                Unpacked (14 bytes) and explanation:



                rk128%128i^#*+
                r Reverse 'cuz big-endian
                k Fold from the left using block:
                128% Modulize by 128
                128i^# Push 128 to the power of (one plus the iteration index)
                * Multiply
                + Add to the total
                Implicit print


                Stax has builtin base conversion, but it only works on strings. It almost works on lists of integers, though; the problem is in Stax's handling of 0.



                A string is a list of integers. When you're using such a list as a string, any zeroes are automatically converted to 32 as a nice shorthand for spaces. Since the builtin |b for base conversion treats its operand as a string rather than as a raw list of integers, any case with a zero will fail.



                10 bytes, fails on zeroes



                Ç┘_A♥∙QZ►╣
                {128%m128|b Unpacked
                128%m Modulize each by 128
                128a☺


                Run and debug it at staxlang.xyz!



                Unpacked (14 bytes) and explanation:



                rk128%128i^#*+
                r Reverse 'cuz big-endian
                k Fold from the left using block:
                128% Modulize by 128
                128i^# Push 128 to the power of (one plus the iteration index)
                * Multiply
                + Add to the total
                Implicit print


                Stax has builtin base conversion, but it only works on strings. It almost works on lists of integers, though; the problem is in Stax's handling of 0.



                A string is a list of integers. When you're using such a list as a string, any zeroes are automatically converted to 32 as a nice shorthand for spaces. Since the builtin |b for base conversion treats its operand as a string rather than as a raw list of integers, any case with a zero will fail.



                10 bytes, fails on zeroes



                Ç┘_A♥∙QZ►╣
                {128%m128|b Unpacked
                128%m Modulize each by 128
                128a☺


                Run and debug it at staxlang.xyz!



                Unpacked (14 bytes) and explanation:



                rk128%128i^#*+
                r Reverse 'cuz big-endian
                k Fold from the left using block:
                128% Modulize by 128
                128i^# Push 128 to the power of (one plus the iteration index)
                * Multiply
                + Add to the total
                Implicit print


                Stax has builtin base conversion, but it only works on strings. It almost works on lists of integers, though; the problem is in Stax's handling of 0.



                A string is a list of integers. When you're using such a list as a string, any zeroes are automatically converted to 32 as a nice shorthand for spaces. Since the builtin |b for base conversion treats its operand as a string rather than as a raw list of integers, any case with a zero will fail.



                10 bytes, fails on zeroes



                Ç┘_A♥∙QZ►╣
                {128%m128|b Unpacked
                128%m Modulize each by 128
                128a☺


                Run and debug it at staxlang.xyz!



                Unpacked (14 bytes) and explanation:



                rk128%128i^#*+
                r Reverse 'cuz big-endian
                k Fold from the left using block:
                128% Modulize by 128
                128i^# Push 128 to the power of (one plus the iteration index)
                * Multiply
                + Add to the total
                Implicit print


                Stax has builtin base conversion, but it only works on strings. It almost works on lists of integers, though; the problem is in Stax's handling of 0.



                A string is a list of integers. When you're using such a list as a string, any zeroes are automatically converted to 32 as a nice shorthand for spaces. Since the builtin |b for base conversion treats its operand as a string rather than as a raw list of integers, any case with a zero will fail.



                10 bytes, fails on zeroes



                Ç┘_A♥∙QZ►╣
                {128%m128|b Unpacked
                {128%m Modulize each by 128
                128|b Convert from base 128


                Run and debug it at staxlang.xyz!







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 4 hours ago









                Khuldraeseth na'BaryaKhuldraeseth na'Barya

                1,7858 silver badges31 bronze badges




                1,7858 silver badges31 bronze badges
























                    1












                    $begingroup$


                    Charcoal, 11 bytes



                    I↨﹪θ¹²⁸¦¹²⁸


                    Try it online! Link is to verbose version of code. Takes input as an array. Explanation:



                     θ Input array
                    ﹪ ¹²⁸ Elementwise modulo 128
                    ↨ ¹²⁸ Convert from base 128
                    I Cast to string for implicit print





                    share|improve this answer









                    $endgroup$



















                      1












                      $begingroup$


                      Charcoal, 11 bytes



                      I↨﹪θ¹²⁸¦¹²⁸


                      Try it online! Link is to verbose version of code. Takes input as an array. Explanation:



                       θ Input array
                      ﹪ ¹²⁸ Elementwise modulo 128
                      ↨ ¹²⁸ Convert from base 128
                      I Cast to string for implicit print





                      share|improve this answer









                      $endgroup$

















                        1












                        1








                        1





                        $begingroup$


                        Charcoal, 11 bytes



                        I↨﹪θ¹²⁸¦¹²⁸


                        Try it online! Link is to verbose version of code. Takes input as an array. Explanation:



                         θ Input array
                        ﹪ ¹²⁸ Elementwise modulo 128
                        ↨ ¹²⁸ Convert from base 128
                        I Cast to string for implicit print





                        share|improve this answer









                        $endgroup$




                        Charcoal, 11 bytes



                        I↨﹪θ¹²⁸¦¹²⁸


                        Try it online! Link is to verbose version of code. Takes input as an array. Explanation:



                         θ Input array
                        ﹪ ¹²⁸ Elementwise modulo 128
                        ↨ ¹²⁸ Convert from base 128
                        I Cast to string for implicit print






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 2 hours ago









                        NeilNeil

                        86.8k8 gold badges46 silver badges183 bronze badges




                        86.8k8 gold badges46 silver badges183 bronze badges
























                            1












                            $begingroup$


                            Wolfram Language (Mathematica), 25 bytes



                            Fold[128#+#2&,#~Mod~128]&


                            Try it online!




                            Wolfram Language (Mathematica), 25 bytes



                            #~Mod~128~FromDigits~128&


                            Try it online!






                            share|improve this answer











                            $endgroup$



















                              1












                              $begingroup$


                              Wolfram Language (Mathematica), 25 bytes



                              Fold[128#+#2&,#~Mod~128]&


                              Try it online!




                              Wolfram Language (Mathematica), 25 bytes



                              #~Mod~128~FromDigits~128&


                              Try it online!






                              share|improve this answer











                              $endgroup$

















                                1












                                1








                                1





                                $begingroup$


                                Wolfram Language (Mathematica), 25 bytes



                                Fold[128#+#2&,#~Mod~128]&


                                Try it online!




                                Wolfram Language (Mathematica), 25 bytes



                                #~Mod~128~FromDigits~128&


                                Try it online!






                                share|improve this answer











                                $endgroup$




                                Wolfram Language (Mathematica), 25 bytes



                                Fold[128#+#2&,#~Mod~128]&


                                Try it online!




                                Wolfram Language (Mathematica), 25 bytes



                                #~Mod~128~FromDigits~128&


                                Try it online!







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 2 hours ago

























                                answered 2 hours ago









                                RomanRoman

                                5331 silver badge6 bronze badges




                                5331 silver badge6 bronze badges
























                                    0












                                    $begingroup$


                                    PHP, 42 bytes





                                    foreach($argv as$a)$r=$r<<7|$a&127;echo$r;


                                    Try it online! and verify all test cases.



                                    Input via command line args, output to STDOUT.






                                    share|improve this answer











                                    $endgroup$



















                                      0












                                      $begingroup$


                                      PHP, 42 bytes





                                      foreach($argv as$a)$r=$r<<7|$a&127;echo$r;


                                      Try it online! and verify all test cases.



                                      Input via command line args, output to STDOUT.






                                      share|improve this answer











                                      $endgroup$

















                                        0












                                        0








                                        0





                                        $begingroup$


                                        PHP, 42 bytes





                                        foreach($argv as$a)$r=$r<<7|$a&127;echo$r;


                                        Try it online! and verify all test cases.



                                        Input via command line args, output to STDOUT.






                                        share|improve this answer











                                        $endgroup$




                                        PHP, 42 bytes





                                        foreach($argv as$a)$r=$r<<7|$a&127;echo$r;


                                        Try it online! and verify all test cases.



                                        Input via command line args, output to STDOUT.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 7 hours ago

























                                        answered 7 hours ago









                                        gwaughgwaugh

                                        3,9161 gold badge9 silver badges26 bronze badges




                                        3,9161 gold badge9 silver badges26 bronze badges






























                                            draft saved

                                            draft discarded
















































                                            If this is an answer to a challenge…



                                            • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                            • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                              Explanations of your answer make it more interesting to read and are very much encouraged.


                                            • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                            More generally…



                                            • …Please make sure to answer the question and provide sufficient detail.


                                            • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                            draft saved


                                            draft discarded














                                            StackExchange.ready(
                                            function ()
                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f189471%2fdecode-a-variable-length-quantity%23new-answer', 'question_page');

                                            );

                                            Post as a guest















                                            Required, but never shown





















































                                            Required, but never shown














                                            Required, but never shown












                                            Required, but never shown







                                            Required, but never shown

































                                            Required, but never shown














                                            Required, but never shown












                                            Required, but never shown







                                            Required, but never shown







                                            Popular posts from this blog

                                            Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                                            The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                                            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу