« first day (1457 days earlier)      last day (1037 days later) » 

2:07 PM
How do I get the following C# code to run successfully on try it online?
The code is an answer to the question: codegolf.stackexchange.com/questions/209666/…
 
@MyWrathAcademia you have to write a full program (i.e. the class, static void Main, reading input & calling the function). (for aesthetics, you can use the header/footer; the code run in the end is just the concatenation of the three); also, unless in is some special thing in C#, your answer must either be a function/lambda taking the input as an argument, or read it from stdin by itself
 
2:22 PM
Thanks @dzaima . I've tried to write a full program tio.run/##XY/BS8MwFIfv/…
But I still can't get the code to run successfully.
I'm not sure what the following means:
> also, unless in is some special thing in C#, your answer must either be a function/lambda taking the input as an argument, or read it from stdin by itself
 
@MyWrathAcademia wrong link?
 
@dzaima Sorry, try this:
 
@MyWrathAcademia ah, in is a keyword. try renaming the variable
@MyWrathAcademia in CGCC, a valid answer must be either a function or a full program. You cannot assume the input will be in a predefined variable.
 
@dzaima Of course, an IDE would have warned me about that.
@dzaima this is what I now get:
 
also args is empty. To read from the input field you must read stdin (or whatever other way you want to construct the string[] with)
 
2:29 PM
I can't paste the url to the latest code because the message is too long.
 
@MyWrathAcademia do shift+enter to enter a newline after it to make it a multiline message, which makes SE allow long links
 
@dzaima Thank you.
Is there an alternative to try it online? This code works on visual studio code.
@dzaima do you have any idea how to get this code to work?
 
i think this should work, but it seems to output nothing:
https://tio.run/##bZFda8IwFIbv@ysOhdEEXXC4i7FOYZMpMmEDhV2UXnT1tA3WxJ1Ei5T@dpd27APxMuc575O8JDXXqZGnvZEqh@XRWNyG3v@TmOiyxNRKrYyYoUKS6dnGQqrPs9H8NfQeu9CDseRAFI8hUzCCkxyNpZiR3u@ejoyVfDSuCe2eFJRiuSulZQEEPBrEYcPFSi@ksYyLqabnJC0Yy9tAdxc7JASmck6FFSwtYbJ9J2mRWC5e8ChWJLesZWmRUBTXQRT0gzhoeM8Xpc59zutMu5TTtqoDSAU5N5XoLK4VsgMPm4afQi9TnemnTO1HFSa2QIphsidCZcH13t3D3XDq9z0/@khog7iLYSpNAY4jGXDDC1DTuoOI39RYnW627YqN4W0OvaG4ub2QKzE54J/090G3g6u2skoRdAaUuFprtO4Pce03PDx9AQ
 
@dzaima The reason the code outputs nothing is that it writes to a file it creates.
@dzaima The files it creates and writes to are on my file system. Is it not possible for code on try it online to write to a file?
 
@MyWrathAcademia it can, but you'd have to print the contents manually if you wanted them to be viewable
 
2:44 PM
Here is the updated code:
 
@MyWrathAcademia wrong link again?
 
@dzaima aah, sorry again. It seems after running the code the url in the address bar does not update. I will use the permalink button from now on:
So where are those files saved so that it can be printed?
 
@MyWrathAcademia they should be just where you wrote them. but Console.WriteLine(File.ReadAllLines("barkeep.log")); doesn't seem to output anything either
i'm stupid, foreach (var c in File.ReadAllLines("barkeep.log")) Console.WriteLine(c); works. i don't know C# much :/
@MyWrathAcademia you do need to use a lambda (as i did - i=>i.GroupBy…) by CGCCs rules
so something like this:
https://tio.run/##bZBPSwMxEMXv/RRDQDahNSh6EGsLKlZED6KCh2UPMZ1ug7tJmaQtsuxnr8la/xR7zLx5vzcv2h9qbzaXOhhnL3wgY8u8GMPMwgg2ZjQ28pbccnH1wXklRuOGMCzJQiWfF5UJPINM5EfFsBXyxT0YH7iQE0c3Ss85L5Nh6SOSrxSBX0emxTU8B0JVv5IJSLyU9/ghX8jUPGl6rigvmizPBlmRtaLPZOVKJkQzc9EVsQm1AmOhFH4tO8qDschXYti2YjPszWxH@i7TsHyNKsyRCrheEqENELBenMPZyYQNeix/U/SOuChgYvwcoo7kIQ73iI6mnYj4pfrg9HudVkIBj3fQP5HHp3t8FaoV/kJ/Djo9OkiVrUZwMyAVa00xoA44Za2IXb5KQ9faqhpT8d1226DumwbA/lz0Pdqmdc9WQNMDuHbWuwr/fF@C99k5i6EAO7E6ZU5M3H5CNb2sqrTvO4MQe0i6Q/yfx3G7@QQ
 
@dzaima No you're not. You just solved a problem in a language you don't really know. I think that's very impressive.
@dzaima This didn't work because you were trying to print an array of strings.
 
(btw, golfed 8 bytes by removing parenthesis, brackets & spaces)
 
2:56 PM
You can print strings without using a foreach loop like so:
 
so everything works now it appears :D
 
@dzaima Wait what?
@dzaima Yes everything works, thanks a lot. Today is my first time doing a challenge on code golf, what are these rules? Are you saying that code gulf will not accept the following solution?
 
@MyWrathAcademia see this - negative score means it's not an accepted method of input by default; compared to this
 
@dzaima . I don't quite understand what "Programs may take input by assuming it is stored in predefined variables." means.
Can you show me where or how my program does this "Programs may take input by assuming it is stored in predefined variables."?
 
@MyWrathAcademia your solution is expecting the input to be stored in the input variable
also, your code is neither a function nor a full program, but a snippet of code, which is also disallowed
 
3:12 PM
I kindof see it now:
  input.GroupBy((l)=>{return l.Split(' ')[0];}).ToList().ForEach((g)=>{using(var sw = new StreamWriter(g.Key.Trim(new char[]{'[',']'})+".log")){foreach(var v in g)sw.WriteLine(v);}});
 
@MyWrathAcademia pad with 4 spaces (or ctrl+k) for monospace - there's no markdown in multiline messages (SE chat is very funky and very neglected)
 
Does expect the input to be stored in the input variable.
Much better, @dzaima thanks
@dzaima your correction is a lambda expression:
i=>i.GroupBy((l)=>{return l.Split(' ')[0];}).ToList().ForEach((g)=>{using(var sw = new StreamWriter(g.Key.Trim(new char[]{'[',']'})+".log")){foreach(var v in g)sw.WriteLine(v);}})
@dzaima So this is acceptable for a code golf answer?
 
@MyWrathAcademia yeah. can't find a conclusive single meta post, but it's the way most python/java answers are done
 
@dzaima Great thanks. I think I'll add both links to my answer. How do I credit you for the code gulf compliant answer?
 
@MyWrathAcademia no need, i don't participate much lately anyways
 
3:24 PM
@dzaima Okay :). It's quite fun, so I think I will get involved in any future code gulf challenges I think I can answer.
So what languages are you familiar with?
 
@MyWrathAcademia Java, JS, ±Python, APL (+ my 2 golflangs) but i've stopped mostly golfing/participating in SE (also TNB is a better place for discussion)
 
@dzaima Nice, I suspected one of your languages might be Java, based on how C# didn't surprise you.
Why +- for Python?
What's golflangs?
And what made you stop code gulfing?
Thanks for the link to that chat room.
 
@MyWrathAcademia 1) don't know it much beyond the basics; 2) golflangs are specialized languages for getting better scores at golfing; 3) mostly this
anyway, have to go now
 
Ok cheers.
cyc
 

« first day (1457 days earlier)      last day (1037 days later) »