The task
This is a simple challenge.
Your input is a single non-empty string, containing only digits 0123456789
and hashes #
.
It will contain exactly one run of digits, which encodes a nonnegative integer and may wrap around the end of the string, and at least one #
.
The integer may have leading zeroes.
For example, ##44##
, 013####
and 23###1
are valid inputs, while ###
, 0099
and #4#4
are not.
Your task is to extract the integer n
from the string, and output the string rotated n
steps to the right.
Examples
- The input
#1##
should be rotated 1 step to the right, so the correct output is##1#
. - The input
#026###
should be rotated 26 steps to the right, since the leading 0 is ignored. The correct output is26####0
. - The input
1####2
contains the integer 21 wrapped over the end, so it should be rotated 21 steps to the right. The correct output is##21##
.
Rules and scoring
You can write a full program or a function. The lowest byte count wins, and standard loopholes are disallowed.
You can assume that the number n
fits into the standard int
type of your language.
Conversely, if that standard int
type implements arbitrary-precision integers, you must support (in theory) an arbitrarily large n
.
Test cases
#1## -> ##1#
##4## -> #4###
1####1 -> ####11
1####2 -> ##21##
#026### -> 26####0
#000### -> #000###
###82399 -> ##82399#
51379#97 -> #9751379
#98##### -> ###98###
#######4## -> #4########
60752#1183 -> 8360752#11
####99366800## -> 366800######99
########9##### -> ###9##########
91#####515694837 -> 1#####5156948379
###6114558###### -> #6114558########
######219088736090042#### -> 9088736090042##########21
#46055080150577874656291186550000138168########### -> 0138168############4605508015057787465629118655000
568375993099127531613012513406622393034741346840434468680494753262730615610086255892915828812820699971764142551702608639695081452206500085233149468399533981039485419872101852######################3680 -> 99533981039485419872101852######################36805683759930991275316130125134066223930347413468404344686804947532627306156100862558929158288128206999717641425517026086396950814522065000852331494683
n
fits into the nativeint
type of your language (which may be arbitrary-precision). I'll update the challenge text later. \$\endgroup\$1234
? \$\endgroup\$