Skip to main content
deleted 8 characters in body
Source Link
Rick Hitchcock
  • 2.6k
  • 11
  • 17

#JavaScript (ES6), 170 135131 bytes

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290}`]||'473168290 5'[c%11]).join``

**How it works:**

If you change the dots to 0s and the dashes to 1s, and prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program splits on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290}`]||'473168290 5'[c%11]).join``

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 135 bytes

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290 5'[c%11]).join``

**How it works:**

If you change the dots to 0s and the dashes to 1s, and prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program splits on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290 5'[c%11]).join``

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 131 bytes

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1))}`]||'473168290 5'[c%11]).join``

**How it works:**

If you change the dots to 0s and the dashes to 1s, and prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program splits on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1))}`]||'473168290 5'[c%11]).join``

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

deleted 79 characters in body
Source Link
Rick Hitchcock
  • 2.6k
  • 11
  • 17

#JavaScript (ES6), 170 166135 bytes

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.splitreplace(/0).map?(111|1)/g,d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

**How it works:**

If you change the dots to 0s and the dashes to 1s, thenand prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program first splits on words, then on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.splitreplace(/0).map?(111|1)/g,d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 166 bytes

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.split(0).map(d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

**How it works:**

If you change the dots to 0s and the dashes to 1s, then prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program first splits on words, then on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.split(0).map(d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 135 bytes

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290 5'[c%11]).join``

**How it works:**

If you change the dots to 0s and the dashes to 1s, and prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program splits on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:

let f=

s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/0?(111|1)/g,d=>+(d>1)),2)]||'473168290 5'[c%11]).join``

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

deleted 1 character in body
Source Link
Rick Hitchcock
  • 2.6k
  • 11
  • 17

#JavaScript (ES6), 170170 166 bytes

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replacesplit(/111|0)./g,e=>e<1?'':+map(e>1d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

**How it works:**

If you change the dots to 0s and the dashes to 1s, then prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program first splits on words, then on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:   

let f=

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replacesplit(/111|0)./g,e=>e<1?'':+map(e>1d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 bytes

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/111|./g,e=>e<1?'':+(e>1)),2)]||'473168290 5'[c%11]).join``).join` `

**How it works:**

If you change the dots to 0s and the dashes to 1s, then prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program first splits on words, then on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases:  

let f=

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.replace(/111|./g,e=>e<1?'':+(e>1)),2)]||'473168290 5'[c%11]).join``).join` `

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

#JavaScript (ES6), 170 166 bytes

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.split(0).map(d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

**How it works:**

If you change the dots to 0s and the dashes to 1s, then prefix with a 1, you get binary numbers, which when converted to decimal gives you:

  1. Letters: 2 - 18, 20, and 22 - 29.
    These can be converted to the correct letters by indexing into ' ETIANMSURWDKGOHVF L PJBXCYZQ'.
  2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.
    If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into '473168290 5'.

The program first splits on words, then on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.


Test Cases: 

let f=

s=>s.split(/0{7}/).map(e=>e.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=parseInt(1+e.split(0).map(d=>+(d>1)).join``,2)]||'473168290 5'[c%11]).join``).join` `

console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));

added 739 characters in body
Source Link
Rick Hitchcock
  • 2.6k
  • 11
  • 17
Loading
Source Link
Rick Hitchcock
  • 2.6k
  • 11
  • 17
Loading