All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Basic Bewilderment (Posted on 2011-06-19)
All the positive integers from 1 (base ten) to 2011 (base ten) are expressed alternately in base ten and base 12 and, written successively without commas and spaces resulting in this string.

123456789A1110131215141716.......11B4200911B62011

(I) Reading left to right, what is the 2011th digit in the above string?

(II) Reading right to left, what is the 2011th digit in the above string?

 See The Solution Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution (spoiler) Comment 1 of 1

CLS
FOR i = 1 TO 2011
IF i MOD 2 = 1 THEN
newstr\$ = LTRIM\$(STR\$(i))
ELSE
newstr\$ = ""
n = i
WHILE n > 0
d = n MOD 12
newstr\$ = MID\$("0123456789AB", d + 1, 1) + newstr\$
n = n \ 12
WEND
END IF
prevlen = totlen
totlen = totlen + LEN(newstr\$)
IF totlen >= 2011 AND prevlen < 2011 THEN PRINT newstr\$, 2011 - prevlen, i
NEXT
PRINT totlen

goal = totlen + 1 - 2011
PRINT goal
totlen = 0
FOR i = 1 TO 2011
IF i MOD 2 = 1 THEN
newstr\$ = LTRIM\$(STR\$(i))
ELSE
newstr\$ = ""
n = i
WHILE n > 0
d = n MOD 12
newstr\$ = MID\$("0123456789AB", d + 1, 1) + newstr\$
n = n \ 12
WEND
END IF
prevlen = totlen
totlen = totlen + LEN(newstr\$)
IF totlen >= goal AND prevlen < goal THEN PRINT newstr\$, goal - prevlen, i
NEXT
PRINT totlen

finds

`4B6            3             714 6550 4540A32            1             1478 6550 `

which means:

I: The 2011th digit in the string is 6, as that is the third digit of 4B6, which is the base-12 representation of 714, which is where the 2011th digit happens to fall.

II: The total length of the string is 6550, decimal, and so the 2011th digit from the right is the 4540th digit from the left. Further, that is the first digit of A32, which is the base-12 representation of 1478. Thus A is the answer to part II.

 Posted by Charlie on 2011-06-19 13:53:26

 Search: Search body:
Forums (0)