Skip to main content
edited tags
Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105
Tweeted twitter.com/#!/StackCodeGolf/status/449682272942567424
Change the title to make it clear that "print true" isn't a solution
Link
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169

Determine if an integer is a palindrome in anya given radix (base)

added 113 characters in body
Source Link
durron597
  • 4.8k
  • 1
  • 21
  • 49

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and:

  1. Prints any fixed message you want if the number is a palindrome in that radix (e.g. true, t, 1)
  2. Prints any different fixed message you want if the number is not a palindrome in that radix (e.g. false, f, 0, etc.)
  3. These messages must be the same per each run, but there are no rules about what they must be (whatever's best for golfing).
  4. You may assume the input is valid, two positive integers. "number" will not exceed 2147483647, "radix" will not exceed 32767.
  5. You may not use external resources, but you may use any math function included by default in your language.

Note: a radix is just the base of the number.

Sample runs:

16
10
false

16
3
true

16
20
true

121
10
true

5
5
false

12346
12345
true

16781313
64
true

16781313
16
true

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and:

  1. Prints any fixed message you want if the number is a palindrome in that radix (e.g. true, t, 1)
  2. Prints any different fixed message you want if the number is not a palindrome in that radix (e.g. false, f, 0, etc.)
  3. These messages must be the same per each run, but there are no rules about what they must be (whatever's best for golfing).
  4. You may assume the input is valid, two positive integers. "number" will not exceed 2147483647, "radix" will not exceed 32767.

Note: a radix is just the base of the number.

Sample runs:

16
10
false

16
3
true

16
20
true

121
10
true

5
5
false

12346
12345
true

16781313
64
true

16781313
16
true

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and:

  1. Prints any fixed message you want if the number is a palindrome in that radix (e.g. true, t, 1)
  2. Prints any different fixed message you want if the number is not a palindrome in that radix (e.g. false, f, 0, etc.)
  3. These messages must be the same per each run, but there are no rules about what they must be (whatever's best for golfing).
  4. You may assume the input is valid, two positive integers. "number" will not exceed 2147483647, "radix" will not exceed 32767.
  5. You may not use external resources, but you may use any math function included by default in your language.

Note: a radix is just the base of the number.

Sample runs:

16
10
false

16
3
true

16
20
true

121
10
true

5
5
false

12346
12345
true

16781313
64
true

16781313
16
true
Source Link
durron597
  • 4.8k
  • 1
  • 21
  • 49
Loading