Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

71%
+3 −0
Challenges Presumptuous base conversion

Python, 45 bytes I am not a Python guy at all, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes! lambda n:int(n,int(max("1"+n),...

posted 2y ago by Shaggy‭  ·  edited 2y ago by Shaggy‭

Answer
#4: Post edited by user avatar Shaggy‭ · 2022-09-23T11:50:30Z (over 2 years ago)
  • # Python, <s>45</s> 48 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes! The double `max` is annoying me, for example.
  • <!-- language-all: lang-python -->
  • lambda n:int(n,max(2,int(max(n),16)+1))or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPJzexQsNIB8QGsfI0dQzNNLUNNTXzixRyUvOAAv8LikCyaRpKhgZKmpr/AQ)
  • # Python, 45 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes!
  • <!-- language-all: lang-python -->
  • lambda n:int(n,int(max("1"+n),16)+1)or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPB0TmJlZoKBkqaedp6hiaaWobauYXKeSk5mnkaf4vKAIpSANKGyhpav4HAA)
#3: Post edited by user avatar Shaggy‭ · 2022-09-23T08:18:02Z (over 2 years ago)
  • # Python, 45 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes!
  • <!-- language-all: lang-python -->
  • lambda n:int(n,int(max("2"+n),16)+1)or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPB0TmJlZoKBkpaedp6hiaaWobauYXKeSk5mnkaf4vKAIpSNNQMjAwUNLU/J8GAA)
  • # Python, <s>45</s> 48 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes! The double `max` is annoying me, for example.
  • <!-- language-all: lang-python -->
  • lambda n:int(n,max(2,int(max(n),16)+1))or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPJzexQsNIB8QGsfI0dQzNNLUNNTXzixRyUvOAAv8LikCyaRpKhgZKmpr/AQ)
#2: Post edited by user avatar trichoplax‭ · 2022-09-23T08:16:25Z (over 2 years ago)
Typo
  • # Python, 45 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's someone simple I could be doing to save myself a few bytes!
  • <!-- language-all: lang-python -->
  • lambda n:int(n,int(max("2"+n),16)+1)or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPB0TmJlZoKBkpaedp6hiaaWobauYXKeSk5mnkaf4vKAIpSNNQMjAwUNLU/J8GAA)
  • # Python, 45 bytes
  • I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's something simple I could be doing to save myself a few bytes!
  • <!-- language-all: lang-python -->
  • lambda n:int(n,int(max("2"+n),16)+1)or len(n)
  • [Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPB0TmJlZoKBkpaedp6hiaaWobauYXKeSk5mnkaf4vKAIpSNNQMjAwUNLU/J8GAA)
#1: Initial revision by user avatar Shaggy‭ · 2022-09-22T23:09:54Z (over 2 years ago)
# Python, 45 bytes

I am not a Python guy _at all_, so I'm quite proud of this. I'm sure, though, there's someone simple I could be doing to save myself a few bytes!

<!-- language-all: lang-python -->

    lambda n:int(n,int(max("2"+n),16)+1)or len(n)

[Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHPKjOvRCNPB0TmJlZoKBkpaedp6hiaaWobauYXKeSk5mnkaf4vKAIpSNNQMjAwUNLU/J8GAA)