Skip to main content
VisualMelon's user avatar
VisualMelon's user avatar
VisualMelon's user avatar
VisualMelon
  • Member for 10 years, 5 months
  • Last seen this week
  • Europe
comment
Brute-force the switchboard
A few suggestions: 1. use ascii-codes, not chars (d=94). 2. Initialise i when you declare it. 3. Use i++<m instead of separate increment (need to modify the contents of the loop in one place, but this adds no cost). 4. Can you get away with (i&1<<j++)>0? 5. I don't think you need the {} for the inner for loop. 6. You can replace a[k]==d||a[k]==u with a[k]>45, I think. 7. Go with j=k=0. All that should remove 19bytes.
awarded
comment
Randomizing until 0
I do apologise... no idea how I missed that, having already looked at half a dozen answers.
comment
Shortest code in your language to persist a string across a reboot
Remove that space after "a",, and I doubt this will be beaten :)
awarded
comment
Simple golfing interpreter
(Oh that is embarrassing... I should have use %50 instead of %'d')
comment
Simple golfing interpreter
You can shave 26bytes off this by doing a few simple things, like declaring i with v, consulting an ASCII table so you can use small numbers, rearranging the ifs, and then using a ternary: class Z{static void Main(string[]a){int v=0,i;foreach(var s in a){i=s[0]%'d';if(i==1)break;if(i>9)System.Console.Write(v);e‌​lse v=i<1?v-1:i<5?v/2:i<6?v+1:v*2;}}} (P.S. an explanation of how it works and how to use it (e.g. expects command line args) is always appreciated!)
awarded
awarded
comment
Tips for code-golfing in C#
Note that this actually calls the static String.Concat(object) with the argument, rather than the virtual calling object.ToString(). Concat explicitly converts null to the empty string (see the reference source). There is no 'native casting' going on, you can convert anything like this, it's just that the result might not be very useful in some cases! (but the null behaviour may well be).
awarded
awarded
comment
Build me a city
Golfing Java and C# (my department) is great fun! Keep at it! Not tested, but I think you can save a few bytes by rejigging the for loops: you can pre-assign i=0, or better, i=l, and count down for(;i-->0;h=d>h?d:h) (and stuff the h= bit in there). The same back-counting will work for the inner loop also. The inner if also has no need for the braces {}. And always be weary of <= or >=, you can turn the ternary around with > and save a byte.
accepted
comment
ASCII Arc Length: How long is a piece of string?
Input and output look fine to me! I'm dreadful at JS, but do you need d? Would (p-v)**2 not work? Unless another surprise answer pops out of the ether, I'll accept this in a couple of days.
comment
Print a Variable's Name
... sorry, didn't realise there wasn't a byte count!
comment
Print a Variable's Name
This is a bit dodgy... because the lambda stuff is absolutely essential (i.e. you can't just pass in the variable, you have to pass something that the compile will recognise should become an Expression). You should also be counting using System.Linq.Expressions;.
comment
Draw ASCII boxes in boxes
Not checked these properly, but: you never use i in isolation, just initialise i=m and compare i<b+m; or... just use i, init i=0 but loop on i<a, then add r[i]=new string('#',a), next to j=0, and add a condition to check i is within bounds for j's loop (this ought to pay off, because you lose all the Linq).
comment
Impatiently wait for input
Can save quite a bit by using the return value from Thread.Join(int), (rid of c, lose braces, etc. etc.): var t=new System.Threading.Thread(()=>System.Console.ReadKey());t.Star‌​t();return(t.Join(10‌​000)?"":"no ")+"input recieved"; (VB.NET already seems to do this)
1
2
3 4 5
20