exercism | My solutions for Exercism exercises
kandi X-RAY | exercism Summary
kandi X-RAY | exercism Summary
A repository for exercises I've completed on Exercism.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of exercism
exercism Key Features
exercism Examples and Code Snippets
Community Discussions
Trending Discussions on exercism
QUESTION
This is my code for space-age problem in exercism. After writing this code in ubuntu terminal, I was facing difficulty in running the code due to some error in main block. Help me run this code.
...ANSWER
Answered 2021-Apr-16 at 11:54ageOn
takes two arguments, so you need something like this:
QUESTION
I’m new to Go and to practice I do some coding exercice on Exercism. I stubbled on a particular exercice in which I’m having a hard time undestanding the solution. Here’s the code:
...ANSWER
Answered 2021-Mar-12 at 17:16The Keep
method takes a function as a parameter. It expects it to be func (int) bool
- a function taking an int
and returning a bool
.
When Keep
is invoked in Discard
, the code passes it an anonymous function with the right signature (take int
, return bool
). This anonymous function invokes strainer
(which is a function passed into Discard
) and returns its response, negated.
The idea is that strainer
is a filter function: it tells you which elements to keep. So the implementation of Keep
is straightforward: iterate over all elements, and keep only those for which strainer
returns true.
Discard
is written in a clever way using Keep
, instead of also writing a loop like this:
QUESTION
First of all, I am a Python newbie.
Second, this is actually an Exercism exercise.
Thirdly, I am totally new to matrixes, but I have learnt quite a lot in the last two weeks.
Fourthly, I am totally new to the concept of Classes, still trying to wrap my mind around those. But that is not in issue here.
Finally, I stumbled upon the following question, and the answer stupifies me.
Where I need clarification
- What is [index-1] doing in the answer?
What I have done so far
I have gone through lots of tutorials on arrays and matrixs in python but I haven't found one that helped me understand how [index-1] in this answer works. I do understand the concept of 2D arrays and matrixs in Python though.
The Question
Given a string representing a matrix of numbers, return the rows and columns of that matrix.
So given a string with embedded newlines like:
...ANSWER
Answered 2021-Feb-28 at 18:20Lists (or arrays as they're often called in other languages) in programming start from index 0. If I have a list of elements say [a, b, c ,d ,e]
, then index 0
would correspond to character a
. Index 1
to character b
and so on.
The index in a matrix (in this case) starts counting from 1
. Thus, when you say: "I want the element from index 1
", the computer would throw you the second element. To compensate for this, we subtract 1
. That way, when you ask for the element at index 1
, the computer will actually read the value at index 1-1
, so 0
.
QUESTION
I'm currently learning Haskell and am working on the Nucleotide Count problem on https://exercism.io/. The problem:
Given a string representing a DNA sequence, count how many of each nucleotide is present. If the string contains characters that aren't A, C, G, or T then it is invalid and you should signal an error.
The compiler is giving me the following errors:
...ANSWER
Answered 2021-Feb-28 at 03:12You just got your wrapping and unwrapping swapped.
QUESTION
I'm new to Java and training with exercism.io
I don't really know why I get an error (not a statement here). Can you explain why I get this?
...ANSWER
Answered 2021-Jan-22 at 06:48This is an expression:
QUESTION
I am solving a problem for the website Exercism in rust, where I basically try to concurrently count how many times different letters occur in some text. I am doing this by passing hashmaps between threads, and somehow am in some kind of infinite loop. I think the issue is in my handling of the receiver, but I really don't know. Please help.
...ANSWER
Answered 2021-Jan-10 at 01:48Iterating on the receiver rx
will block for new messages while senders exist. The ones you've cloned into the threads will drop out of scope when they're done, but you have the original sender tx
still in scope.
You can force tx
out of scope by dropping it manually:
QUESTION
For the Nth Prime Rust exercise on exercism.io, I found that some solutions choose to filter()
over a range with no upper limit.
Here's an example:
...ANSWER
Answered 2020-Dec-26 at 20:01This is due to the use of Iterator::nth
. This method will call the next
method on the iterator exactly n
times, then stop.
QUESTION
I am new to Elixir
and trying out this exercism. Below are my code:
ANSWER
Answered 2020-Nov-23 at 09:46It's not possible to view your link without creating an account, so I'm not sure what the problem is, but Enum.each/2
is designed to perform side effects, such as printing the values, so you don't normally care about the return value. For converting the values, you generally want Enum.map/2
. For example:
QUESTION
Here is an example function with the pattern I am referring to:
...ANSWER
Answered 2020-Dec-11 at 07:27Iterating until success is like .find()
but if you're only interested in a true
/false
result you can use .any()
, which does exactly what you're asking for.
Tests if any element of the iterator matches a predicate.
any()
takes a closure that returnstrue
orfalse
. It applies this closure to each element of the iterator, and if any of them returntrue
, then so doesany()
. If they all returnfalse
, it returnsfalse
.
any()
is short-circuiting; in other words, it will stop processing as soon as it finds atrue
, given that no matter what else happens, the result will also betrue
.An empty iterator returns false.
So your loop can be written like this:
QUESTION
I'm doing the Delphi track at exercism, and following how Delphi generates code for a form, answered one of the basic questions like this:
...ANSWER
Answered 2020-Dec-02 at 18:16I've never explicitly created the instance of the class, but it seems as if Delphi is doing it somewhere, maybe when declaring TYear?
No, Delphi is NOT automatically creating an instance of you. When you declare a variable of a class type, it is simply a pointer variable that can be made to point at a valid instance. But you must always create this instance yourself, and save the pointer in the variable:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install exercism
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page