Timeline for Random Golf of the Day #1: Shuffle an Array
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 10, 2015 at 22:18 | history | edited | pseudonym117 | CC BY-SA 3.0 | removed 1 byte thanks to anatolyg |
| Feb 10, 2015 at 22:12 | comment | added | anatolyg | You can remove 1 byte by transforming for(;m;a,b,c); into for(;m;c)a,b; | |
| Feb 5, 2015 at 17:25 | comment | added | pseudonym117 | its probably compiling it as c++ code, which is stricter than c. compile it from a VS developer command prompt using cl. also be sure the file is .c, not .cpp | |
| Feb 5, 2015 at 17:15 | comment | added | bacchusbeale | I copied into VS2013 and turned off warnings...still there are 12 errors. No variable declarations and variables before '{' etc. | |
| Feb 5, 2015 at 16:13 | history | edited | pseudonym117 | CC BY-SA 3.0 | golfed further, thanks to Runer112 |
| Feb 4, 2015 at 18:17 | comment | added | Runer112 | This is pretty impressively golfed. After trying a lot of modifications that didn't save anything, I did manage to see a way to save 2 characters. If you change the swap order so that the first swap statement becomes t=a[i], you can then move the i=rand()%m-- statement inside as the array index. | |
| Feb 3, 2015 at 22:43 | comment | added | pseudonym117 | I was just trying to figure out why that wasn't working... should have remembered that. Also I do need s(a,m)int*a for visual studio and the intel compiler. Don't have gcc or clang installed to test, but I assume they will also complain. | |
| Feb 3, 2015 at 22:40 | comment | added | FUZxxl | @Geobits indeed. I missed that possibility. | |
| Feb 3, 2015 at 22:38 | comment | added | Geobits | @FUZxxl I believe an xor swap causes problems if i==m. | |
| Feb 3, 2015 at 22:03 | comment | added | FUZxxl | I think it suffices to make the function header s(a,m)*a{, but I'm not sure and don't want to test either. You might want to do a xor-swap, like in a[i]^=a[m]^=a[i]^=a[m]. This also avoids the need to declare t. | |
| Feb 3, 2015 at 21:54 | history | edited | pseudonym117 | CC BY-SA 3.0 | added nice formatted version |
| Feb 3, 2015 at 21:10 | history | edited | pseudonym117 | CC BY-SA 3.0 | formatting |
| Feb 3, 2015 at 21:03 | history | answered | pseudonym117 | CC BY-SA 3.0 |