Last active
August 29, 2015 14:16
-
-
Save greymd/fb45abc82971eec318d6 to your computer and use it in GitHub Desktop.
任意の自然数の体積を持つ直方体の持ち得る自然数x, y, zの組み合わせを求めるEgisonシェル芸
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
$ echo 64 | \ | |
egison -T -m '1#(match-all (p-f %1) (multiset integer) [ <join $xs <join $ys $zs>> [(foldl * 1 xs) (foldl * 1 ys) (foldl * 1 zs)]])' | \ | |
xargs -n 3 | \ | |
egison -T -f '3#(and (lte? %1 %2) (lte? %2 %3))' | \ | |
sort | uniq | |
# 結果 (体積64の直方体) | |
# 1 1 64 | |
# 1 2 32 | |
# 1 4 16 | |
# 1 8 8 | |
# 2 2 16 | |
# 2 4 8 | |
# 4 4 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/sh
echo 64 |
egison -T -s '1#(match-all (p-f (car %1)) (multiset integer) [ <join $xs <join $ys $zs>> [(foldl * 1 xs) (foldl * 1 ys) (foldl * 1 zs)]])' |
egison -T -F1c -f '1#(all lte? (match-all %1 (list integer) [ <join _ <cons $x <cons $y _>>> [x y]]))' |
sort | uniq