Good morning, everyone.
Don’t say I didn’t warn you, we’re moving from letters to numbers with this challenge.
Today’s challenge comes from use...
For further actions, you may consider blocking this person and/or reporting abuse
Here's my attempt:
My attempt with comments:
Here is my attempt, did it in Go: Github
This executable boils down to:
Output:
Also, wooo first post on here 🎉
I'm impressed by how short many of the solutions are.
Clojure:
JavaScript
This is going to be one of those "don't do this at home" types of code (or maybe "do it at home but not at work"). I tried to do it as a single chain of commands, assuming that the string is going to be valid. It can be further cleaned and reduced, I'll try later.
Here is the code commented step-by-step:
You can see it working on this CodePen.
And as an extra, here is a version in which the checks are also sorted:
Here my contribution in javascript:
PHP
It wasn't specified, but I sorted the check order. Also noticed that checks 123 and 129 are repeated two and three times, respectively, while 126, 128, and 131 are missing. I'm guessing the duplicate number were supposed to be the missing numbers. 😄
BASH
Here's my take (JavaScript). A few notes:
I think is the most scalable solution since you first move all the data to a manipulable format, deal with it and then output it.
Ruby
Output :
My JavaScript version:
Output:
Here's my Groovy take on this:
Call is made like the following:
Interesting points that are Groovy-related:
First time seeing these challenges. I don't know If there are any special requirements (e.g.: Should the code be production-ready? Will it be shared in a team? etc.) so I wrote just a simple solution for the task.
A little late to the party, but trying to work on a few skills. I thought I'd attempt to work on using closures a bit on this one:
Go:
Here is my simple solution to parse balanced book string:
JS below :)
Nim
Doing a little catch up on challenges. Here's my solution in Go:
Enjoy the naming scheme :evil-smile:
My solution in Swift :
Java:
Haskell
PHP:
i think it is quite funny how most of the answers here ignore basically half of the requirement and do not print the new balance :)
i think it should be a signal you are ignoring the task and creating something that seems fun for you to solve ( looking at how everyone handles the 'checks numbers' in his own way, even tho it was not a req :) )
just my 2 cents, but always open for a good constructive namecalling kind of talk hihi
//TS
//TDD
My solution :)
Also available in my github repo: github.com/MohamedElidrissi/Daily-...
Walking through the requirements now while I'm on the train so I can get rolling on this tonight!
I see some people are sorting the checkbook before doing the balances by check number.
I am NOT going to do this, because I'm not confident the check number order is necessarily the order the checks were used / were processed by the bank. Therefore I think it might be more correct to keep the ordering of the given list!
Here is my Rust Version!
It's not quite as well factored as I'd like, and it definitely doesn't account for nearly as many edge cases as it should but it works!
Python:
Ruby Language
Normally, I would build out classes for this sort of thing. A Checkbook class with Entries that can be Debit or Credit and so on so that it's easier to write and maintain tests in TDD style. This implementation is just a simplistic top-down functional approach. It's still testable, but it wasn't as easy to compose as an OOP solution would be.
script with specs
output
(There is a small typo, it's BSD-2 license, FreeBSD is the OS ;).
Thanks for spotting it, we'll get it fixed.