Match maker

A challenge by Bulmenisaurus avatar Bulmenisaurus

Description

Given a CSS query, output the unindented html needed that will produce a match. For example, a.foo>b#bar should produce <a class=‘foo’><b id=‘bar’></b></a>

The html should have full tags, not self closing ones. The query follows the following grammar:

query   ::= element (">" element)*
element ::= name [id] class*
id      ::= "#" name
class   ::= "." name
name    ::= [a-z0-9]+

For the test cases you should expect at most 9 levels of nesting elements.

Leaderboard

Author Bytes
#1 Mukundan314 avatar Mukundan314 145
#2 bizy-coder avatar bizy-coder 147
#3 bizy-coder avatar bizy-coder 157
#4 hallvabo avatar hallvabo 167
#5 Bulmenisaurus avatar Bulmenisaurus 168
#6 ovs-code avatar ovs-code 171
#7 Jacob-Lockwood avatar Jacob-Lockwood 181
#8 NicknamedTwice avatar NicknamedTwice 184
#9 AlephSquirrel avatar AlephSquirrel 187
#10 MeWhenI avatar MeWhenI 189
Challenge ended 4 weeks, 6 days ago ago
This challenge has ended. You are free to submit more solutions but they won't count for scoring.