Distinct palindromes within decimal numbers: Difference between revisions

Add Factor
(Add Factor)
Line 21:
[[N_1%27s_followed_by_a_3]]
 
 
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: formatting io kernel math math.ranges present prettyprint
sequences sequences.extras sets ;
 
: dpal ( n -- seq )
present all-subseqs members [ dup reverse = ] filter ;
 
! task 1
"Number Palindromes" print
100 125 [a..b] [ dup pprint bl bl bl bl bl dpal . ] each nl
 
! task 2
"Number Has no >= 2 digit-palindromes?" print
{ 9 169 12769 1238769 123498769 12346098769 1234572098769
123456832098769 12345679432098769 1234567905432098769
123456790165432098769 83071934127905179083
1320267947849490361205695 }
[ dup dpal [ length 2 < ] reject empty? "%-25d %u\n" printf ]
each</lang>
{{out}}
<pre>
Number Palindromes
100 { "1" "0" "00" }
101 { "1" "0" "101" }
102 { "1" "0" "2" }
103 { "1" "0" "3" }
104 { "1" "0" "4" }
105 { "1" "0" "5" }
106 { "1" "0" "6" }
107 { "1" "0" "7" }
108 { "1" "0" "8" }
109 { "1" "0" "9" }
110 { "1" "0" "11" }
111 { "1" "11" "111" }
112 { "1" "2" "11" }
113 { "1" "3" "11" }
114 { "1" "4" "11" }
115 { "1" "5" "11" }
116 { "1" "6" "11" }
117 { "1" "7" "11" }
118 { "1" "8" "11" }
119 { "1" "9" "11" }
120 { "1" "2" "0" }
121 { "1" "2" "121" }
122 { "1" "2" "22" }
123 { "1" "2" "3" }
124 { "1" "2" "4" }
125 { "1" "2" "5" }
 
Number Has no >= 2 digit-palindromes?
9 t
169 t
12769 t
1238769 t
123498769 t
12346098769 t
1234572098769 t
123456832098769 t
12345679432098769 t
1234567905432098769 t
123456790165432098769 t
83071934127905179083 t
1320267947849490361205695 f
</pre>
 
=={{header|Julia}}==
1,808

edits