Skip to main content
Bounty Awarded with 100 reputation awarded by Adám
added 38 characters in body
Source Link
user
  • 457
  • 2
  • 21
  • 71

APL (Dyalog Unicode), 2828 26 bytes

Saved 2 bytes thanks to Adám!

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵⍨1=≢∘∪¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 

Try it online!Try it online!

Pretty straightforward implementation.

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 1+⍳ ⍝ Make a range [2, n + 1] ¨ ⍝ For each b in that range ⊢⊥⍣¯1⍨ ⍝ Interpret n in base b (gives a vector of integers) ⍵/⍨ ⍝ Keep the representations where (1=≢∘∪)¨⍵1=≢∘∪¨⍵  ⍝ it's a repdigit ¨⍵ ¨⍵ ⍝ For every representation, ≢∘∪ ≢∘∪ ⍝ is the length of it, without duplicates 1= 1= ⍝ equal to 1? ≢¨ ⍝ Get the length of each of the remaining representations ⌈/ ⍝ Get the biggest length 

APL (Dyalog Unicode), 28 bytes

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 

Try it online!

Pretty straightforward implementation.

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 1+⍳ ⍝ Make a range [2, n + 1] ¨ ⍝ For each b in that range ⊢⊥⍣¯1⍨ ⍝ Interpret n in base b (gives a vector of integers) ⍵/⍨ ⍝ Keep the representations where (1=≢∘∪)¨⍵ ⍝ it's a repdigit ¨⍵ ⍝ For every representation, ≢∘∪ ⍝ is the length of it, without duplicates 1= ⍝ equal to 1? ≢¨ ⍝ Get the length of each of the remaining representations ⌈/ ⍝ Get the biggest length 

APL (Dyalog Unicode), 28 26 bytes

Saved 2 bytes thanks to Adám!

{⌈/≢¨⍵/⍨1=≢∘∪¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 

Try it online!

Pretty straightforward implementation.

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 1+⍳ ⍝ Make a range [2, n + 1] ¨ ⍝ For each b in that range ⊢⊥⍣¯1⍨ ⍝ Interpret n in base b (gives a vector of integers) ⍵/⍨ ⍝ Keep the representations where 1=≢∘∪¨⍵  ⍝ it's a repdigit ¨⍵ ⍝ For every representation, ≢∘∪ ⍝ is the length of it, without duplicates 1= ⍝ equal to 1? ≢¨ ⍝ Get the length of each of the remaining representations ⌈/ ⍝ Get the biggest length 
Source Link
user
  • 457
  • 2
  • 21
  • 71

APL (Dyalog Unicode), 28 bytes

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 

Try it online!

Pretty straightforward implementation.

{⌈/≢¨⍵/⍨(1=≢∘∪)¨⍵}⊢⊥⍣¯1⍨¨1+⍳ 1+⍳ ⍝ Make a range [2, n + 1] ¨ ⍝ For each b in that range ⊢⊥⍣¯1⍨ ⍝ Interpret n in base b (gives a vector of integers) ⍵/⍨ ⍝ Keep the representations where (1=≢∘∪)¨⍵ ⍝ it's a repdigit ¨⍵ ⍝ For every representation, ≢∘∪ ⍝ is the length of it, without duplicates 1= ⍝ equal to 1? ≢¨ ⍝ Get the length of each of the remaining representations ⌈/ ⍝ Get the biggest length