Skip to main content
Commonmark migration
Source Link

Task

Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

 

72 105

 

which in bits are:

 

1001000 1101001

 

And the transition bits indicators:

 

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Task

Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

 

72 105

 

which in bits are:

 

1001000 1101001

 

And the transition bits indicators:

 

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Task

Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Clarify constraints
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32

Task

Given an input string of one or more ASCII characters which codepoints are less thanbetween 0 and 128 (exclusive), do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Task

Given an input string of ASCII characters which codepoints are less than 128, do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Task

Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Add the winner
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32

Task

Given an input string of ASCII characters which codepoints are less than 128, do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Task

Given an input string of ASCII characters which codepoints are less than 128, do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Task

Given an input string of ASCII characters which codepoints are less than 128, do the following:

  1. Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
  2. Concatenate all bits (this results in 7*n bits where n is the number of characters)
  3. For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.

#Example

Input:

Hi

Output:

11011001011101

Explanation:

The string "Hi" has the ASCII codes

72 105

which in bits are:

1001000 1101001

And the transition bits indicators:

11011001011101

This is code golf. Lowest byte count wins.

Test Cases

Test case 1:

Hello World!
110110010101110011010101101010110001110000111110000110000001011101101010101100110001

Test case 2:

%% COMMENT %%
1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111

Test case 3 (credit to Luis Mendo):

##
11100101110010

Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!

Tweeted twitter.com/StackCodeGolf/status/1149876302675156994
deleted 1 character in body
Source Link
Shaggy
  • 42.2k
  • 4
  • 34
  • 94
Loading
Add test case
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading
Clarify 7-bit ASCII characters.
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading
Clarify leading zeros.
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading
Post Reopened by Luis Mendo code-golf
Post Closed as "Duplicate" by Peter Taylor code-golf
Became Hot Network Question
Fix typo
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading
Add test cases
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading
Source Link
justhalf
  • 2.2k
  • 1
  • 19
  • 32
Loading