# Champernowne up to me [duplicate]

Inspired by this question.

Champernowne's constant is an infinite decimal number that consists of "0." followed by all natural numbers concatenated together. It begins like so: 0.123456781011121314151617181920212223242526272829303132333435363738394041424344454647484950, etc. The digits of Chamernowne's constant are sequence A033307 in the OEIS.

Write a program or function that, when given an integer as input, outputs/returns Champernowne's constant up to the first occurance of the input. For example, if the input is 13, you should output 0.12345678910111213. If you wish, for inputs greater than 0, you may drop the leading "0." in your output.

## Input:

An integer, or a string containing only numbers.

## Output:

Champernowne's constant up to the first occurance of the input.

## Test Cases:

0   -> 0
1   -> 0.1 OR 1
14  -> 0.1234567891011121314 OR 1234567891011121314
91  -> 0.1234567891 OR 1234567891
12  -> 0.12 OR 12
101 -> 0.123456789101 OR 123456789101


## Scoring:

This is , lowest score in bytes wins!

## marked as duplicate by FryAmTheEggman code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 4 '17 at 0:02

• Very related. – ETHproductions Aug 3 '17 at 23:57
• @ETHproductions, thanks, I hadn't seen that. It is very closely related, but I don't think it is quite close enough to qualify as a dupe. However, if you disagree, feel free to CV. – Gryphon Aug 3 '17 at 23:58
• @ETHproductions I can't believe I'm getting to the point where I'm forgetting about questions that I actually answered. Anyway to me that seems like a dupe, so I'll close this for now. – FryAmTheEggman Aug 4 '17 at 0:01

# 05AB1E, 6 bytes

### Code

LJ¹¡н«


Uses the 05AB1E encoding. Try it online!

### Explanation

L         # Create the range [1, 2, ..., input]
J        # Join into a single string
¹¡      # Split at occurences of the input
н     # Take the first element
«    # Append the input to the first element and implicitly output

• And I thought this would actually be somewhat difficult :( – Gryphon Aug 3 '17 at 23:55

# Python 3, 7063 61 bytes

A bunch of bytes removed thanks to @Rod, and some more thanks to @WheatWizard

lambda x:''.join(map(str,range(1,x))).split(str(x))[0]+str(x)


Try it online!

• you can save 13 bytes using map instead list comprehension, and backticks instead str – Rod Aug 4 '17 at 0:31
• @Rod Thanks! I've used your map suggestion – Luis Mendo Aug 4 '17 at 14:48
• @WheatWizard Good idea, thanks! – Luis Mendo Aug 4 '17 at 14:53

# Mathematica, 111 bytes

(m=Min@SequencePosition[s=Flatten[IntegerDigits/@Range[0,#]],t=IntegerDigits@#];FromDigits@Join[s[[;;m-1]],t])&


# Pyth, 11 8 bytes

+hcjkSQ


Try it online! or run a Test Suite.

Simply creates the constant (jkSQ) and then prints the constant up to the input (c ... ) followed by the input (+ ...).

# MATL, 2015 14 bytes

U:VXzG&Yb1X)Gh


Takes the input as a string. Try it online!

### Explanation

U      % Implicitly input a string. Convert to number
:      % Range from 1 to that
V      % Convert to string. Includes spaces as separators
Xz     % Remove spaces
G      % Push input again
&Yb    % Split at that. Gives a cell array
1X)    % Get contents of the first cell
G      % Push input again
h      % Concatenate horizontally. Implicitly display