-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathts.ts
More file actions
30 lines (21 loc) · 928 Bytes
/
ts.ts
File metadata and controls
30 lines (21 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import readlineSync from 'readline-sync'
const readline = () => readlineSync.prompt({ encoding: 'utf-8', prompt: '' })
// ------ Everything above this line will get cut when running copy script
const N: number = parseInt(readline()) // Number of elements which make up the association table.
const Q: number = parseInt(readline()) // Number Q of file names to be analyzed.
let mimeTypes: { [extension: string]: string } = {}
for (let i = 0; i < N; i++) {
const [extension, mimeType] = readline().split(' ')
mimeTypes[extension.toLowerCase()] = mimeType
}
for (let i = 0; i < Q; i++) {
const FNAME: string = readline() // One file name per line.
const split = FNAME.split('.')
if (split.length === 1) {
console.log('UNKNOWN')
continue
}
const extension = split.slice(-1)[0]
if (extension.toLowerCase() in mimeTypes) console.log(mimeTypes[extension.toLowerCase()])
else console.log('UNKNOWN')
}