Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant
08-04-2015, 05:04 AM
Post: #5
 nlj Junior Member Posts: 34 Joined: Apr 2015
RE: Weekend Challenge: Missing Positions in Gods' Triangle
(07-30-2015 04:53 PM)Gerald H Wrote:  Write a programme that on input of the index of a number, say C, that cannot appear as position of any integer returns C, eg

for index

1

the programme returns

11

as 11 is the lowest number not representing the start position of an integer.

The following does the trick:

Code:
«
0 9 NDUPN DROP
→ c
Σi Σc ch
num.ints.at.ch int.width.at.ch
c.width.at.ch tot.c.width.at.ch
c.to.go ints.to.go
«
1 CF
WHILE 1 FC? REPEAT
ch ALOG 9 * 'num.ints.at.ch' STO
ch 1 + 'int.width.at.ch' STO
ch 'c.width.at.ch' STO
num.ints.at.ch c.width.at.ch * 'tot.c.width.at.ch' STO
IF Σc tot.c.width.at.ch + c ≥ THEN
1 SF
ELSE
tot.c.width.at.ch 'Σc' STO+
num.ints.at.ch int.width.at.ch * 'Σi' STO+
END
1 'ch' STO+
END
c Σc - 'c.to.go' STO
c.to.go c.width.at.ch / FLOOR 'ints.to.go' STO
Σi
ints.to.go int.width.at.ch *
c.to.go c.width.at.ch MOD
+ +
»
»

As requested, it returns 11 for an input of 1, 1089 for an input of 690, and, for example, 1124999998 for an input of 987654321.

[Here i refers to an index into God's Number, c refers to the "dead" digits of God's Number where no integer starts, and ch (characteristic) is the power of ten currently being addressed as we iterate from the "units" to the "tens" to the "hundreds" etc.. All local variables are initialised to zero except for the input value, c.]
 « Next Oldest | Next Newest »

 Messages In This Thread Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - Gerald H - 07-30-2015, 04:53 PM RE: Weekend Challenge: Missing Positions in Gods' Triangle - Thomas Klemm - 07-30-2015, 06:52 PM RE: Weekend Challenge: Missing Positions in Gods' Triangle - Paul Dale - 07-30-2015, 10:18 PM RE: Weekend Challenge: Missing Positions in Gods' Triangle - Gerald H - 07-31-2015, 05:23 AM RE: Weekend Challenge: Missing Positions in Gods' Triangle - nlj - 08-04-2015 05:04 AM RE: Weekend Challenge: Missing Positions in Gods' Triangle - Gerald H - 08-04-2015, 07:23 AM RE: Weekend Challenge: Missing Positions in Gods' Triangle - Gerald H - 08-07-2015, 05:08 PM RE: Weekend Challenge Sharpened: Missing Positions in Gods' Triangle - ttw - 08-08-2015, 03:53 AM RE: Weekend Challenge Sharpened: Missing Positions in Gods' Triangle - Gerald H - 08-08-2015, 05:08 AM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - nlj - 08-08-2015, 02:26 PM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - Gerald H - 08-08-2015, 03:25 PM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - Gerald H - 08-08-2015, 04:27 PM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - nlj - 08-08-2015, 06:01 PM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - nlj - 08-09-2015, 10:12 PM RE: Weekend Challenge Sharpened: Missing Positions in Champernowne's Constant - nlj - 08-10-2015, 02:54 AM

User(s) browsing this thread: 1 Guest(s)