Skip to main content
Commonmark migration
Source Link

#Mathematica 77 43

Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally.

For example, 16781313 is not a palindrome in base 17:

IntegerDigits[16781313, 17]

{11, 13, 15, 11, 14, 1}

However, it is a palindrome in base 16:

IntegerDigits[16781313, 16]

{1, 0, 0, 1, 0, 0, 1}


If the ordered pairs in the above examples were entered,

(x=Input[]~IntegerDigits~Input[])==Reverse@x

would return

False (* (because {11, 13, 15, 11, 14, 1} != {1, 14, 11, 15, 13, 11} ) *)

 

True (* (because {1, 0, 0, 1, 0, 0, 1} is equal to {1, 0, 0, 1, 0, 0, 1} ) *)

#Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally.

For example, 16781313 is not a palindrome in base 17:

IntegerDigits[16781313, 17]

{11, 13, 15, 11, 14, 1}

However, it is a palindrome in base 16:

IntegerDigits[16781313, 16]

{1, 0, 0, 1, 0, 0, 1}


If the ordered pairs in the above examples were entered,

(x=Input[]~IntegerDigits~Input[])==Reverse@x

would return

False (* (because {11, 13, 15, 11, 14, 1} != {1, 14, 11, 15, 13, 11} ) *)

 

True (* (because {1, 0, 0, 1, 0, 0, 1} is equal to {1, 0, 0, 1, 0, 0, 1} ) *)

Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally.

For example, 16781313 is not a palindrome in base 17:

IntegerDigits[16781313, 17]

{11, 13, 15, 11, 14, 1}

However, it is a palindrome in base 16:

IntegerDigits[16781313, 16]

{1, 0, 0, 1, 0, 0, 1}


If the ordered pairs in the above examples were entered,

(x=Input[]~IntegerDigits~Input[])==Reverse@x

would return

False (* (because {11, 13, 15, 11, 14, 1} != {1, 14, 11, 15, 13, 11} ) *)

True (* (because {1, 0, 0, 1, 0, 0, 1} is equal to {1, 0, 0, 1, 0, 0, 1} ) *)

added 421 characters in body
Source Link
DavidC
  • 25.4k
  • 2
  • 52
  • 105

#Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally. For this reason

For example, it16781313 is not necessary to create b distinct digits fora palindrome in base b.17:

IntegerDigits[16781313, 17]

{11, 13, 15, 11, 14, 1}

However, it is a palindrome in base 16:

IntegerDigits[16781313, 16]

{1, 0, 0, 1, 0, 0, 1}


If the ordered pairs in the above examples were entered,

(x=Input[]~IntegerDigits~Input[])==Reverse@x

would return

False (* (because {11, 13, 15, 11, 14, 1} != {1, 14, 11, 15, 13, 11} ) *)

True (* (because {1, 0, 0, 1, 0, 0, 1} is equal to {1, 0, 0, 1, 0, 0, 1} ) *)

#Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally. For this reason, it is not necessary to create b distinct digits for base b.

(x=Input[]~IntegerDigits~Input[])==Reverse@x

#Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally.

For example, 16781313 is not a palindrome in base 17:

IntegerDigits[16781313, 17]

{11, 13, 15, 11, 14, 1}

However, it is a palindrome in base 16:

IntegerDigits[16781313, 16]

{1, 0, 0, 1, 0, 0, 1}


If the ordered pairs in the above examples were entered,

(x=Input[]~IntegerDigits~Input[])==Reverse@x

would return

False (* (because {11, 13, 15, 11, 14, 1} != {1, 14, 11, 15, 13, 11} ) *)

True (* (because {1, 0, 0, 1, 0, 0, 1} is equal to {1, 0, 0, 1, 0, 0, 1} ) *)

shortened
Source Link
DavidC
  • 25.4k
  • 2
  • 52
  • 105

#Mathematica 7777 43

Line 1 input gets a decimal number andIntegerDigits[n,b] represents n as a list of digits in base (b. Each base-b) from standard input digit is expressed decimally. Line 2 checks whether the number in For this reason, it is not necessary to create b distinct digits for base b is a palindrome.

{n, b} = ToExpression /@ StringSplit@InputString[];
(x = n~IntegerDigits~bx=Input[]~IntegerDigits~Input[]) == Reverse@x==Reverse@x

#Mathematica 77

Line 1 input gets a decimal number and a base (b) from standard input. Line 2 checks whether the number in base b is a palindrome.

{n, b} = ToExpression /@ StringSplit@InputString[];
(x = n~IntegerDigits~b) == Reverse@x

#Mathematica 77 43

IntegerDigits[n,b] represents n as a list of digits in base b. Each base-b digit is expressed decimally. For this reason, it is not necessary to create b distinct digits for base b.

(x=Input[]~IntegerDigits~Input[])==Reverse@x
Post Undeleted by DavidC
Post Deleted by DavidC
Source Link
DavidC
  • 25.4k
  • 2
  • 52
  • 105
Loading