Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Racket Intermediate Student with Lambda, regex length 27 22 10 (CrackedCracked)

(Look familiar? I translated this into tinylisp for a certain crackcrack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.

Racket Intermediate Student with Lambda, regex length 27 22 10 (Cracked)

(Look familiar? I translated this into tinylisp for a certain crack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.

Racket Intermediate Student with Lambda, regex length 27 22 10 (Cracked)

(Look familiar? I translated this into tinylisp for a certain crack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.

Put space in paren to ensure regex match
Source Link

Original solution

(λ (n) (((((λ(f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (q) (λ(n) (λ(c) (λ(r) (cond [(< c 0)r][(= 1 1) (((q n) (- c 1))(cons(cond [(= 0((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(a)(λ (b) (cond [(< a b)a][(= 1 1)((r(- a b)) b)])))))c)2))((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r)(λ (s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))])))))))(+ 1(* c n))) (+ 1(* c n)n)) 1) '())][(= 1 1) ((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))]))))))) (+ (* c n)n))(* c n))-1) '())]) r))]))))))n) (- n 1)) '()) ) 

Try it online! (Note that the TIO code is slightly different because I've wrapped the solution in (... 4) to call it.)

I picked ISL with Lambda over standard Racket on this and my other answer because I wanted to have short regexes and minimize loopholes. To do it, I started with this:

(define Y (λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y) ((x x) y))))))) (define % (Y (λ (r) (λ (a) (λ (b) (cond [(< a b) a] [(= 1 1) ((r (- a b)) b)])))))) (define range1 (Y (λ (r) (λ (s) (λ (e) (λ (t) (λ (a) (cond [(>= (* t s) (* t e)) a] [(= 1 1) ((((r s) (- e t)) t) (cons (- e t) a))])))))))) (define g (Y (λ (q) (λ (n) (λ (c) (λ (r) (cond [(< c 0) r] [(= 1 1) (((q n) (- c 1)) (cons (cond [(= 0 ((% c) 2)) ((((range1 (+ 1 (* c n))) (+ 1 (* c n) n)) 1) '())] [(= 1 1) ((((range1 (+ (* c n) n)) (* c n)) -1) '())]) r))]))))))) (define (f n) (((g n) (- n 1)) '())) 

(Look familiar? I translated this into tinylisp for a certain crack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.

Original solution

(λ (n) (((((λ(f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (q) (λ(n) (λ(c) (λ(r) (cond [(< c 0)r][(= 1 1) (((q n) (- c 1))(cons(cond [(= 0((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(a)(λ (b) (cond [(< a b)a][(= 1 1)((r(- a b)) b)])))))c)2))((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r)(λ (s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))])))))))(+ 1(* c n))) (+ 1(* c n)n)) 1) '())][(= 1 1) ((((((λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y)((x x)y)))))) (λ (r) (λ(s) (λ(e) (λ(t) (λ(a) (cond [(>= (* t s) (* t e)) a][(= 1 1)((((r s) (- e t)) t) (cons(- e t)a))]))))))) (+ (* c n)n))(* c n))-1) '())]) r))]))))))n) (- n 1)) '()) ) 

Try it online! (Note that the TIO code is slightly different because I've wrapped the solution in (... 4) to call it.)

I picked ISL with Lambda over standard Racket on this and my other answer because I wanted to have short regexes and minimize loopholes. To do it, I started with this:

(define Y (λ (f) ((λ (x) (x x)) (λ (x) (f (λ (y) ((x x) y))))))) (define % (Y (λ (r) (λ (a) (λ (b) (cond [(< a b) a] [(= 1 1) ((r (- a b)) b)])))))) (define range1 (Y (λ (r) (λ (s) (λ (e) (λ (t) (λ (a) (cond [(>= (* t s) (* t e)) a] [(= 1 1) ((((r s) (- e t)) t) (cons (- e t) a))])))))))) (define g (Y (λ (q) (λ (n) (λ (c) (λ (r) (cond [(< c 0) r] [(= 1 1) (((q n) (- c 1)) (cons (cond [(= 0 ((% c) 2)) ((((range1 (+ 1 (* c n))) (+ 1 (* c n) n)) 1) '())] [(= 1 1) ((((range1 (+ (* c n) n)) (* c n)) -1) '())]) r))]))))))) (define (f n) (((g n) (- n 1)) '())) 

(Look familiar? I translated this into tinylisp for a certain crack.) Y it the applicative-order Y combinator, taken from this blog post. All functions are curried to make using the Y combinator possible. Then I substituted the function bodies in for each reference to a function and turned f into a lambda. After that, all I had to do was play with spaces so that I could use .\W instead of .\W+ in my regex.

Cracked
Source Link

Racket Intermediate Student with Lambda, regex length 27 22 10 (Cracked)

You can run Racket ISL with Lambda at Try it online!.

Produces a function that takes n as input and returns the answer as a list of lists. The basic idea is that only one-character words are allowed, possibly prefixed with con. Also, besides the con exception, every other character must be non-word. Now let's see if any con robber can crack it!

Regex (JS)

(con|.\W)+ 

Output

(list (list 1 2 3 4) (list 8 7 6 5) (list 9 10 11 12) (list 16 15 14 13)) 

Edit 3/14

I've golfed the regex down quite a bit, making it more restrictive in the process. The basic idea of the solution is the same, but since the regex is not equivalent to the previous, I'll count my 7 days starting now. Also, until told otherwise, I'll assume that the answer's requirement for a full match means that ^ and $ on the regex are implied.

Racket Intermediate Student with Lambda, regex length 27 22 10

You can run Racket ISL with Lambda at Try it online!.

Produces a function that takes n as input and returns the answer as a list of lists. The basic idea is that only one-character words are allowed, possibly prefixed with con. Also, besides the con exception, every other character must be non-word. Now let's see if any con robber can crack it!

Regex (JS)

(con|.\W)+ 

Output

(list (list 1 2 3 4) (list 8 7 6 5) (list 9 10 11 12) (list 16 15 14 13)) 

Edit 3/14

I've golfed the regex down quite a bit, making it more restrictive in the process. The basic idea of the solution is the same, but since the regex is not equivalent to the previous, I'll count my 7 days starting now. Also, until told otherwise, I'll assume that the answer's requirement for a full match means that ^ and $ on the regex are implied.

Racket Intermediate Student with Lambda, regex length 27 22 10 (Cracked)

You can run Racket ISL with Lambda at Try it online!.

Produces a function that takes n as input and returns the answer as a list of lists. The basic idea is that only one-character words are allowed, possibly prefixed with con. Also, besides the con exception, every other character must be non-word. Now let's see if any con robber can crack it!

Regex (JS)

(con|.\W)+ 

Output

(list (list 1 2 3 4) (list 8 7 6 5) (list 9 10 11 12) (list 16 15 14 13)) 

Edit 3/14

I've golfed the regex down quite a bit, making it more restrictive in the process. The basic idea of the solution is the same, but since the regex is not equivalent to the previous, I'll count my 7 days starting now. Also, until told otherwise, I'll assume that the answer's requirement for a full match means that ^ and $ on the regex are implied.

Add TIO link
Source Link
Loading
Golf regex
Source Link
Loading
Golf regex some. Should be equivalent to the previous.
Source Link
Loading
Source Link
Loading