Print the ASCII printable character set

6

0

Challenge: Print the entire printable ASCII charset (not just a range!) in order.

[space]!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

(Of course, replace space with the actual space character.)

Rules: read closely

  • No other characters allowed in the output.

  • Program/function does not accept input.

  • Try not to hardcode/embed the output.

  • This is code golf, shortest answer wins.

dkudriavtsev

Posted 2016-07-11T00:25:09.303

Reputation: 5 781

5

Well they are a couple main things about this challenge that are why it's getting downvoted. A) the community really doesn't like it when you ban golfing language (whether or not I agree with this is a different matter) B) it's rather simple but I wouldn't say it's exactly trivial (kinda on the edge). Also saying "Try not to ..." usually isn't a good sign because it's not actually enforcing it (because it's hard to enforce this objectively), and it might mean your challenge may not be found that interesting (therefore getting downvotes).

– Downgoat – 2016-07-11T00:38:51.980

8I'm not sure how to interpret try not to hardcode the output here. For a constant output challenge, that's the only way... – Dennis – 2016-07-11T00:50:47.407

@Dennis I meant something like: echo " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" – dkudriavtsev – 2016-07-11T01:19:32.677

1Do we have to print the output from a function or is returning a string acceptable? – Dennis – 2016-07-11T05:53:55.043

1Are built-ins accepted or not? The rule about hardcoding is not clear on that. The MATL answer form @Suever seems to use built-in that contains the printable ASCII. – Fatalize – 2016-07-11T06:37:12.917

2Does "no other characters" include embedded newlines? – Neil – 2016-07-11T07:48:14.683

:( unfortunately the Brainfuck code +[+.] (5 bytes) doesn't count as it fails the first rule... – grooveplex – 2016-07-11T11:42:32.863

2This is NOT a duplicate of that challenge! Programs there had to accept input and print only part of the table. This challenge is easier and different. – dkudriavtsev – 2016-07-11T23:23:29.510

Answers

5

MATL, 3 bytes

6Y2

Try it Online

And for the sake of a non-built-in (7 bytes)

32:127c

Suever

Posted 2016-07-11T00:25:09.303

Reputation: 10 257

Non-builtin: '~':. – Stewie Griffin – 2018-04-30T12:09:43.143

@StewieGriffin Unfortunately that didn't work until 18.5.0. Here's what it looked like at the time of this challenge.

– Suever – 2018-04-30T12:42:40.143

15

Brainfuck, 30 27 bytes

+[[>++<<+>-]>]<<<++[<.+>++]

Try it online!

How it works

+ changes the initial cell to 1. After this step, we enter the following, nested loop.

[        While the current cell is non-zero:
  [        While the current cell (C) is non-zero:
    >++      Increment the cell to C's right twice.
    <<+      Increment the cell to C's left.
    >-       Decrement C.
  ]
  >        Advance to the cell to C's right.
]

This computes consecutive powers of 2 until the the value 256 = 0 (mod 256) is reached. When the outer loop finishes, the tape is in the following state.

                                     v
001 002 004 008 016 032 064 128 000 000 000

<<<++ retrocedes three cells and increments twice, leaving the tape as follows.

                         v
001 002 004 008 016 032 066 128 000 000 000

Now we're ready to print the actual output. As a stop condition, we increment the cell above twice each time we print and increment the cell to its left. Since 66 + 95 × 2 = 256 = 0 (mod 256), we stop after printing all 95 printable ASCII characters. We achieve this as follows.

[      While the current cell (C) is non-zero:
  <      Retrocede to the cell to C's left.
  .+     Print its content and increment.
  >++    Increment C twice.
]

Dennis

Posted 2016-07-11T00:25:09.303

Reputation: 196 637

2with Dennis brainfuck outgolfs procedual programming languages! – downrep_nation – 2016-07-11T06:59:35.960

@Dennis - You may want to add a leading >. Your implementation runs off the tape to the left, which few interpreters support. – owacoder – 2016-07-11T14:14:09.013

3@owacoder On PPCG, languages are defined by their implementations. As long as there is one interpreter that behaves as desired (and the one on Try it Online! does), it's considered valid. – Dennis – 2016-07-11T15:23:24.590

@owacoder Well actually a lot of interpreters support negative tape indices nowadays – ASCII-only – 2018-04-27T05:12:39.940

6

Brainfuck, 40 39 bytes

++++[->++++[->++>++++++<<]<]>>>-[-<.+>]

Try it online.

Explanation

++++[->++++[->++>++++++<<]<]

The nested loops basically mean you multiply the number of plusses together, so 4 × 4 × 2 = 32 in one cell and 4 × 4 × 6 = 96. Here is the tape after running this:

00 00 32 96
 ^

>>>- moves the pointer to the fourth cell and decrements it. Now we're done with the setup. 32 is the code for space, the first printable ASCII character. 95 is the number of characters we have to print. Here is the tape now:

00 00 32 95
          ^

[-<.+>] runs until the current cell (the fourth one) is zero. It decrements the counter and prints the character and increments it for the next time.

NinjaBearMonkey

Posted 2016-07-11T00:25:09.303

Reputation: 9 925

6

Cheddar, 29 bytes

->(32:126).map((i)->@"i).fuse

Range from 32-126, loop over it and get the string at the given char code @" and the fuse together (join)

Cheddar, 7 bytes

32@"126

Unfortunately this is broken as of the current release but I'm sure you can go back some versions where this works

Downgoat

Posted 2016-07-11T00:25:09.303

Reputation: 27 116

eyyy my @" operator! – Conor O'Brien – 2016-07-12T00:22:27.310

@CᴏɴᴏʀO'Bʀɪᴇɴ it's a very useful operator 10/10 – Downgoat – 2016-07-12T00:22:58.223

5

Retina, 18 bytes


~
{2`
$`
T01`p`_p

The leading linefeed is significant.

Try it online!

Explanation

Stage 1: Substitution


~

We start by replacing the empty (non-existent) input with a single ~.

Stage 2: Substitution

{2`
$`

The regex of this substitution is still empty, since the ` separates configuration from regex and {2 is therefore just the configuration. The { indicates that the remaining two stages should be run in a loop until they stop changing the output. The 2 indicates that this specific stage has a limit of 2, meaning that only the first two matches of the regex will be replaced. Since the regex is empty, that means we get an empty match in front of the string and an empty match after the first character.

This match is replaced with the prefix $` which refers to everything in front of the match. For the first match, there is nothing in front of it, so this doesn't insert anything, but for the second match, there is the leading character in front of it, which therefore gets duplicated.

Stage 3: Transliteration

T01`p`_p

Here, T activates transliteration mode, and 0 and 1 are limits (where 0 just means "don't set this limit"). Together, they mean "transliterate only the first character in the string". The actual transliteration maps from p to _p. Here, p expands to the printable ASCII characters and _ means "remove" this character, so the expanded lists look like this:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
_ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

That means spaces get removed and all other characters get decremented by one.

To see how the last two stages act together here is the string after each of the first few and last stages:

~
~~
}~
}}~
|}~
||}~
{|}~

...

"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Since the state of the string is only checked after every other stage to determine whether to end the loop, and the two stages cancel each other once we reach the leading space (since Stage 2 adds a space and Stage 3 removes it), this terminates the loop and therefore the program.

Martin Ender

Posted 2016-07-11T00:25:09.303

Reputation: 184 808

4

Python 2, 30 bytes

print bytearray(range(32,127))

Try it online!

Lynn

Posted 2016-07-11T00:25:09.303

Reputation: 55 648

4

Python 2.7, 36 bytes:

print''.join(map(chr,range(32,127)))

Simple enough. A full program that prints out the entire ASCII sequence in order.

R. Kap

Posted 2016-07-11T00:25:09.303

Reputation: 4 730

3

Pyth, 5 bytes

srd\

Try it here.

 r         range from
  d        space
   \<del>  to the delete character, 0x7F (included literally in the program)
s          sum (concatenate all)

Doorknob

Posted 2016-07-11T00:25:09.303

Reputation: 68 138

3

JavaScript, 54 bytes

for(i=32;i<128;i++)console.log(String.fromCharCode(i))

Wasted quite a few bytes printing it... Also prints each char on a new line.

charredgrass

Posted 2016-07-11T00:25:09.303

Reputation: 935

5If you start the loop in 31, you can save one byte removing i++ and using String.fromCharCode(++i). – Washington Guedes – 2016-07-11T12:29:56.463

3

Octave, 13 bytes

disp(' ':'~')

Try it on ideone.

beaker

Posted 2016-07-11T00:25:09.303

Reputation: 2 349

2

Bash, 54 bytes

man ascii|fold -w1|LC_ALL=C sort -u|tr -cd '[:print:]'

Try it online!

I like that this uses the ASCII man page (which contains an ASCII table) to extract the characters.

LambdaBeta

Posted 2016-07-11T00:25:09.303

Reputation: 2 499

2

Canvas, 1 byte

Try it here!


Without builtin:

15 14 bytes

9⁵×4-{⁷⁷++╷c]∑

Try it here!

hakr14

Posted 2016-07-11T00:25:09.303

Reputation: 1 295

:| that's really long without builtin – ASCII-only – 2018-04-27T01:35:17.283

@ASCII-only yeah. ⁴⁷⁷++╷ is the shortest way i could find to make the number 95 (Canvas only has literals for 0-9, and predefined variables for 10, Infinity, 256, 13, 64, 11, 12, 16, and 128.) – hakr14 – 2018-04-27T01:37:56.650

lol nvm found a shorter one – hakr14 – 2018-04-27T01:42:02.617

210 bytes – ASCII-only – 2018-04-27T13:08:44.953

2

Java 8, 48 bytes

v->{for(char i=31;++i<127;)System.out.print(i);}

Try it online.

Explanation:

v->{                       // Method with empty unused parameter and no return-type
  for(char i=31;++i<127;)  //  Loop characters from ' ' to '~'
    System.out.print(i);}  //   And print it

Kevin Cruijssen

Posted 2016-07-11T00:25:09.303

Reputation: 67 575

2

CJam, 6 bytes

',32>

The second byte is a DEL character. Try it online!

Dennis

Posted 2016-07-11T00:25:09.303

Reputation: 196 637

2

Perl 6, 17 bytes

print |(' '..'~')
print chrs ^95+32

Brad Gilbert b2gills

Posted 2016-07-11T00:25:09.303

Reputation: 12 713

2

C, 40 bytes

f(){for(char i=32;i<128;i++)putchar(i);}

dkudriavtsev

Posted 2016-07-11T00:25:09.303

Reputation: 5 781

New here, but do you have to declare a func? (without the f(){ is not ok?) – Ring Ø – 2018-12-27T07:25:28.623

1@RingØ In C, you can't just write code without a function. each submission has to compile or run, so in JS for example it would be ok to not put the f() but it's required for C. – dkudriavtsev – 2018-12-27T09:18:54.333

2

Brachylog, 3 bytes

@Pw

@P is the string that contains the printable ASCII characters so… yeah, not very interesting.

It's not clear whether OP accepts built-ins or not, and since others have posted answers that use built-ins, I'll use the 3 bytes version until OP clarifies this point.

With no built-in, 14 bytes

32:126e          Get a number between 32 and 126
       :"~c"w    Format that number to STDOUT as a char code
             \   Backtrack

Fatalize

Posted 2016-07-11T00:25:09.303

Reputation: 32 976

2

TSQL, 53 bytes - Vertical solution

DECLARE @ int=32x:PRINT char(@)SET @+=1IF @<127GOTO x

Fiddle

TSQL, 75 71 68 bytes - Horizontal solution

DECLARE @ char(95)=''WHILE 95>LEN(@)SET @=char(126-LEN(@))+@ PRINT @

Fiddle

t-clausen.dk

Posted 2016-07-11T00:25:09.303

Reputation: 2 874

this can be executed on any version of sqlserver from this millennium – t-clausen.dk – 2016-07-11T08:11:34.410

1Horisontal=>Horizontal ;) – aloisdg moving to codidact.com – 2016-07-11T11:40:24.477

1The second solution appears to be missing the leading space. You can save 3 bytes by changing SELECT to SET. – BradC – 2018-04-30T15:51:28.693

@BradC you are absolutely right, thanks. Fixed - considering my more complex answers, I can't believe i missed something this obvious. – t-clausen.dk – 2018-05-01T07:39:05.357

Vertical solution isn't valid – ASCII-only – 2018-05-01T07:43:00.627

@ASCII-only does it give incorrect result ? It executes fine in the fiddle – t-clausen.dk – 2018-05-01T07:58:08.867

@t-clausen.dk Yeah, but IMO the newlines count as "other characters" – ASCII-only – 2018-05-01T08:07:14.257

@ASCII-only I agree. It could very well be interpreted that way, which is why I provided both answers – t-clausen.dk – 2018-05-01T08:15:11.593

Here's a varchar version that fixes the leading space, also builds from the left instead of the right: DECLARE @ varchar(94)=' 'WHILE 94>LEN(@)SET @+=char(LEN(@)+33)PRINT @ – BradC – 2018-05-01T13:26:04.910

@BradC I tried with the varchar first. But saved 1 bytes building it from the right – t-clausen.dk – 2018-05-01T13:32:30.767

1@t-clausen.dk But I still don't get a leading space from your latest code, looks like all you did was change the SELECT to SET. If you change both 94s to 95 that seems to fix it. – BradC – 2018-05-01T13:38:28.600

2

Ruby, 17 bytes

$><<[*' '..?~]*''

or

print *[*' '..?~]

daniero

Posted 2016-07-11T00:25:09.303

Reputation: 17 193

1

Retina, 12 bytes

The is the Unit Separator character \x1F (31)



+;T`p`p_

Try it online!


Retina 0.8.2, 18 bytes

Same method as above, but requires some extra bytes for printing and not having a trailing newline.



+*\T`p`p_
\`.

Try it online!


If, like in Martin's answer, a trailing newline is acceptable, then this is possible, beating him by 5 bytes:

Retina 0.8.2, 13 bytes



+*\T`p`p_

Try it online!

mbomb007

Posted 2016-07-11T00:25:09.303

Reputation: 21 944

1

Gol><>, 9 bytes

`_FLss|rH

Try it online!

How it works

`_FLss|rH

`_F...|    Run the following 95 times:
   Lss       Push the loop counter + 32
       rH  Print all the chars in the pushed order and halt

Bubbler

Posted 2016-07-11T00:25:09.303

Reputation: 16 616

1

F# (.NET Core), 30 bytes

Seq.iter(printf"%c")[' '..'~']

Try it online!

snail_

Posted 2016-07-11T00:25:09.303

Reputation: 1 982

1

Tcl, 55 bytes

set i 31
time {puts -nonewline [format %c [incr i]]} 95

Try it online!

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

Common Lisp, 41 bytes

(dotimes(i 95)(princ(code-char(+ i 32))))

Try it online!

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

Charcoal, 1 byte

γ

Try it online!

No builtin, 7 bytes:

⪫…· ¦~ω

Try it online!

Explanation

⪫     ω  Join by empty string
 …· ¦~    Inclusive range from " " to "~"

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

Add++, 12 bytes

L^,126 32rBF

Try it online!

Explanation

L^,          Lambda returning stack cast to string (takes character code of numbers)
   126 32r   Inclusive range from 32 to 126
          BF Flatten stack

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

><>, 21 19 bytes

48*v
)?;>:o1+:763**

Try it online!

Explanation

48*v               Push 32 and move down
                   Print character, increment, stop if greater than 126
)?;>:o1+:763**

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

05AB1E, 2 bytes

žQ

Try it online!

No builtin, 8 bytes:

95Ý32+çJ

Try it online!

Explanation

95Ý       Push [0..95]
   32+    Add 32 (vectorizes)
      ç   chr (vectorizes)
       J  Join by empty string

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

1

Japt -P, 5 bytes

#_odH

Test it


Explanation

#_        :95
  o       :Range [0,95)
    H     :Add 32 to each
   d      :Get the characters at those codepoints

Shaggy

Posted 2016-07-11T00:25:09.303

Reputation: 24 623

1

Ruby, 14 bytes

print *?\s..?~

Try it online!

Kirill L.

Posted 2016-07-11T00:25:09.303

Reputation: 6 693

1

Chip -w -gii -c127, 19 bytes

aABbcC,~S
dDEefF^Gg

Try it online!

Flags:

  • -w Don't attempt to read stdin
  • -gii Generate incrementing bytes for input
  • -c127 Cut off execution at 127 cycles

Code:

This is a cat program suitable for ASCII (only handles 7 bits):

aABbcC
dDEefF Gg

And this suppresses output for values outside the range 0x20-0x7f. (More accurately, it requires that at least one of the bits 0x20 or 0x40 to be true):

      ,~S
     F^G

Phlarx

Posted 2016-07-11T00:25:09.303

Reputation: 1 366

1

Whitespace, 52 bytes

[S S S T    S S S S S N
_Push_32][N
S S N
_Create_Label_LOOP][S N
S _Duplicate][T N
S S _Print_as_character][S S S T    N
_Push_1][T  S S S _Add][S N
S _Duplicate][S S S T   T   T   T   T   T   T   N
_Push_127][T    S S T   _Subtract][N
T   T   N
_If_negative_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs, and new-lines).
Program stops with error: No exit defined.

Pseudo-code:

Integer c = 32
Start LOOP:
  Print c as character
  c = c + 1
  If c - 127 is negative:
    Go to next iteration of LOOP

Kevin Cruijssen

Posted 2016-07-11T00:25:09.303

Reputation: 67 575

1

Forth (gforth), 27 bytes

: f 127 32 do i emit loop ;

Try it online!

Explanation

127 32 do  \ loop from 32 to 126 (127 is not printable)
  i emit   \ get the index of the loop, then print it as its ascii representation
loop       \ end the loop       

reffu

Posted 2016-07-11T00:25:09.303

Reputation: 1 361

1

PowerShell 5.1, 22 Bytes

-join[char[]](32..126)

Or 17 bytes if newlines are allowed and we can ditch the join.

Veskah

Posted 2016-07-11T00:25:09.303

Reputation: 3 580

1

Elixir, 24 bytes

IO.puts Enum.uniq 32..?~

Try it online!

Prints a trailing newline. If that's not acceptable, it's +1 byte for write instead of puts.

uniq is the cheapest operation I managed to find for converting range to list. As a bonus, here are 4 different programs that all accomplish the task in 27 bytes:

IO.puts Enum.to_list 32..?~
IO.puts Enum.into 32..?~,[]
IO.puts Enum.take 32..?~,95
IO.puts for n<-32..?~,do: n

Kirill L.

Posted 2016-07-11T00:25:09.303

Reputation: 6 693

1

Bash + general Linux utilities, 18

jot -s '' -c 95 32

Digital Trauma

Posted 2016-07-11T00:25:09.303

Reputation: 64 644

1

SQL, 76 75 bytes

(Microsoft SQL Server 2012+)

declare @ int=32;while(@<127)begin;print char(@);set @+=1;end

Demo

Phrancis

Posted 2016-07-11T00:25:09.303

Reputation: 165

Not sure outputting on separate lines satisfies the challenge. Also, can save a few bytes with a label/and GOTO instead of while. – BradC – 2018-04-30T14:29:36.623

1

PHP, 40 30 29 26 24 bytes

Thanks to Mego, manatwork and Titus for helping me golf this down.

<?=join(range(' ','~'));

Quill

Posted 2016-07-11T00:25:09.303

Reputation: 576

I think #128 is out of printable ASCII. Anyway, range() can generate character sequence directly, no need to chr() them one by one.

– manatwork – 2016-07-11T07:59:58.730

range is inclusive (unlike Python's range, which includes the start but not the end), so it should be range(32,127). – Mego – 2016-07-11T08:06:42.560

join()'s first parameter “Defaults to an empty string.” Then you have an unnecessary space after the second ,. – manatwork – 2016-07-11T08:48:15.467

Yepp, my explanation officially sucks. :( To translate my previous comment: join()'s first parameter is optional. – manatwork – 2016-07-11T09:33:09.140

I'm pretty sure you can replace echo with <?= and then save a byte. – None – 2016-07-11T12:12:04.617

@Midnightas: 2 bytes. also drop the blank behind the echo – Titus – 2016-07-12T10:55:25.907

1

Julia, 18 bytes

map(print,' ':'~')

Try it online!

If returning a string from a function is acceptable, a further byte can be saved.

f()=' ':'~'|>join

Dennis

Posted 2016-07-11T00:25:09.303

Reputation: 196 637

1

Haskell, 16 bytes

putStr[' '..'~']

Damien

Posted 2016-07-11T00:25:09.303

Reputation: 2 407

1

C#, 51 45 40 bytes

for(char x=' ';x<=128;)Debug.Write(x++);

wonea

Posted 2016-07-11T00:25:09.303

Reputation: 119

1I think that this doesn't qualify just yet, since it isn't a full program or a function. Also, why do you cast the x to a char when giving x a value? – Yytsi – 2016-07-11T08:23:14.647

1Yeah, but there is 2 casts in your code...? – Yytsi – 2016-07-11T08:41:17.913

1You can rewrite your for to be shorter ()=>{for(int x=31;x<126;)Debug.Write((char)++x);}; (I also use a lambda to be pendatic with PPCG will. Here we use an Action instead of a Func) – aloisdg moving to codidact.com – 2016-07-11T11:32:27.267

You can remove your cast by incrementing your char. ()=>for(char x=' ';x<127;)Debug.Write(x++);}; – aloisdg moving to codidact.com – 2016-07-11T11:39:28.677

Also nice first answer! Feel free to step by the Tips for code-golfing in C# page for more tips! I just referenced this post in it ;)

– aloisdg moving to codidact.com – 2016-07-11T11:58:39.257

1

Pyke, 5 bytes

~KS4>

Try it here!

Pyke's printable variable isn't sorted and it contains tabs and newlines etc... :(

Blue

Posted 2016-07-11T00:25:09.303

Reputation: 26 661

1

C - 35 bytes

f(i){for(i=31;++i<128;putchar(i));}

Call:

int main() {
    f();
}

Uses the horrible int-as-a-string trick I learnt from Lynn. (Will again if OP confirms that a vertical output is OK).

Quentin

Posted 2016-07-11T00:25:09.303

Reputation: 1 187

That only works on little-endian machines though. putchar(i) is the same length. – owacoder – 2016-07-11T11:50:50.770

@owacoder mmh, I had puts there originally, but then I changed it because of the newlines and didn't question it further. Thanks! – Quentin – 2016-07-11T11:55:22.577

i;f(){for(;++i<96;putchar(i+32));} also works, and saves a byte. – owacoder – 2016-07-11T11:57:26.067

1

Mathematica, 22 bytes

32~CharacterRange~126&

Pretty simple. & creates an anonymous function and 32~CharacterRange~126 outputs a list of characters from 32 () to 126 (~). Actually, I'm pretty sure this is optimal this time.

LegionMammal978

Posted 2016-07-11T00:25:09.303

Reputation: 15 731

1

Excel VBA, 57 bytes:

Prints individual characters

Sub a()
For i = 32 To 126
Debug.Print Chr(i)
Next
End Sub

Prints out joined string, 68 bytes

Sub a()
For i = 32 To 126
b = b & Chr(i)
Next
Debug.Print b
End Sub

tjb1

Posted 2016-07-11T00:25:09.303

Reputation: 561

27 bytes in VBA Immediate Window: For i=32To 126:?Chr(i):Next or, for all one string with no line breaks, 28 bytes: For i=32To 126:?Chr(i);:Next – Engineer Toast – 2018-04-30T13:29:42.843

1

Majc (formely hashmap), 6 bytes

r af

The delete character is unprintable so here's the hex code (xxd):

0000000: 7220 7f61 660a                           r .af.

user47018

Posted 2016-07-11T00:25:09.303

Reputation:

1

C, 33 bytes

i;f(){++i<96&&putchar(i+31)|f();}

Jasmes

Posted 2016-07-11T00:25:09.303

Reputation: 131

0

Perl 5, 21 bytes

print map{chr}32..127

Try it online!

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

2sable, 8 bytes

95Ý32+çJ

Try it online!

Same as for 05AB1E

Explanation

95Ý       Push [0..95]
   32+    Add 32 (vectorizes)
      ç   chr (vectorizes)
       J  Join by empty string

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

3var, 20 bytes

iiss+<+<>+<+<kkF[Pi]

Try it online!

Explanation

iiss                 Increment A twice, square A twice (set a to 16)
    +                Add A to B (set R to 16)
     <               Set B to R
      +<>            Add A and B (16 + 16 = 32), store to A and B
         +<+<        Add 32 to B twice more (B = 96)
             kk      Decrement B twice (B = 94)
               F[  ] Do B times
                 Pi  Print A as character and increment A

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

Actually, 12 bytes

:95r:32+♂┌εj

Try it online!

Explanation

:95r          Push [0 .. 95]
    :32+      Add 32
        ♂┌    Map chr over TOS
          εj  Join by empty string

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

VBA (Excel), 28 bytes

using immediate window.

for i=32to 126:?chr(i);:next

remoel

Posted 2016-07-11T00:25:09.303

Reputation: 511

0

Prolog (SWI), 80 68 67 62 45 bytes

?-between(32,126,I),writef('%n',[I]),1=0;1=1.

Try it online!

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

Swift 4, 57 bytes

for i in 32...126{print(UnicodeScalar(i)!,terminator:"")}

Try it online!

ASCII-only

Posted 2016-07-11T00:25:09.303

Reputation: 4 687

0

Stax, 2 bytes

Vp

Run and debug it

wastl

Posted 2016-07-11T00:25:09.303

Reputation: 3 089

0

Jelly, 2 bytes

ØṖ

Try it online!

Yep, it's included, but here's an answer without the builtin:

Jelly, 7 bytes

95Ḷ+32Ọ

Try it online!

95Ḷ        create lowered range, from 0 to 94 inclusive
   +32     add 32 to every element in the range
      Ọ    cast the entire list to characters and implicitly print

Harry

Posted 2016-07-11T00:25:09.303

Reputation: 1 189

0

Yabasic/VBA, 29 bytes

An anonymous function that takes no input and outputs to the console.

Note that the VBA answer could be 1 byte shorter by using Chr instead of Chr$.

For i=32To 126:?Chr$(i);:Next

Yabasic: Try it online!

VBA:      There is no TIO for VBA :(

Taylor Scott

Posted 2016-07-11T00:25:09.303

Reputation: 6 709

0

JavaScript (Node.js), 47 bytes

for(i=31;++i<127;)alert(String.fromCharCode(i))

Try it online!

Muhammad Salman

Posted 2016-07-11T00:25:09.303

Reputation: 2 361

0

Befunge-93, 18 bytes

 g:"~"`#@_:,1+00p#

You can try it here. The leading space is important!

                     The current character to be printed/checked, starts loop with a space
  g                  Push character from (0|0) onto stack(using the implicit 0s on the empty stack)
   :"~"`#@_          Check whether the char on (0|0) is over ~, if yes then end
           :,1+00p   Duplicate current char for output and incrementation
                  #  Since the code is a torus, it would continue at (0|0) so we skip it, since it could break the code.

Gegell

Posted 2016-07-11T00:25:09.303

Reputation: 81

0

Dyalog APL, 11 bytes

⎕UCS 31+⍳99

⍳99 integers 1 through 99

31+ add 31 to them

⎕UCS pick those from the Unicode Character Set

Adám

Posted 2016-07-11T00:25:09.303

Reputation: 37 779

0

Scala, 25 bytes

()=>' 'to'~'foreach print

Anonymous function with no args which prints given range

See it online: https://ideone.com/fX2rwf

cliffroot

Posted 2016-07-11T00:25:09.303

Reputation: 1 080

0

Lua - 41 bytes

for i=32,127 do io.write(("").char(i))end

brianush1

Posted 2016-07-11T00:25:09.303

Reputation: 300

You also have to print #127. Not collecting everything in a variable seems to be shorter: for i=32,127 do io.write(("").char(i))end – manatwork – 2016-07-11T08:51:16.750