master
parent
be1991b224
commit
a74b2772b7
@ -0,0 +1,27 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
(require "../helper.rkt")
|
||||||
|
(provide read-syntax (rename-out [#%mb #%module-begin]))
|
||||||
|
|
||||||
|
(define (read-syntax path port)
|
||||||
|
(strip-context #`(module mod "main.rkt"
|
||||||
|
#,@(port->lines port))))
|
||||||
|
|
||||||
|
(define-macro (#%mb STARS-LINE SEXP-LINE ...)
|
||||||
|
#`(#%module-begin
|
||||||
|
(if (eq? (process-line STARS-LINE) '★)
|
||||||
|
(score (process-line SEXP-LINE))
|
||||||
|
(process-line SEXP-LINE #t))
|
||||||
|
...))
|
||||||
|
|
||||||
|
(define (process-line line [garbage #f])
|
||||||
|
(define gchars 0)
|
||||||
|
(let* ([line (string-trim line)]
|
||||||
|
[line (regexp-replace* #rx"!." line "")]
|
||||||
|
[line (regexp-replace* #rx"<.*?>" line
|
||||||
|
(λ (m) (set! gchars (+ gchars (string-length m) -2)) ""))]
|
||||||
|
[line (regexp-replace* #rx"," line "")])
|
||||||
|
(if garbage gchars (read (open-input-string line)))))
|
||||||
|
|
||||||
|
(define (score tree [start 0])
|
||||||
|
(+ (add1 start) (for/sum ([x (in-list tree)])
|
||||||
|
(score x (add1 start)))))
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,9 @@
|
|||||||
|
#lang reader "main.rkt" ★
|
||||||
|
{}
|
||||||
|
{{{}}}
|
||||||
|
{{},{}}
|
||||||
|
{{{},{},{{}}}}
|
||||||
|
{<a>,<a>,<a>,<a>}
|
||||||
|
{{<ab>},{<ab>},{<ab>},{<ab>}}
|
||||||
|
{{<!!>},{<!!>},{<!!>},{<!!>}}
|
||||||
|
{{<a!>},{<a!>},{<a!>},{<ab>}}
|
@ -0,0 +1,8 @@
|
|||||||
|
#lang reader "main.rkt" ★★
|
||||||
|
<>
|
||||||
|
<random characters>
|
||||||
|
<<<<>
|
||||||
|
<{!>}>
|
||||||
|
<!!>
|
||||||
|
<!!!>>
|
||||||
|
<{o"i!a,<{i<a>
|
Reference in New Issue