Fl4m3Ph03n1x
I am doing some exercises while learning Elixir using Exercism.io.
Now, my objective is to do all exercises, extras included. This should give me a good grasp of the power of the language.
However I am having trouble. I don’t quite understand what some exercises want me to do, but I refuse to skip them either. One of these exercises is the following:
Introduction
There are 10 types of people in the world: Those who understand binary, and those who don’t.
You and your fellow cohort of those in the “know” when it comes to binary decide to come up with a secret “handshake”.
1 = wink 10 = double blink 100 = close your eyes 1000 = jump 10000 = Reverse the order of the operations in the secret handshake.Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
Here’s a couple of examples:
Given the input 3, the function would return the array [“wink”, “double blink”] because 3 is 11 in binary.
Given the input 19, the function would return the array [“double blink”, “wink”] because 19 is 10011 in binary. Notice that the addition of 16 (10000 in binary) has caused the array to be reversed.
use Bitwise (or div/rem)
If you use Bitwise, an easy way to see if a particular bit is set is to compare the binary AND (
&&&) of a set of bits with the particular bit pattern you want to check, and determine if the result is the same as the pattern you’re checking.Example:
Flags: 0b11011 Check: 0b11010
Flags &&& Check: 0b11010 (All checked bits are set)
Another:
Flags: 0b11011 Check: 0b10110
Flags &&& Check: 0b10010 (Third bit not set)
Question
Could someone help me understand why 11 translates to ["wink", "double blink"] instead of translating to ["wink", "wink"] ? ( it has two 1, right ? )
I know I am missing something rather basic but I just can see what.
Trending in Chat/Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 19 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
It’s fully open source.
Check out Exercism · GitHub
kip
This is another one that is quite fun with binary pattern matching
Fl4m3Ph03n1x
So Exercism.io is a community driven effort ( by the Elixir community ? )
If so perhaps I could help as well? There is always strength in numbers.
peerreynders
The way the information is presented in the example makes no sense to me. “Recycling” the bits and pieces that are there leads me to this “best guess”:
NobbZ
Yes, we are on par with that. At least now after the relaunch. But as I said, there is a lot to do after the relaunch to identify exercises that do not suite the new product and community goals anymore. Even more work is to be done to rephrase them or to decide to remove them completely.
I hope I find some time later today, after the kids are in bed, to at least skim some exercises to find some examples of “pesky clients” and then draft a first issue that I can post on github to actually raise the attention of Katrina Owen to the problem and get some discussion around the topic started.
Fl4m3Ph03n1x
I also feel like that, but for the sake of learning the language I try to power through as much as possible.
@NobbZ Wonderful insight, however this is not Exercism.io’s purpose. It’s purpose is not to simulate pesky clients it is to give you objective exercises so you can learn the language.
@peerreynders So, this is confusing to me.
I fail to see how doing
0b11011 &&& 0b10110which results in 18, is supposed to tell me that the 3rd bit is not set and how that affects the exercise.NobbZ
If you are lucky and work for an employer that actually asks back… Congratulations. I’ve seen it differently a lot of times even though, I am in the lucky situation, that I’m developing on a core product that is mostly experimental, and as such requirements are discovered by myself and formalized by the team before they get implemented in future sprints.
peerreynders
Doesn’t even come close:
“We want this.”
“Why do you think you need that?”
… which sooner or later leads to the discovery that the actual problem needs a completely different solution.
NobbZ
Sometimes the assignments are purposely vague, it’s a bit in the spirit of the customer that only ever tells what he really needs a week after the deadline
But yes, I liked this under the old exercism, but the new should clean up with those. This exercises are scary and not in the warm and welcoming spirit the new exercism should have.
peerreynders
Those are the type of constraints that I like to see explicitly stated, otherwise more time is spent on trying to figure out what the intended problem is rather than solving the problem.
(I realize I’m in no position to complain given this is a volunteer effort - I just find the same to apply in other avenues.)