March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,46 @@
BEGIN
# return TRUE if number is self describing, FALSE otherwise #
OP SELFDESCRIBING = ( INT number )BOOL:
BEGIN
[10]INT counts := ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
INT n := number;
INT digits := 0;
# count the occurances of each digit #
WHILE
n /= 0
DO
digits +:= 1;
counts[ ( n MOD 10 ) + 1 ] +:= 1;
n OVERAB 10
OD;
# construct the number that the counts would describe, #
# if the number was self describing #
INT described number := 0;
FOR i TO digits
DO
described number *:= 10;
described number +:= counts[ i ]
OD;
# if the described number is the input number, #
# it is self describing #
( number = described number )
END; # SELFDESCRIBING #
main: (
FOR i TO 100 000 000
DO
IF SELFDESCRIBING i
THEN
print( ( i, " is self describing", newline ) )
FI
OD
)
END

View file

@ -1,5 +1,4 @@
(de selfDescribing (N)
(not
(find '((D I) (<> D (cnt = N (circ I))))
(setq N (mapcar format (chop N)))
(range 0 (length N)) ) ) )
(fully '((D I) (= D (cnt = N (circ I))))
(setq N (mapcar format (chop N)))
(range 0 (length N)) ) )