Tips for Advent of Code day 3 part 1

2021.12.03 20:08 Due_rr Tips for Advent of Code day 3 part 1

To practice my F# skills I want to complete Advent of Code this year. The first two days went OK, but already on day three I'm struggling. Almost wanted to switch back to my trusted Python. My solution for part one can be seen below and the explanation of the assignment can be found here.
There were two main difficulties for me: 1. There is no build-in way to do element wise operations, so I had to write these myself. 2. I had to convert often between string, char, bool and int.
Any tips to improve this code? Did I maybe make it unnecessary difficult?
```fsharp open System.IO open System
let read fname = File.ReadLines fname
let input = read "input.txt" |> Seq.toList
let elementWiseAdd (list1: int list) (list2: int list) = List.zip list1 list2 |> List.map (fun (x, y) -> x + y)
let elementWiseSum (lst: seq>) = let head = lst |> Seq.head

lst |> Seq.fold (fun acc lst -> elementWiseAdd acc lst) [ for _ in 1 .. head.Length -> 0 ] 
let charArrayToInts = List.map (fun x -> int (x) - 48)
let stringToInts = Seq.map Seq.toList >> Seq.map charArrayToInts
let mostCommonDigit (lst: string list) = lst |> stringToInts |> elementWiseSum |> Seq.map (fun x -> x > lst.Length / 2)
let leastCommonDigit = mostCommonDigit >> Seq.map (fun x -> not x)
let boolsToDecimal (boolNumber: seq) = let binaryNumber = boolNumber |> Seq.map Convert.ToInt32 Convert.ToInt32(String.concat "" (binaryNumber |> Seq.map string), 2)
let mostCommonDigitsAsInt = mostCommonDigit >> boolsToDecimal
let leastCommonDigitsAsInt = mostCommonDigit >> Seq.map (fun x -> not x) >> boolsToDecimal ```
submitted by Due_rr to fsharp [link] [comments]


2021.12.03 20:08 swagNextTuber CNN reporter: Is 'Die Hard' really a Christmas movie?

CNN reporter: Is 'Die Hard' really a Christmas movie? submitted by swagNextTuber to TrendingQuickTVnews [link] [comments]


2021.12.03 20:08 noviaccou Brim Financial Referral Code 73573 - $10 Sign up Bonus

Brim Financial Referral Code 73573 - $10 Sign up Bonus submitted by noviaccou to CanadianReferralCodes [link] [comments]


2021.12.03 20:08 Salt-Shop Got crypto? Here are 3 software wallets for storage, staking and swapping

Got crypto? Here are 3 software wallets for storage, staking and swapping submitted by Salt-Shop to SatoshiStreetBets [link] [comments]


2021.12.03 20:08 exitmass Cinnamon stick Redeye with 1,000HP?

Cinnamon stick Redeye with 1,000HP? submitted by exitmass to Challenger [link] [comments]


2021.12.03 20:08 southpawFA Christian adoption agency sues Biden admin to keep kids out of loving gay homes. A Tennessee children's home says its religious freedom is more important than the best interests of the child.

Christian adoption agency sues Biden admin to keep kids out of loving gay homes. A Tennessee children's home says its religious freedom is more important than the best interests of the child. submitted by southpawFA to LAMPNet [link] [comments]


2021.12.03 20:08 Wishbones_007 Reddit be like

Reddit be like submitted by Wishbones_007 to mildlyinfuriating [link] [comments]


2021.12.03 20:08 Maxi_27 I need help for some trade backs to evolve rhydon, dusclops. Will give all iv foreign ditto for helping me complete my pokedex. Thanks

submitted by Maxi_27 to pokemontrades [link] [comments]


2021.12.03 20:08 endauver The boys chilling

The boys chilling submitted by endauver to BorderCollie [link] [comments]


2021.12.03 20:08 98dpb What’s this?

submitted by 98dpb to MarvelLegends [link] [comments]


2021.12.03 20:08 tangerinesubmerine Question about smoking

So im 23 and smoked weed for about 4 years. Im trying to stop but I have such bad anxiety, and I'm not in a location where I can make edibles, but I digress. Given that im only 23, if I'm able to stop smoking, can my voice heal a bit? I'm a male soprano, not sure what my range is precisely, but it hasnt lowered my voice that I've noticed. I can still hit all the high notes. But I've noticed i have to clear my throat more than usual for instance, and I don't like the path this is going down.
submitted by tangerinesubmerine to singing [link] [comments]


2021.12.03 20:08 Azazeel_- The normies will be a pain in the ass

The normies will be a pain in the ass submitted by Azazeel_- to ShitPostCrusaders [link] [comments]


2021.12.03 20:08 birb_dude001 does anyone have any music suggestions?

my playlist is kinda getting bland and im looking for basically anything to keep it spicy, ill leave a link to it so yall know what to suggest
https://open.spotify.com/playlist/3pv4J80MGVZJ9u7FjS9pub?si=QiEWKSZeQHCdOsDF8hU3Kw
-P
submitted by birb_dude001 to Music [link] [comments]


2021.12.03 20:08 walden_gal If I liked the Mandela Catalog, what music should I listen to?

It's a bit of cross-pollination, but I loved the audio in the Mandela Catalog, the lo-fi crackling, the manipulated audio of songs and voices. Does anyone know any music that's similar to this, or just the Mandela Catalog in general? Cheers
submitted by walden_gal to ifyoulikeblank [link] [comments]


2021.12.03 20:08 tonimont876 Private reservist pay

submitted by tonimont876 to USMC [link] [comments]


2021.12.03 20:08 LilyKitty98 [XB1] [PC] [PSN] PVE/PVP Clan recruiting for members

Heatstroke is still recruiting for more guardians! We are an end game content clan (e.g. raids, dungeons, gms, etc). We don't care about experience, we will teach you! You just need to be the right light level (1290+)!
We do not tolerate any bullying/harassment of any kind.
We are 18+ years of age.
If this sounds like the team for you then drop me a message or request to join us!
submitted by LilyKitty98 to DestinyClanFinder [link] [comments]


2021.12.03 20:08 SnooDoubts4128 mosin did it tonight!

submitted by SnooDoubts4128 to MosinNagant [link] [comments]


2021.12.03 20:08 FunComfortable3035 What happened to r/fridaynightfunkinhijinks?

I tried to find it but when I did it said it had been removed? Does anyone know what happened exactly?
submitted by FunComfortable3035 to FridayNightFunkin [link] [comments]


2021.12.03 20:07 ben_kayla Always bored

Always bored submitted by ben_kayla to uncutmanmeat [link] [comments]


2021.12.03 20:07 needsmorepepper Still have a faint pulse.

Still have a faint pulse. submitted by needsmorepepper to wallstreetbets [link] [comments]


2021.12.03 20:07 Sefu417495 Thoughts on 89 ToTGS Marquinhos price ?

I feel like he’s now too expensive right now compared to the RTTK which is almost identical and would be a little better after update
submitted by Sefu417495 to fut [link] [comments]


2021.12.03 20:07 haber-trend Sıcak! | #DeportivoAlaves #LaLiga #GranadaCF #DeportivoAlaves #LaLiga #GranadaCF son saatin en çok aranan 1. trend haberi oldu ve an itibarıyla 2 gazetede yer alıyor.

submitted by haber-trend to HaberTrend [link] [comments]


2021.12.03 20:07 noviaccou Brim Financial Referral Code 73573 - $10 Sign up Bonus

Brim Financial Referral Code 73573 - $10 Sign up Bonus submitted by noviaccou to ReferralWallet [link] [comments]


2021.12.03 20:07 VGMVinylLover I'm Too Lazy to Write An Essay for R/Venals So Rate My Collection

I'm Too Lazy to Write An Essay for Venals So Rate My Collection submitted by VGMVinylLover to vinyljerk [link] [comments]


2021.12.03 20:07 its_all_for_nothing Is is only for gay men?

I’ve never met a straight man (to my knowledge) that has his bellybutton pierced. I think they’re really cool but is it something straight men do too or is it usually just gay men?
submitted by its_all_for_nothing to ask [link] [comments]


http://greenway-kate.ru