Advertisement
tomuwhu

Morzés feladat fájlbeolvasása

Mar 3rd, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require( 'fs' ), rn = '\r\n'
  2. var file = fs.readFileSync( 'morzeabc.txt', 'utf-8' ),
  3.     DeCode = new Map(), betű, morzejel
  4. file.split( rn )
  5.     .splice( 1 )
  6.     .forEach( ξ => {
  7.         [ betű, morzejel ] = ξ.split( '\t' )
  8.         DeCode.set( morzejel, betű )
  9.     })
  10. file = fs.readFileSync( 'morze.txt', 'utf-8' )
  11. console .log(
  12.     file.split( rn )
  13.         .map( ξ => ξ
  14.             .split(';')
  15.             .map( ξ => ξ
  16.                 .split( ' '.repeat(7) )
  17.                 .map( ξ => ξ
  18.                     .split( ' '.repeat(3) )
  19.                     .map  ( ξ => DeCode.get( ξ ) )
  20.                     .join ( '' )
  21.                 )
  22.                 .join( ' ' )
  23.             )
  24.             .join(': ')
  25.         )
  26. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement