Skip to main content

Timeline for Print the ASCII table

Current License: CC BY-SA 3.0

24 events
when toggle format what by license comment
Jun 17, 2020 at 9:04 history edited CommunityBot
Commonmark migration
Mar 15, 2017 at 12:15 comment added Kevin Cruijssen @JackAmmo You're right that you can change the <= to < by also changing ++i to i++. However, you then also have to change the char i=0; to char i=1;. So this: void f(int n){for(char i=1;i++<n;)System.out.print(i);} (and indeed 55 bytes) Try it here.
S Feb 6, 2016 at 13:44 history suggested Elliot A. CC BY-SA 3.0
fix title of post
Feb 6, 2016 at 13:15 review Suggested edits
S Feb 6, 2016 at 13:44
Jun 30, 2015 at 0:43 comment added Jack Ammo @Loovjo 55 bytes actually if you remove the = and post-increment instead of pre-increment: void f(int n){for(char i=0;i++<n;)System.out.print(i);}
Jun 29, 2015 at 23:01 history edited Rodolfo Dias CC BY-SA 3.0
Golfed code
Jun 23, 2015 at 14:23 comment added xenia 56 bytes: void f(int n){for(char i=0;++i<=n;System.out.print(i));}
Oct 31, 2014 at 17:53 history edited Ingo Bürk CC BY-SA 3.0
added 8 characters in body
Oct 30, 2014 at 6:55 history edited Rodolfo Dias CC BY-SA 3.0
Golfed the code a bit more.
Oct 30, 2014 at 6:53 comment added Ingo Bürk So we come down to void f(int n){int i=0;for(;++i<=n;System.out.print((char)i));} which is 62 bytes. At least I don't see more to golf now. :)
Oct 30, 2014 at 6:49 comment added Rodolfo Dias @IngoBürk Damn it, next time I have to double our triple-read comments before posting. Of course it's the same think... hides
Oct 29, 2014 at 21:01 comment added Ingo Bürk @RodolfoDias Are you sure? Obviously, ++i<n+1 should be equivalent to ++i<=n. Note the = in there, however! It just saves one byte. It works for me.
Oct 29, 2014 at 20:52 comment added Rodolfo Dias @IngoBürk Hmm, if I don't put the i+1, the function prints the n-1 first ASCII charachters. At least, it's what it's happening here :/
Oct 29, 2014 at 20:40 comment added Ingo Bürk @RodolfoDias You can drop the public keyword and honestly, the static as well. It's still a function/method. You can also replace ++i<n+1 with ++i<=n.
Oct 29, 2014 at 20:20 history edited Rodolfo Dias CC BY-SA 3.0
Edited code
Oct 29, 2014 at 20:16 comment added Rodolfo Dias @IngoBürk I'm dumb enough to write the whole thing and not read that I can and cannot do. Oh well...
Oct 29, 2014 at 19:33 comment added Ingo Bürk You are allowed to write a function, so no need for an entire class and everything.
Oct 29, 2014 at 19:11 comment added flawr The challenge allows the use of your a as input. And I think you can shorten the for loop by abusing the increment place as loop body: for(;++i<n;System.out.print((char)i)); (but you might have to change the initialization or end value by +- 1)
Oct 28, 2014 at 19:25 history edited Rodolfo Dias CC BY-SA 3.0
Edited code
Oct 28, 2014 at 19:21 comment added Rodolfo Dias @Shujal I have much to learn yet. Thanks!
Oct 28, 2014 at 16:03 comment added Shujal You can save some chars by declaring the int while opening the scanner: int i,n=new Scanner(... and changing the loop to for(;++i<n;). Also, you don't need to invoke Character.toString. You can just feed System.out a char value and it will happily output it.
Oct 28, 2014 at 15:31 history edited Rodolfo Dias CC BY-SA 3.0
deleted 2 characters in body
Oct 28, 2014 at 15:29 review First posts
Oct 28, 2014 at 16:54
Oct 28, 2014 at 15:26 history answered Rodolfo Dias CC BY-SA 3.0