Skip to main content
Commonmark migration
Source Link

Prolog, 49 bytes

#Prolog, 49 bytes# Code:

p(N):-number_codes(N,L),sort(L,S),msort(L,T),S=T.

Explained:

p(N):-number_codes(N,L), % Convert int to list (of charcodes)
      sort(L,S),         % Sort list and remove duplicates
      msort(L,T),        % Sort list and keep duplicates
      S=T.               % Check if lists are equal

Example:

p(48778584).
false

p(17308459).
true

#Prolog, 49 bytes# Code:

p(N):-number_codes(N,L),sort(L,S),msort(L,T),S=T.

Explained:

p(N):-number_codes(N,L), % Convert int to list (of charcodes)
      sort(L,S),         % Sort list and remove duplicates
      msort(L,T),        % Sort list and keep duplicates
      S=T.               % Check if lists are equal

Example:

p(48778584).
false

p(17308459).
true

Prolog, 49 bytes

Code:

p(N):-number_codes(N,L),sort(L,S),msort(L,T),S=T.

Explained:

p(N):-number_codes(N,L), % Convert int to list (of charcodes)
      sort(L,S),         % Sort list and remove duplicates
      msort(L,T),        % Sort list and keep duplicates
      S=T.               % Check if lists are equal

Example:

p(48778584).
false

p(17308459).
true
Source Link
Emigna
  • 53k
  • 5
  • 43
  • 162

#Prolog, 49 bytes# Code:

p(N):-number_codes(N,L),sort(L,S),msort(L,T),S=T.

Explained:

p(N):-number_codes(N,L), % Convert int to list (of charcodes)
      sort(L,S),         % Sort list and remove duplicates
      msort(L,T),        % Sort list and keep duplicates
      S=T.               % Check if lists are equal

Example:

p(48778584).
false

p(17308459).
true