Last active
June 4, 2016 21:42
-
-
Save mnzk/5e046595299cd356dc4b9e20a5828653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (only-in srfi/26 cute)) | |
(define-syntax t>= | |
(syntax-rules () | |
((_ x) x) | |
((_ x f g ...) (t>= (f x) g ...)))) | |
(define (solve24 n) | |
(t>= "9876543210" string->list | |
permutations | |
(cute list-ref <> (sub1 n)) | |
reverse list->string)) | |
(define (solve24-seq n) | |
(t>= "0123456789" string->list | |
in-permutations | |
(cute sequence-ref <> (sub1 n)) | |
reverse list->string)) | |
(define N 1000000) | |
(time (solve24 N)) | |
(time (solve24-seq N)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment