digitalmars.D - Advent of Code
- Regan Heath (7/7) Dec 01 2015 Hi all,
- =?UTF-8?Q?Ali_=c3=87ehreli?= (5/12) Dec 01 2015 My visit was short due to this:
- Charles (10/14) Dec 01 2015 I was the same way earlier, but reddit doesn't need personal
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/14) Dec 01 2015 I over-reacted. In fact, I have accounts on three of those, except
- drug (4/21) Dec 01 2015 If you copy the input with spaces (like I did) the code above gives
- Adrian Matoga (5/10) Dec 02 2015 Speak D to me, please.
- Sean Campbell (5/18) Dec 08 2015 how is this D speek. it's far shorter and easier to read if you
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (12/15) Dec 09 2015 Yes, I don't find chaining of methods all that easy to read
- w0rp (6/6) Dec 08 2015 Thanks for suggesting this. This is fun! Although, I've taken on
Hi all, Long time since I read/posted here but I saw this and thought it might be good PR for D: http://adventofcode.com/ Should also be fun. Ciao, Regan
Dec 01 2015
On 12/01/2015 08:08 AM, Regan Heath wrote:Hi all, Long time since I read/posted here but I saw this and thought it might be good PR for D: http://adventofcode.com/ Should also be fun. Ciao, ReganMy visit was short due to this: To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit] Ali
Dec 01 2015
On Tuesday, 1 December 2015 at 22:57:38 UTC, Ali Çehreli wrote:My visit was short due to this: To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit] AliI was the same way earlier, but reddit doesn't need personal information, so you can just make a throwaway account. Did the first question and it was painfully simple. !!!! SPOILERS (stop reading here if you want to do it) !!! auto input = "arbitrarily long string of '(' and ')'"; int floor; foreach(movement; input) floor += (movement == '(' ? 1 : -1); writeln(floor);
Dec 01 2015
On 12/01/2015 07:50 PM, Charles wrote:On Tuesday, 1 December 2015 at 22:57:38 UTC, Ali Çehreli wrote:I over-reacted. In fact, I have accounts on three of those, except twitter. Oh well... AliMy visit was short due to this: To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit] AliI was the same way earlier, but reddit doesn't need personal information, so you can just make a throwaway account.
Dec 01 2015
On 02.12.2015 06:50, Charles wrote:On Tuesday, 1 December 2015 at 22:57:38 UTC, Ali Çehreli wrote:If you copy the input with spaces (like I did) the code above gives wrong result because the requirement is the input should contain only "(" and ")".My visit was short due to this: To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit] AliI was the same way earlier, but reddit doesn't need personal information, so you can just make a throwaway account. Did the first question and it was painfully simple. !!!! SPOILERS (stop reading here if you want to do it) !!! auto input = "arbitrarily long string of '(' and ')'"; int floor; foreach(movement; input) floor += (movement == '(' ? 1 : -1); writeln(floor);
Dec 01 2015
On Wednesday, 2 December 2015 at 03:50:20 UTC, Charles wrote: (..)auto input = "arbitrarily long string of '(' and ')'"; int floor; foreach(movement; input) floor += (movement == '(' ? 1 : -1); writeln(floor);Speak D to me, please. stdin.byLine.front.map!(a => a.predSwitch('(', 1, ')', -1, 0)).sum.writeln;
Dec 02 2015
On Wednesday, 2 December 2015 at 08:45:11 UTC, Adrian Matoga wrote:On Wednesday, 2 December 2015 at 03:50:20 UTC, Charles wrote: (..)how is this D speek. it's far shorter and easier to read if you use writefln("floor %s",input.count('(') - input.count(')'));auto input = "arbitrarily long string of '(' and ')'"; int floor; foreach(movement; input) floor += (movement == '(' ? 1 : -1); writeln(floor);Speak D to me, please. stdin.byLine.front.map!(a => a.predSwitch('(', 1, ')', -1, 0)).sum.writeln;
Dec 08 2015
On Wednesday, 9 December 2015 at 02:48:31 UTC, Sean Campbell wrote:how is this D speek. it's far shorter and easier to read if you use writefln("floor %s",input.count('(') - input.count(')'));Yes, I don't find chaining of methods all that easy to read either, but you can do less work by taking advantage of D already knowing the length of the input: import std.stdio; import std.algorithm; void main(){ immutable input = "(((())"; immutable long len = input.length - 2*input.count(')'); writeln(len); }
Dec 09 2015
Thanks for suggesting this. This is fun! Although, I've taken on quite a different challenge myself. I'm computing all of the answers only by using my console in Firefox. I'm actually getting through these pretty quickly. (It helps to know some ES5 and ES6.) I can imagine the D code already, and they are actually pretty similar to the JavaScript I've been writing.
Dec 08 2015