-
Notifications
You must be signed in to change notification settings - Fork 5
/
HexColorCode.py
44 lines (43 loc) · 1.12 KB
/
HexColorCode.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import re
s = ""
for i in range(int(input())):
s = input()
m = re.findall(r'(#[a-fA-F0-9]{6}(?=[^\s])|#[a-fA-F0-9]{3}(?=[^\s]))\b', s)
if m:
print(*m, sep='\n')
# CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB).
# Specifications of HEX Color Code
# It must start with a '#' symbol.
# It can have 3 or 6 digits.
# Each digit is in the range of 0 to F. (1,2,3,4,5,6,7,8,9,0,A,B,C,D,E and F).
# A-F letters can be lower case. (a,b,c,d,e and f are also valid digits).
# Sample Input
# 11
# #BED
# {
# color: #FfFdF8; background-color:#aef;
# font-size: 123px;
# background: -webkit-linear-gradient(top, #f9f9f9, #fff);
# }
# #Cab
# {
# background-color: #ABC;
# border: 2px dashed #fff;
# }
# Sample Output
# #FfFdF8
# #aef
# #f9f9f9
# #fff
# #ABC
# #fff
# Explanation
# #BED and #Cab satisfy the Hex Color Code criteria, but they are used as selectors and not as color codes in the given CSS.
# Hence, the valid color codes are:
# #FfFdF8
# #aef
# #f9f9f9
# #fff
# #ABC
# #fff
# Note: There are no comments ( // or /* */) in CSS Code.