Cody

# Problem 45242. String to Binary Representation

Solution 2068241

Submitted on 24 Dec 2019 by Binbin Qi
• Size: 12
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
message = 'People who succeed have momentum. The more they succeed, the more they want to succeed and the more they find a way to succeed. Similarly, when someone is failing, the tendency is to get on a downward spiral that can even become a self-fulfilling prophecy.'; y_correct='00001010101001101111011000001110001101101010011000000100111011100001011011110110000001001100111010101110110001101100011010100110101001100010011000000100000101101000011001101110101001100000010010110110111101101011011010100110011101100010111010101110101101100111010000000100001010100001011010100110000001001011011011110110010011101010011000000100001011100001011010100110100111100000010011001110101011101100011011000110101001101010011000100110001101000000010000101110000101101010011000000100101101101111011001001110101001100000010000101110000101101010011010011110000001001110111010000110011101100010111000000100001011101111011000000100110011101010111011000110110001101010011010100110001001100000010010000110011101100010011000000100001011100001011010100110000001001011011011110110010011101010011000000100001011100001011010100110100111100000010001100110100101100111011000100110000001001000011000000100111011101000011010011110000001000010111011110110000001001100111010101110110001101100011010100110101001100010011001110100000001001100101010010110101101101001011000110110100001100100111000110110100111100011010000000100111011100001011010100110011101100000010011001110111101101011011010100110111101100111011010100110000001001001011011001110000001000110011010000110100101100011011010010110011101101110011000110100000001000010111000010110101001100000010000101110101001100111011000100110101001100111011011000110100111100000010010010110110011100000010000101110111101100000010011100110101001100010111000000100111101100111011000000100100001100000010000100110111101101110111001110110111011101000011001001110001001100000010011001110000011101001011001001110100001100011011000000100001011100001011010000110001011100000010011000110100001100111011000000100101001100110111010100110011101100000010001000110101001101100011011110110101101101010011000000100100001100000010011001110101001100011011001100110101101000110011010101110001101100110011010010110001101100011011010010110011101101110011000000100000011100100111011110110000011100001011010100110110001101001111001110100'; assert(isequal(message2binary(message),y_correct-48))

2   Pass
message = 'First, have a definite, clear practical ideal; a goal, an objective. Second, have the necessary means to achieve your ends; wisdom, money, materials, and methods.'; y_correct='011000101001011001001110110011100010111000110100000001000001011010000110011011101010011000000100100001100000010000100110101001100110011010010110011101101001011000101110101001100011010000000100110001100011011010100110100001100100111000000100000011100100111010000110110001100010111010010110110001101000011000110110000001001001011000100110101001101000011000110110110111000000010010000110000001001110011011110110100001100011011000110100000001001000011001110110000001001111011001000110010101101010011011000110001011101001011001101110101001100111010000000100110010101010011011000110111101100111011000100110001101000000010000010110100001100110111010100110000001000010111000010110101001100000010001110110101001101100011010100110110011101100111010000110010011101001111000000100101101101010011010000110011101101100111000000100001011101111011000000100100001101100011000010110100101101010011001101110101001100000010010011110111101101010111001001110000001001010011001110110001001101100111011011100000001001110111010010110110011100010011011110110101101100011010000000100101101101111011001110110101001101001111000110100000001001011011010000110001011101010011001001110100101101000011000110110110011100011010000000100100001100111011000100110000001001011011010100110001011100001011011110110001001101100111001110100'; assert(isequal(message2binary(message),y_correct-48))

3   Pass
message = 'I do not know what I may appear to the world, but to myself I seem to have been only like a boy playing on the seashore, and diverting myself in now and then finding a smoother pebble or a prettier shell than ordinary, whilst the great ocean of truth lay all undiscovered before me.'; y_correct='100100100000010000100110111101100000010001110110111101100010111000000100110101100111011011110110111011100000010011101110000101101000011000101110000001001001001000000100101101101000011010011110000001001000011000001110000011101010011010000110010011100000010000101110111101100000010000101110000101101010011000000100111011101111011001001110001101100010011000110100000001000100011010101110001011100000010000101110111101100000010010110110100111101100111010100110001101100110011000000100100100100000010011001110101001101010011010110110000001000010111011110110000001000001011010000110011011101010011000000100010001101010011010100110011101100000010011110110011101100011011010011110000001000011011010010110110101101010011000000100100001100000010001000110111101101001111000000100000011100011011010000110100111101001011001110110111001100000010011110110011101100000010000101110000101101010011000000100110011101010011010000110110011100001011011110110010011101010011000110100000001001000011001110110001001100000010000100110100101100110111010100110010011100010111010010110011101101110011000000100101101101001111011001110101001100011011001100110000001001001011001110110000001000111011011110110111011100000010010000110011101100010011000000100001011100001011010100110011101100000010001100110100101100111011000100110100101100111011011100110000001001000011000000100110011101011011011110110111101100010111000010110101001100100111000000100000011101010011001000110010001100011011010100110000001001111011001001110000001001000011000000100000011100100111010100110001011100010111010010110101001100100111000000100110011100001011010100110001101100011011000000100001011100001011010000110011101100000010011110110010011100010011010010110011101101000011001001110100111100011010000000100111011100001011010010110001101101100111000101110000001000010111000010110101001100000010011100110010011101010011010000110001011100000010011110110110001101010011010000110011101100000010011110110011001100000010000101110010011101010111000101110000101100000010000110110100001101001111000000100100001100011011000110110000001001010111001110110001001101001011011001110110001101111011001101110101001100100111010100110001001100000010001000110101001100110011011110110010011101010011000000100101101101010011001110100'; assert(isequal(message2binary(message),y_correct-48))

4   Pass
message = 'As I considered the matter carefully it gradually came to light that all those matters only were referred to mathematics in which order and measurements are investigated, and that it makes no difference whether it be in numbers, figures, stars, sounds or any other object that the question of measurement arises. I saw consequently that there must be some general science to explain that element as a whole which gives rise to problems about order and measurement, restricted as these are to no special subject matter. This, I perceived was called "universal mathematics".'; y_correct='1000001011001110000001001001001000000100110001101111011001110110110011101001011000100110101001100100111010100110001001100000010000101110000101101010011000000100101101101000011000101110001011101010011001001110000001001100011010000110010011101010011001100110101011100011011000110110100111100000010010010110001011100000010011100110010011101000011000100110101011101000011000110110001101101001111000000100110001101000011010110110101001100000010000101110111101100000010000110110100101101110011000010110001011100000010000101110000101101000011000101110000001001000011000110110001101100000010000101110000101101111011011001110101001100000010010110110100001100010111000101110101001100100111011001110000001001111011001110110001101101001111000000100111011101010011001001110101001100000010001001110101001100110011010100110010011100100111010100110001001100000010000101110111101100000010010110110100001100010111000010110101001101011011010000110001011101001011011000110110011100000010010010110011101100000010011101110000101101001011011000110000101100000010011110110010011100010011010100110010011100000010010000110011101100010011000000100101101101010011010000110110011101010111001001110101001101011011010100110011101100010111011001110000001001000011001001110101001100000010010010110011101100110111010100110110011100010111010010110111001101000011000101110101001100010011000110100000001001000011001110110001001100000010000101110000101101000011000101110000001001001011000101110000001001011011010000110110101101010011011001110000001000111011011110110000001000010011010010110011001100110011010100110010011101010011001110110110001101010011000000100111011100001011010100110001011100001011010100110010011100000010010010110001011100000010001000110101001100000010010010110011101100000010001110110101011101011011001000110101001100100111011001110001101000000010001100110100101101110011010101110010011101010011011001110001101000000010011001110001011101000011001001110110011100011010000000100110011101111011010101110011101100010011011001110000001001111011001001110000001001000011001110110100111100000010011110110001011100001011010100110010011100000010011110110010001100101011010100110110001100010111000000100001011100001011010000110001011100000010000101110000101101010011000000100100011101010111010100110110011100010111010010110111101100111011000000100111101100110011000000100101101101010011010000110110011101010111001001110101001101011011010100110011101100010111000000100100001100100111010010110110011101010011011001110011101000000010010010010000001001100111010000110111011100000010011000110111101100111011011001110101001101000111010101110101001100111011000101110001101101001111000000100001011100001011010000110001011100000010000101110000101101010011001001110101001100000010010110110101011101100111000101110000001000100011010100110000001001100111011110110101101101010011000000100111001101010011001110110101001100100111010000110001101100000010011001110110001101001011010100110011101101100011010100110000001000010111011110110000001001010011000011110000011100011011010000110100101100111011000000100001011100001011010000110001011100000010010100110001101101010011010110110101001100111011000101110000001001000011011001110000001001000011000000100111011100001011011110110001101101010011000000100111011100001011010010110110001100001011000000100111001101001011001101110101001101100111000000100010011101001011011001110101001100000010000101110111101100000010000001110010011101111011001000110001101101010011010110110110011100000010010000110010001101111011010101110001011100000010011110110010011100010011010100110010011100000010010000110011101100010011000000100101101101010011010000110110011101010111001001110101001101011011010100110011101100010111000110100000001000100111010100110110011100010111001001110100101101100011000101110101001100010011000000100100001101100111000000100001011100001011010100110110011101010011000000100100001100100111010100110000001000010111011110110000001000111011011110110000001001100111000001110101001101100011010010110100001100011011000000100110011101010111001000110010101101010011011000110001011100000010010110110100001100010111000101110101001100100111001110100000001000010101000010110100101101100111000110100000001001001001000000100000011101010011001001110110001101010011010010110011011101010011000100110000001001110111010000110110011100000010011000110100001100011011000110110101001100010011000000100010001001010111001110110100101100110111010100110010011101100111010000110001101100000010010110110100001100010111000010110101001101011011010000110001011101001011011000110110011100100010001110100'; assert(isequal(message2binary(message),y_correct-48))