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

60%
+1 −0
Challenges Digit Sum Integer Sequence (working title)

AWK, 82 bytes {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1} Try it online! Just pass your input, e.g.: echo "123" | awk '...'

posted 5mo ago by xrs‭  ·  edited 5mo ago by xrs‭

Answer
#3: Post edited by user avatar xrs‭ · 2024-05-26T23:13:13Z (5 months ago)
  • # [AWK], 82 bytes
  • {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1}
  • [Try it online!][TIO-lwo5jjsz]
  • [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
  • [TIO-lwo5jjsz]: https://tio.run/##SyzP/v@/urggJ7NEQ8VQJ0VHSUnTOtM20TYl2jDWOi2/SKNCITNPIUWzOiW6ItYu0R4kUxFrZWANomwy7TOh/NqCosy8EoVE7UxtFcPa//@NuEyNuczNuQyNjLksDIyMAA "AWK – Try It Online"
  • Just pass your input, e.g.:
  • `echo "123" | awk '...' `
  • # [AWK], 82 bytes
  • {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1}
  • [Try it online!][TIO-lwo5jjsz]
  • [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
  • [TIO-lwo5jjsz]: https://tio.run/##SyzP/v@/urggJ7NEQ8VQJ0VHSUnTOtM20TYl2jDWOi2/SKNCITNPIUWzOiW6ItYu0R4kUxFrZWANomwy7TOh/NqCosy8EoVE7UxtFcPa//@NuEyNuczNuQyNjLksDIyMAA "AWK – Try It Online"
  • Just pass your input, e.g.:
  • echo "123" | awk '...'
#2: Post edited by user avatar xrs‭ · 2024-05-26T23:12:54Z (5 months ago)
  • # [AWK], 82 bytes
  • {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1}
  • [Try it online!][TIO-lwo5jjsz]
  • [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
  • [TIO-lwo5jjsz]: https://tio.run/##SyzP/v@/urggJ7NEQ8VQJ0VHSUnTOtM20TYl2jDWOi2/SKNCITNPIUWzOiW6ItYu0R4kUxFrZWANomwy7TOh/NqCosy8EoVE7UxtFcPa//@NuEyNuczNuQyNjLksDIyMAA "AWK – Try It Online"
  • # [AWK], 82 bytes
  • {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1}
  • [Try it online!][TIO-lwo5jjsz]
  • [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
  • [TIO-lwo5jjsz]: https://tio.run/##SyzP/v@/urggJ7NEQ8VQJ0VHSUnTOtM20TYl2jDWOi2/SKNCITNPIUWzOiW6ItYu0R4kUxFrZWANomwy7TOh/NqCosy8EoVE7UxtFcPa//@NuEyNuczNuQyNjLksDIyMAA "AWK – Try It Online"
  • Just pass your input, e.g.:
  • `echo "123" | awk '...' `
#1: Initial revision by user avatar xrs‭ · 2024-05-26T23:10:12Z (5 months ago)
# [AWK], 82 bytes

    {split($1,d,"");i=a=d[1];for(x in d){d[x]>a?a=d[x]:0;d[x]<i?i=d[x]:0}print a+i+$1}

[Try it online!][TIO-lwo5jjsz]

[AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
[TIO-lwo5jjsz]: https://tio.run/##SyzP/v@/urggJ7NEQ8VQJ0VHSUnTOtM20TYl2jDWOi2/SKNCITNPIUWzOiW6ItYu0R4kUxFrZWANomwy7TOh/NqCosy8EoVE7UxtFcPa//@NuEyNuczNuQyNjLksDIyMAA "AWK – Try It Online"