Created
June 25, 2017 02:15
-
-
Save katsuyan/e7e504b5d78a2ac1c9a50be1716c2240 to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q7
This file contains 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
(ns puzzule.q7 | |
(:require [clj-time.core :as t] | |
[clj-time.format :as f] | |
[clojure.string :as string])) | |
(defn- parse-int [x] | |
(Integer/parseInt x)) | |
(defn- int-to-binary-string [n] | |
(Integer/toBinaryString n)) | |
(defn- binary-string-to-int [n] | |
(Integer/parseInt n 2)) | |
(defn reverse-same-binary? [bin] | |
(= bin (string/reverse bin))) | |
(def days (for [n (range) | |
:while (not (t/after? | |
(t/plus (t/date-time 1964 10 10) (t/days n)) | |
(t/date-time 2020 7 24)))] | |
(t/plus (t/date-time 1964 10 10) (t/days n)))) | |
(defn time-to-str [time] | |
(let [custom-formatter (f/formatter "yyyyMMdd")] | |
(f/unparse custom-formatter time))) | |
(map binary-string-to-int | |
(filter reverse-same-binary? | |
(map (comp int-to-binary-string | |
parse-int | |
time-to-str) | |
days))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment