Quantcast
Channel: Smaller-Base Palindromes - Code Golf Stack Exchange
Browsing all 8 articles
Browse latest View live

Answer by Brad Gilbert b2gills for Smaller-Base Palindromes

Perl 6, 83 bytes{(5..*).grep({grep {.Set>1&&[.reverse]eqv$_},map {[.polymod($^a xx*)]},2..$_})[$_]}Try itExpanded{ # create a list of SBPs (5 .. *).grep( { # find out if the current value is...

View Article



Answer by Lynn for Smaller-Base Palindromes

Python 2, 125 bytesn=5i=input()while i: n+=1;b=1 while b<n: b+=1;l=[];a=n while a:l+=a%b,;a/=b if{n%b}<set(l)>l==l[::-1]:i-=1;b=nprint nTry it online!n represents the integer we test for...

View Article

Answer by Uriel for Smaller-Base Palindromes

Dyalog APL, 53 bytes{{∨/∧/¨((1<≢∘∪)∧⌽=⊢)¨(⍵+1)⊥⍣¯1⍨¨1↓⍳⍵+1:⍵+1⋄∇⍵+1}⍣⍵⊢2}Try it online!

View Article

Answer by Emigna for Smaller-Base Palindromes

05AB1E, 15 bytesµNDLвʒÂQ}ʒË_}gĀTry it online!Explanationµ # loop until input matches are found N # push current iteration number D # duplicate L # rangeв # convert to each baseʒÂQ} # filter, keep...

View Article

Answer by Erik the Outgolfer for Smaller-Base Palindromes

Pyth, 14 bytese.f_I#ft{TjLZSTry it here.1-indexed.Explanation:e.f_I#ft{TjLZSZQ Trailing ZQ is implicit .f Q Find the first Q (input) positive integers that return a truthy result for SZ Make range...

View Article


Answer by Felipe Nardi Batista for Smaller-Base Palindromes

Python 2, 133 119 bytes-3 thanks to Ovs-5 thanks to Lynn1-indexedj=i=0n=input()while n: j+=1;l=[];N=i while N:l+=N%j,;N/=j if{i%j}<set(l)>l==l[::-1]or j>i:n-=j<i;i+=1;j=1print~-iTry it online!

View Article

Answer by Erik the Outgolfer for Smaller-Base Palindromes

Jelly, 12 bytesbṖEÐḟŒḂÐfµ#ṪTry it online!-2 thanks to Jonathan Allan, one being for, well, obvious stuff >_>Explanation:bṖEÐḟŒḂÐfµ#Ṫ Special quick behavior requires full programbṖEÐḟŒḂÐf # Get...

View Article

Smaller-Base Palindromes

For the purpose of this challenge, a smaller-base palindrome (SBP) is a number which is palindromic in a base between 1 and itself (exclusive), and is not a repdigit in the same base. For example, 5 is...

View Article

Browsing all 8 articles
Browse latest View live




Latest Images