Pack Bytes to Hex
Programming Interview
Hard
6 views
Problem Description
Given {x}, .255). Put them into a bytes object and output hex string in uppercase.
Input Format
First line n. Second line n integers.
Output Format
One hex string.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
n=int(p[0])
a=list(map(int,p[1:1+n]))
b=bytes(a)
sys.stdout.write(b.hex().upper())
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!