Skip to main content
Commonmark migration
Source Link

#MATL, 18 14 13 bytes

MATL, 18 14 13 bytes

4e!Z{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4e!     % Reshape input to be 2 x 4 (puts the year in row 1 and month in row 2)
Z{      % Place each row in a separate cell
Zc      % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

#MATL, 18 14 13 bytes

4e!Z{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4e!     % Reshape input to be 2 x 4 (puts the year in row 1 and month in row 2)
Z{      % Place each row in a separate cell
Zc      % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

MATL, 18 14 13 bytes

4e!Z{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4e!     % Reshape input to be 2 x 4 (puts the year in row 1 and month in row 2)
Z{      % Place each row in a separate cell
Zc      % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display
added 55 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52

#MATL, 18 1414 13 bytes

4:&)Owv4e!12XOXkZ{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4:&)4e!     % BreakReshape intoinput theto firstbe 42 charactersx 4 (puts the year) and thein lastrow two1 (theand month in row 2)
Owv!Z{      % InsertPlace each row in a nullseparate charactercell
Zc between the year and month % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

#MATL, 18 14 bytes

4:&)Owv!12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4:&)    % Break into the first 4 characters (the year) and the last two (the month)
Owv!    % Insert a null character between the year and month
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

#MATL, 18 14 13 bytes

4e!Z{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4e!     % Reshape input to be 2 x 4 (puts the year in row 1 and month in row 2)
Z{      % Place each row in a separate cell
Zc      % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display
deleted 41 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52

#MATL, 18 14 bytes

4:&)XhZc12XOXkOwv!12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4:&)    % Break into the first 4 characters (the year) and the last two (the month)
Xh  Owv!    % Combine these two parts intoInsert a cell array
Zc      % Join themnull togethercharacter withbetween athe spaceyear inand betweenmonth
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

#MATL, 18 14 bytes

4:&)XhZc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4:&)    % Break into the first 4 characters (the year) and the last two (the month)
Xh      % Combine these two parts into a cell array
Zc      % Join them together with a space in between
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

#MATL, 18 14 bytes

4:&)Owv!12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4:&)    % Break into the first 4 characters (the year) and the last two (the month)
Owv!    % Insert a null character between the year and month
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display
added 66 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52
Loading
added 237 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52
Loading
added 345 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52
Loading
added 159 characters in body
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52
Loading
Source Link
Suever
  • 11.2k
  • 1
  • 23
  • 52
Loading