みなさん、カウントアップ!


30

前書き

奇妙に聞こえるかもしれませんが、から1までカウントするためのチャレンジは1つもありませんn

これは同じことではありません。その1つは(閉じた)十分に説明されていない挑戦です。
これは同じことではありません。それは無期限にカウントアップすることです。

チャレンジ

から1までのすべての整数を出力するプログラムまたは関数を作成しnます。

ルール

  • nどんな方法でも手に入れることができます。
  • これnは常に正の整数であると想定できます。
  • n任意のベースを取得できますが、常に10進数で出力する必要があります。
  • 出力は、にない文字(またはパターン)で区切る必要があります0123456789。10進数以外の先頭または末尾の文字を使用できます(たとえば、などの配列を使用する場合[1, 2, 3, 4, 5, 6])。
  • 標準の抜け穴は拒否されます。
  • 最短の言語ではなく、各言語で最短のアプローチを見つけたいので、私は答えを受け入れません。
  • この編集後に回答を更新する必要があります。最後の編集の前に投稿された回答は、標準の抜け穴に関する変更ルールに準拠する必要があります(拒否したくありませんでしたが、コミュニティをroめたくありませんでした。私はそれらを否定しました)。
  • デート後の任意の言語バージョン(または言語)を使用できます。この課題のためだけに作成された言語または言語バージョンは使用できません。

ボーナス

20%

  • プログラムは、少なくとも184467440737095516152^64-1)までカウントできる必要があります。たとえば、新しいデータ型が大きな整数をサポートする唯一の方法である場合、それを構築する必要があります。あなたの言語が最大2 ^ 64-1までの巨大な整数をサポートする方法を持っていない場合、代わりにその特定の言語の上限をサポートする必要があります。

編集:制限をから2^64に変更し2^64-1て、より多くの回答を許可しました。

編集:このチャレンジにはあまり関心がなかったので、2 ^ 64-1ルールをボーナスにしました。回答が2 ^ 64-1をサポートしている場合、ボーナスを含めるように編集できます。また、短い場合は、サポートしていない回答を投稿できます。



nどんな方法でも手に入れることができます。」それnは、変数に保存されると仮定できるということですか?
フレイ

@flawr どんな方法で入手 nできます。変数に保存できますが、ハードコーディングしてはいけません。
エリックアウトゴルファー


@Ephphathaはい、おそらくこのチャレンジは、私がまったくの初心者だった昔からのものです。
エリックアウトゴルファー

回答:


60

MarioLANG、29バイト

;
)    <
+===="
>:(-[!
=====#

オンラインでお試しください!

私のコードは悲しいことに非常に悲しいか怒っていることを知っています:



> :(

Happy MarioLANG、46バイト

;
)       <
+======="
>  >((-[!
=:)^====#
 ===

オンラインでお試しください!

幸せなアプローチ:




 :)

感情的でないMarioLANG、41バイト

;
)     <
+====="
> >(-[!
= "===#
 :!
 =#

オンラインでお試しください!


1
最後のスニペットにはまだ感情があり:!ます;)
クッキー

1
あなたのような、いくつかの幻想と絵文字として多くのものを見ることができ、その場合には@cookie =#、または>(、あるいは(-[また、など、全く分からない理由が、どうやらそこにある顔文字Wikipediaのページの一覧が含まれていない、:!も私が言及したもののいずれか。
ケビンCruijssen

別の質問に触発された19バイト
ドリアン

28

Pyth、1バイト

S

本文は少なくとも30文字でなければなりません。14を入力しました。


2
あなたはそう言う?タイトルに苦労しました!
エリックアウトゴルファー16

43
これは、説明を追加できなかったためです。このような複雑なコードを説明なしで理解するにはどうすればよいでしょうか?
ルイスメンドー

10
いや このコードは私の理解をはるかに超えています。長すぎて、このような複雑な論理構造を把握できません。
ルイスメンドー

7
@LuisMendo私は知っています... orlpは、このような長いコードを高度なロジックで理解する天才だったに違いありません。:P
HyperNeutrino

1
あなたはまだ現在の勝者です!
エリックアウトゴルファー16

16

Cjam、5バイト

{,:)}

オンラインでお試しください!

これは名前のないブロックでありn、スタック上にあることを期待し、その範囲のリストを残します[1...n]
範囲を構築するだけで機能し,、すべての範囲要素をインクリメントし:)て範囲を1ベースにします。


9
コードに不思議なことに現れたスマイリーの+1::)
user48538

1
@ zyabin101スマイリーフェイスは非常に一般的なCJam発生です!
シモンズ

4
@ASimmonsがCjamを締めくくるのは幸せですか
エリックアウトゴルファー

14

Mathematica、5バイト

Range

簡単です。


33
この言語を支払うために支払う必要がある場合は簡単ではありません:
エリックアウトゴルファー

1
@ΈρικΚωνσταντόπουλος金持ちの方が簡単になったと私は主張しますが、あなたはなんとかこの答えを4バイト倒すことができました;)
Sebb

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀあなたのコメントから長い時間が経ったことは知っていますが、あなたはその言語を買う余裕はなく、あなたその言語に対して支払います。
NoOneIsHere

@NoOneIsHere は、支払いによって何かの所有権を主張することを意味します。一度限りの支払いではなく、サブスクリプションがあることを意味すると思います。
エリックアウトゴルファー

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ一度に約150ドルの支払いがありますが、議論を続けるためにチャットに行きましょう。
NoOneIsHere

14

六角形、19

$@?!{M8.</(=/>').$;

または、拡張六角形形式で:

  $ @ ?
 ! { M 8
. < / ( =
 / > ' ) 
  . $ ;

基本的にこのプログラムを考案してくれたMartinに大いに感謝します。私はゴルフをして、長さ3の六角形に収まるようにしました。

オンラインでお試しください!

私はTimwiの素晴らしいHexagony関連のプログラムを持っていないので、この説明はあまりカラフルではありません。代わりに、膨大な量のテキストを読むことができます。いいじゃない?

いずれにせよ、IPが$マップの北を上に向けて配置されていると想像した場合、IPはの左上隅から東に向かって移動します。これ$により、次の命令がスキップされ@、プログラムが終了します。代わりに、?現在のメモリエッジを入力番号に設定する実行を行います。行の終わりに到達すると、六角形の中央の行に移動しますが、依然として東に向かっています。

プログラムの残りのほとんどはループです。まず、.これはノーオペレーションです。次に、...ええと...六角形の分岐点に遭遇します。<現在のメモリエッジが正の場合、命令はIPを右に60度回転させ、そうでない場合は左に60度回転させます。私たちは東に向かっているため、見出しは南または北東になります。入力はゼロよりも大きい(したがって正である)ため、常に南東に移動することから始めます。

次に、ヒット >を押して、東にリダイレクトします。これらの演算子は、フォーク部分にヒットした場合にのみフォークします。次に、'どのメモリエッジを変更するかを選択します。次に、ヒット)すると、現在のメモリエッジの値が増加します。すべてのメモリエッジは0から始まるため、これを最初に実行すると値1が取得されます。次に、2行目から1行目までジャンプして実行!し、数値を出力します。次に{、MのASCII値に10プラス8を掛けた値(778)で別のエッジに移動します。次に、六角形の最後から2番目の行にジャンプして戻り/ます。その結果、私たちは北西に移動します。.真ん中の行を過ぎて、;右下にあります。これにより、現在のメモリエッジmod 256がASCIIとして出力されます。これはたまたま改行です。ヒット'すると、読み取った値を持つ最初のエッジに戻ります。ヒットする/と、再び東に移動します。次に、ヒットする(と値が減少します。=将来のメモリエッジのジャンプのために、再び正しい方向に向かいます。

ここで、値は(ゼロでない限り)正なので、六角形の底に戻ります。ここでヒットして.からジャンプして;、何も起こらず、ループの最初に戻ります。値がゼロの場合、プログラムの先頭に戻り、同じことが再び起こり?ますが、別の番号を見つけることができず、別の分岐パスを使用します。そのパスは比較的単純です。{メモリエッジを変更するものをヒットしますが、もう気にしません。その後@、プログラムを終了するものをヒットします。




10

R、13バイト

cat(1:scan())

本文は少なくとも30文字でなければなりません。


あなたの答えを編集することはできません。
エリックアウトゴルファー16

@ΈρικΚωνσταντόπουλος承認が必要な編集のみを現在の評判で提案できます。コードの編集はここでは歓迎されないことに注意してください。ゴルフに関するアドバイスがある場合は、ソリューションを更新する前に作成者がテストできるようにコメントを書いてください。
デンカー

@DenkerAffe以前は編集ボタンがグレー表示されていました。
エリックアウトゴルファー16

1
あなたがスクリプトを呼び出したときでさえ、それを書いて欲しいなら、私はそうします。
マスクリン

9
CATスキャンは、骨の損傷を表示したり、肺や胸の問題を診断したり、カウントではなく癌を検出したりするのに最適だと思いました。
スチューウィーグリフィン

10

ジャバスクリプト182 177 160 154 139 138 132バイト(有効)

@ShaunHのおかげで1バイト節約

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}}

救助に任意の精度!

javascriptは2 ^ 53-1までしかカウントできないため(指摘してくれた@MartinBüttnerに感謝します)、これを行うには任意の精度を作成する必要がありました。データを配列に格納し、「ティック」するたびに最後の要素に1を追加し、配列をトラフに移動します。何かが9を超えると、その要素を0に設定し、左側の要素に1を追加します。

ここで試してみてください! 注:テキストボックスを待たせたくなかったので、実際に結果を確認するにはF12キーを押します。

ところで:私が唯一知らなかったのは、三項演算子がcodegolfでとても役立つことを知りませんでしたか?

if(statement)executeSomething();

より長い

statement?executeSomething():0;

1バイトずつ。

Javascript、28バイト(無効-2 64までカウントできません)

n=>{for(i=0;i++<n;)alert(i)}

2
うん、あなたはただ一人でした:P
エリックアウトゴルファー

無効なバージョンは2 ^ 64-1までカウントできますか?その場合、新しいルールのおかげで有効です。
エリックアウトゴルファー16

唯一最大2 ^ 53-1にΈρικΚωνσταντόπουλοςいいえ、@
バリント

ifが他にない場合&&も同様に有用であるため、まとまりに注意する必要があります。condition&&action()
ショーンH

1
e?c.unshift(1):0e&&c.unshift(1)バイトを保存するには
ショーンH

9

Java 8、43 / 69/94バイト

取り消された44はまだ通常の44です-待ってください、取り消さずに置き換えただけです:(

私が返せる場合LongStream:(43 bytes

n->java.util.stream.LongStream.range(1,n+1)

これはaのラムダですFunction<Long,LongStream>。技術的rangeClosedにはrange、の代わりにを使用する必要がrangeClosedありrangeます。これは、この方法で最大入力から1つをカットするためです。

関数で印刷する必要がある場合:(69 bytes

n->java.util.stream.LongStream.range(1,n+1).peek(System.out::println)

これはaのラムダですConsumer<Long>。技術的にはpeek、このラムダが技術的に最初の例のように返す中間操作であるため、悪用していLongStreamます。forEach代わりに使用する必要があります。繰り返しますが、ゴルフは良いコードではありません。

残念ながら、longの範囲は符号付き 64ビット整数であるため、要求された2^64-1には達しませんが、単に2^63-1ます。

ただし、Java SE 8は、クラスの特定のメソッドを明示的に呼び出すことにより、longs 署名されていないものとして扱う機能を提供しますLong。残念ながら、Javaは依然としてJavaであるため、これはかなり長い時間がかかりますが、置き換えられるBigIntegerバージョンよりも短くなっています。(94 bytes

n->{for(long i=0;Long.compareUnsigned(i,n)<0;)System.out.println(Long.toUnsignedString(++i));}

これはConsumer<Long>、前と同様にです。

スクロールを避けるには長すぎます。


2 ^ 64-1の制限が変更されました:D
Erik the Outgolfer

1
最初の関数はすべきではありませんn->java.util.stream.LongStream.range(1,n+1)か?
メゴ

2
。@ zyabin101>>あなたは何も見なかった
CAD97

1
@KevinCruijssenを使用する理由を除いて、イテレータに(または)をBigInteger使用するだけでは十分ではないため、役立ちます。intlong
CAD97

1
私は間違っていました。J8はlong署名なしで使用するためのメソッドを提供するため、それらを利用する方法はBigIntegerアプローチよりも短くなります。(J8以前のように、独自の符号なしの長い処理を実装しなければならなかったでしょう。)
CAD97



7

Haskell、10バイト

f n=[1..n]

使用例:f 4-> [1,2,3,4]


あなたはハードコードしてnはいけません、あなたは取る必要がありますn
エリックアウトゴルファー16

4
@ΈρικΚωνσταντόπουλος nはここではハードコードされていません-これは関数の引数です。Haskell構文は、Cに似た構文に慣れている人にとっては奇妙なものです。
メゴ

@Megoああ、私は使用例と混同されました。
エリックアウトゴルファー16

7

MarioLANG、19バイト

;
)<
+"
:[
(-
>!
=#

オンラインでお試しください!

通常、垂直プログラムは、MarioLANGの単純なループでよりゴルフに適しています。エレベーター内で遭遇したときにインタープリターが何をするはわかりません[が、現在のセルが0のときにプログラムを終了するようです。これはおそらく一般的に有用なトリックです。

説明

MarioLANGは、命令ポインタがマリオの歩行とジャンプに似ているBrainfuckのような言語です(任意精度の整数の無限のメモリテープを使用)。

マリオは左上隅から始まり、下に落ちます。;STDINから整数を読み取り、現在のメモリセルに配置します。これ=がマリオが歩くための地上セルで"あり#、エレベーターが(#開始点として)エレベーターを形成し、!マリオがすぐに降りないようにエレベーターで停止することに注意してください。そして><彼の移動方向を設定します。これにより、次のコードを含む単純なループが生成されることがわかります。

)   Move memory pointer one cell right.
+   Increment (initially zero).
:   Print as integer, followed by a space.
(   Move memory pointer one cell left.
-   Decrement.
[   Conditional, see below.

現在、通常[、現在のセルがゼロかどうかに応じて、条件付きでマリオが次をスキップします。つまり、カウンターがゼロ以外である限り、これは何もしません。しかし、マリオが遭遇したときと思われる[エレベーターに乗っている間、および現在のセルがあり0、プログラムは単に私たちも、正しく彼をリダイレクトする方法を見つける必要がないことを意味エラー、直ちに終了します。


「落ちる」ので、プログラムを終了します。
エリックアウトゴルファー16

あなたも56を選びましたか?
エリックアウトゴルファー16

@ΈρικΚωνσταντόπουλοςマリオが落ちる場所を見つけることができないようです。インタプリタはでエラーを出して終了するように見えますが、[実際にはさらに便利です。
マーティンエンダー

TIOには、デバッグを有効にしないとエラーメッセージ(STDERR)が表示されない傾向があります。それ確かにエラーのようです。
エリックアウトゴルファー16

@ΈρικΚωνσταντόπουλος Yeah, and that's actually good, because STDERR is ignored unless specified otherwise.
Martin Ender

6

Joe - 2 or 6

While you can use the inclusive variant of the range function..

1R

..that's boring! Let's instead take the cumulative sum (\/+) of a table of ones of shape n (1~T).

\/+1~T

Can you provide a link to the language
Downgoat




4

dc, 15

?[d1-d1<m]dsmxf

Input read from stdin. This counts down from n, pushing a copy of each numbers to the stack. The stack is then output as one with the f command, so the numbers get printed in the correct ascending order.

Because all the numbers are pushed to the stack, this is highly likely to run out of memory before getting anywhere near 2^64. If this is a problem, then we can do this instead:


dc, 18

?sn0[1+pdln>m]dsmx

Maybe it works with 2^64-1 (the new limit).
Erik the Outgolfer

The first one will run out of memory long before you reach 2^64-1. The second will keep on happily going until our sun goes supernova
Digital Trauma

@DigitalTraumaskcsockso I meant that you can edit your second answer if it's shorter for 2^64-1.
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος dc, like bc, uses arbitrary precision math by default, and thus such boundaries are irrelevant for this language.
Digital Trauma

4

ArnoldC, 415 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE n
YOU SET US UP 0
GET YOUR ASS TO MARS n
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
HEY CHRISTMAS TREE x
YOU SET US UP n
STICK AROUND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
GET UP 1
ENOUGH TALK
TALK TO THE HAND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

The only thing of interest is to use n-x (where n is the goal and x the incremented variable) to test the end of the while loop instead of having a dedicated variable, so I end up having n-x and n-(n-x) = x in each loop run

Note: I can only count to 2^31-1. Well I guess the Terminators are not a real danger after all.


3
Of course there is a programming language designed around Arnold Schwarzenegger memes...
Nzall

4

Piet, 64 Codels codelsize 1

With codelsize 20:

codelsize 20

Npiet trace images

First loop:

tracestart

Remaining trace for n=2:

traceend

Notes

  • No Piet answer yet? Let me fix that with my first ever Piet program! This could probably be shorter with better rolls and less pointer manipulation though...

  • The upper supported limit depends on the implementation of the interpreter. It would theoretically be possible to support arbitraryly large numbers with the right interpreter.

  • The delimeter is ETX (Ascii 3), however this cannot be properly displayed in this answer so I'll just leave them out. It works in the console:

enter image description here

Output

Input:  1
Output: 1

Input:  20
Output: 1234567891011121314151617181920

Input:  100
Output: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100

Undefined behaviour:

Input:  -1
Output: 1

Input:  0
Output: 1

Npiet trace for n=2

trace: step 0  (0,0/r,l nR -> 1,0/r,l lB):
action: in(number)
? 2
trace: stack (1 values): 2

trace: step 1  (1,0/r,l lB -> 2,0/r,l nB):
action: push, value 1
trace: stack (2 values): 1 2

trace: step 2  (2,0/r,l nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 1 1 2

trace: step 3  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
1
trace: stack (2 values): 1 2

trace: step 4  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 1 2

trace: step 5  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 2 2

trace: step 6  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 7  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 2 2 2

trace: step 8  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 2 2 2

trace: step 9  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 2 2

trace: step 10  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 2 2

trace: step 11  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 2 2

trace: step 12  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 2 2

trace: step 13  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 2 2 2

trace: step 14  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 0 2 2

trace: step 15  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 0 2 2

trace: step 16  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 0 2 2

trace: step 17  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 2

trace: step 18  (9,1/l,r nY -> 7,1/l,r dY):
action: push, value 2
trace: stack (3 values): 2 2 2

trace: step 19  (7,1/l,r dY -> 6,1/l,r lY):
action: push, value 1
trace: stack (4 values): 1 2 2 2

trace: step 20  (6,1/l,r lY -> 5,1/l,r nM):
action: roll
trace: stack (2 values): 2 2

trace: step 21  (5,1/l,r nM -> 4,1/l,r dM):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 22  (4,1/l,r dM -> 3,1/l,r lG):
action: pointer
trace: stack (2 values): 2 2

trace: step 23  (3,1/d,r lG -> 2,3/l,l nG):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 24  (2,3/l,l nG -> 2,2/u,r lY):
action: out(char)

trace: stack (2 values): 2 2
trace: white cell(s) crossed - continuing with no command at 2,0...

trace: step 25  (2,2/u,r lY -> 2,0/u,r nB):

trace: step 26  (2,0/u,r nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 27  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
2
trace: stack (2 values): 2 2

trace: step 28  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 2 2

trace: step 29  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 3 2

trace: step 30  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 3 3 2

trace: step 31  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 3 3 2

trace: step 32  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 3 3 2

trace: step 33  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 3 3

trace: step 34  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 3 3

trace: step 35  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 3 3

trace: step 36  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 3 3

trace: step 37  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 3 2 3

trace: step 38  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 1 2 3

trace: step 39  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 1 2 3

trace: step 40  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 3 2 3

trace: step 41  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 3
trace: white cell(s) crossed - continuing with no command at 9,3...

trace: step 42  (9,1/d,r nY -> 9,3/d,l nR):

Does it have null bytes between numbers?
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος what do you mean? In the console, you can see the ETX character (Ascii 3) splitting the outputs, the ETX character cannot be displayed on this site though.
Marv

4

JavaScript (ES6), 77 76 63 59 58 Bytes

n=>{for(s=a=b=0;s!=n;console.log(s=[a]+b))a+=!(b=++b%1e9)}

Takes input n as a string, should support up to 9007199254740991999999999

Explained:

n=>{ //create function, takes n as input
    for( //setup for loop
        s=a=b=0; //init s, a, and b to 0
        s!=n; //before each cycle check if s!=n
        console.log(s=[a]+b) //after each cycle concat a and b into to s and print
    )
        a+=!(b=++b%1e9) //During each cycle set b to (b+1)mod 1e9, if b == 0 and increment a
} //Wrap it all up

Explanation please.
Bálint

2^64-1 is fine I've changed spec.
Erik the Outgolfer

1
Interesting, I didn't think of just concatenating two numbers to reach the minimum value. BTW, you could save a lot of bytes by using two variables instead of an array: n=>{for(a=b="";a+""+b!=n;console.log(a+""+b))++b-1e9||(++a,b=0)}
user81655

Thanks for that @user81655, my brain loves arrays for some reason
Shaun H

1
You can save a byte by changing a+""+b to [a]+b
Bassdrop Cumberwubwubwub

3

GNU bc, 23

n=read()
for(;i++<n;)i

Input read from stdin. bc handles arbitrary precision numbers by default, so the 2^64 max is no problem.


3

Actually, 1 byte

R

Boring builtin is boring. Requires a 64-bit version of Python 3 to get all the way up to 2**64.

Try it online! (due to memory and output length restrictions, the online interpreter can't go very high).

Here's a 5-byte version that doesn't require 64-bit Python 3 and is a little nicer on memory usage:

W;DWX

Try it online! (see above caveats)


@StewieGriffin The issue is with addressable RAM, not integer limits (Python seamlessly transitions between native ints and big integers). I tested it with both 32-bit Python 3 and 64-bit Python 3. 32-bit failed, 64-bit didn't.
Mego

@Mego I have changed the limits, although I don't think 32-bit Python supports 2^64-1, I think it supports up to 2^32-1, so I encourage for the latter to be used in the Python case.
Erik the Outgolfer

Why do you call Seriously Actually?
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος Like I mentioned to Stewie, the issue isn't 64-bit ints, but memory addressing. Because of how inefficient Seriously and Actually are at memory usage, they very quickly exhaust the memory limit of 32-bit processes. And Actually and Seriously are different languages - Actually is the successor to Seriously.
Mego

@Mego Oh, I once clicked a link for Actually and it linked me directly to Seriously.
Erik the Outgolfer

3

Fuzzy-Octo-Guacamole, 7 bytes

^!_[+X]

Explanation:

^ get input to ToS
! set for loop to ToS
_ pop
[ start for loop
+ increment ToS (which aparently happens to be 0)
X print ToS
] end for loop

Also, X works instead of o;, for 7 bytes.
Rɪᴋᴇʀ

Wouldn't that print [n]?
Bald Bantha

rather than n
Bald Bantha

No. : prints the full stack. X is new.
Rɪᴋᴇʀ

Also, another 7 byte solution: ^!$[_;]. $ is range.
Rɪᴋᴇʀ

3

Oration, 31 bytes (non competing)

literally, print range(input())

Is this python with literally, in front of every statement? (Question 2: Pre-dates or post-dates if it's yours? both are acceptable unless you made this for this challenge, in which case it's a loophole)
Erik the Outgolfer

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I believe Oration is by ConorO'Brien. github.com/ConorOBrien-Foxx/Assorted-Programming-Languages/tree/… Also, if this language was invented after the challenge, (which it wasn't) it wold be non-competing but still a valid answer. I'm not a big fan of the "Your language must pre-date the challenge" rule. I think if someone invents a 0 or 1 byte solution to a challenge, that's clearly against the rules, but using a new real language should be allowed.
DJMcMayhem

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ this is what Dr Green Eggs said. I'm actually Easterlyirk's chatbot.
Żáłģó

So no review for you?
NoOneIsHere

@NoOneIsHere what?
Żáłģó

3

QBASIC, 43 bytes

1 INPUT a
2 FOR b=1 TO a
3 PRINT b
4 NEXT b

Do you really need INPUT e;a or INPUT a is enough? I don't see you re-using e.
Erik the Outgolfer

good point, not sure why that was there.
Michelfrancis Bustillos

Also, do you really need the spaces between the line number and letters and between 1 TO?
Erik the Outgolfer

Yes, those are necessary
Michelfrancis Bustillos

What version of QBasic is this? Can you use : between statements instead of a return and a line number? QB4.5 lets me do this: INPUT a: FOR b=1 TO a (\n) ?b:NEXT
steenbergh

3

Cubix, 17 bytes

..U;I0-!@;)wONow!

Try it here

Cubix is a 2D language created by @ETHProductions where the commands are wrapped onto a cube. This program wraps onto a cube with an edge length of 2 as follows.

    . .
    U ;
I 0 - ! @ ; ) w
O N o w ! . . .
    . .
    . .
  • I gets the integer input
  • 0 push 0 to the stack
  • - subtract top items of stack
  • ! if truthy jump the next command @ terminate
  • ; pop the subtraction result from the stack
  • ) increment top of stack
  • w move ip to the right and carry on. This causes it to drop to the next line
  • O output the top of stack as a number
  • N push linefeed (10) to the stack
  • o output a linefeed
  • w move ip to the right and carry on. This causes it to drop to the next face
  • ! because TOS truthy, jump the @ terminate
  • ; pop the linefeed from the stack
  • U uturn to the left onto the - subtraction and resume from there

2

Python 2, 37 33 32 33 bytes

for i in xrange(input()):print-~i

Presumably works up to 2**64 and beyond.

Shot down four bytes thanks to @dieter, and another thanks to @orlp. But apparently, as @Sp3000 found out, range() might have issues with higher values, so the function was changed to xrange(). Note: even xrange() might have issues, at least in 2.7.10.


1
Python 2, to be exact :)
Erik the Outgolfer

33 bytes -> for i in range(input()):print i+1
dieter

2
32 bytes -> for i in range(input()):print-~i
orlp

1
"Presumably works up to 2**64 and beyond." - doubt it in Python 2, but it might with xrange (edit: even xrange might have issues, at least in 2.7.10)
Sp3000

How does -~ work? Edit: I figured it out. Also, nice trick!
Erik the Outgolfer


2

V, 11 Bytes

é1@añYpñdd

Since this contains nasty UTF-8 and unprintables, here is a reversible hexdump:

00000000: e931 4061 f159 7001 f164 64              .1@a.Yp..dd

V is an unfinished language I wrote, but this is working as of commit 19. This answer was a little more verbose than I'd like, but that's mostly because V has no knowledge of integers, only strings. So it's a decent answer! This will work up to 2^64, but it will probably take a very long time.

To make my explanation easier to read/write, I will work with this "Human readable form", which is actually how you would type this in vim.

<A-i>1@a<A-q>Yp<C-a><A-q>dd

Explanation:

'Implicit: register "a" == arg 1, and any generated text is printed. 

<A-i>1                       'Insert a single character: "1"
      @a                     ' "a" times, 
        <A-q>       <A-q>    'Repeat the following:
             Yp<C-a>         'Duplicate the line, and increment it
                         dd  'Delete the last line, since we have one too many.

If loopholes are allowed, here's a shorter version that prints 1 to n, but also prints a 0 (8 bytes):

é0@añYp

And in readable form:

<A-i>1@a<A-q>Yp<C-a>

This is shorter because the <A-q> at the end is implicit, so we don't need it if we don't have to delete the last line.


It can take as long as it wants. Glad to see an answer to work with 2^64, especially with an unfinished language. +1
Erik the Outgolfer

I have changed the limit to 2^64-1 because standard loopholes are disallowed now, and I don't want to cut answers out too much.
Erik the Outgolfer
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.