4 kyu
The observed PIN
10,464 of 38,754BattleRattle
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
How is
'666'
there but not'333'
? Each digit is counted as its own adjacent digit as well. I'm lost as to what is actually happening. This kata is a mix of finding adjacent digits as well as finding the possible combinations involving each digit but what's expected is highly inconsistent. Idc how many completions it has the expectations are not inline with the task description.How do you get from digit 9 to digit 3? It's not adjacent. Everything seems consistent with description, unless you're misunderstanding it.
and stop raising issues when you do not understand something in a kata; it is rude. an issue implies there is a serious problem with a kata, that other regular users (volunteers) will have to analyze, debug and fix. when you are confused, ask a question.
I'm actually doing my due diligence and learning more about this and practicing a whole lot more. I thought I knew what was going on but I completely misunderstood the entirety of the kata (conceptually). I was so focused on the procedural aspect rather than trying to truly understand it.
I'm actually doing my due diligence and learning more about this and practicing a whole lot more. I thought I knew what was going on but I completely misunderstood the entirety of the kata (conceptually). I was so focused on the procedural aspect rather than trying to truly understand it.
@trashy_incel
bro watch how you talk to people. There are plenty of ways to express yourself particularly when it comes to someone trying to figure things out. If you knew I didn't understand something, rather than telling me about common sense, then you should have at minimun replied with a link to some help. It obviously wasn't "common" to me. Sometimes it's how you express things and not about the assumptions you're making about the programmer. Yes, I raised an issue because I thought there was one but you could have replied with:I did not claim that understanding the task was common sense, everyone can make mistakes. I misunderstand or miss things in descriptions often, too, and only realize it when I submit my code and see that it does not pass the tests.
What I meant by common sense, as I wrote, and as explainedhere, was that when you think you have found a really big mistake, especially in a kata with so many completions (and 38,500 completions is massive), you should stop and think: Did I understand the task correctly ? Am I solving the right problem ? Did I miss something in the description ?
Only after double checking everything, scrolling down the discourse page to see if there have been similar remarks / reports in the past, you should open an issue. Issues should not be opened lightly, as:
I did try to explain the mistake in your logic, too, but you kept focused on your own interpretation of the task instead of on what the description explains.
I appreciate your explanation and I'll do my part in making sure that I fully understand any kata as much as possible. I truly understand the concerns stated above and I honestly should have asked the question rather than raising an issue. I have done some research on this topic to fully understand it and I'm practicing as we speak. It is a challenging kata and appriciate you and the contributors for providing it.
('11', ["11", "22", "44", "12", "21", "14", "41", "24", "42"])
24 is a diagonal and so is 42. 2 and 4 are not adjacent to one another. It defeats the horizontal and verticle rules.
It should be:
('11', ["11", "22", "44", "12", "21", "14", "41"])
You are misunderstanding this sentence:
it means that any
1
could actually be a1
, a4
(bottom vertical from1
), or a2
(right horizontal from1
). So24
is a valid possibility for11
.Please exercise some common sense when raising issues. This kata has nearly 40,000 completions. If there was such a glaring mistake in the tests it would have been already noticed and/or fixed by now.
So, you're saying that any of the numbers adjacent to the initial number is also a possibile combination?
This comment has been hidden.
Thank you
I am passing most of the test until the timeout error. Can Anyonce give me some clue on how to improve the running effeciency?
try backtracking
If you are doing a PIN code duplicate check, you don't need to
Getting this error in the final test: Pin: '47784068' STDERR Max Buffer Size Reached (1.5 MiB)
You're printing too much to the console, remove your prints.
I'm just returning the output, it's the input that is way too high.
Can anyone tell me, please, is the execution time of 1445 ms good for this task or is it still slow?
A note if you're doing this in Java, make sure to return an ArrayList to avoid the UnsupportedOperationException. Great work on the kata!
I am cyberdetective!
This comment has been hidden.
You are missing something, but we cannot tell you what you are missing without seeing your code.
assertion messages for the PHP random tests are completely unhelpful:
Failed asserting that false is true
This comment has been hidden.
Hello, just trying to understand the variations. For this test example: "369": ["339","366","399","658","636","258","268","669","668","266","369","398","256","296","259","368","638","396","238","356","659","639","666","359","336","299","338","696","269","358","656","698","699","298","236","239"], how come 222 and 333 are not variations? Or 555? Or 325? But I see that 666 is there?
See the keypad again, 3 and 5 are adjacent, but diagonally.
I do understand that, but 658 is one of the variations and that has the same pattern as 325. 6 and 8 are adjacent diagonally, but that is a valid solution
From 369 you can reach 658 going always horizontally or vertically: from 3 to 6, 6 to 5 and 9 to 8. From 6, you can only reach 2 diagonally and the same happens when you try to go from 9 to 5. So no, 325 isn't valid. You're confused about what you should do, you start with a number, let's say 369, but you're not sure that's the number the robber entered, the 3 could also be a 2 or a 6, but not a 5, etc. Read the instructions again.
Your response would have been more useful if you spent it on explaining the actual kata instead of just believing this was an opportunity for you to make yourself look superior.
How is "read the instructions again" helpful to anything if I've just posted that they weren't understood the first time?
Sorry you didn't like my response, sometimes reading the instructions again helps, now that I told you why those numbers can't be in the answer, because I did and only then suggested you read the instructions again. Again, you're not understanding what to do, you're looking at 658 as going from 6 to 8 and from 8 to 5 and you analize that pattern, right? And that's not what you should do, you saw 369, but that number can be 658 amongst others as I already explained. If you don't like my answer, just say "I don't get it", there is no shame in that, and I will try to explain it to you in another way, but please, next time, just be humble and read the instructions again now that you got new information and keep an open mind. After all, it's you who didn't get what to do and I am trying to help you.
This comment has been hidden.
JavaScript fork for adding random tests.
Merged.
This kata has been much more fun than I initially thought it would!
I really need to learn how to write more efficiently..
Solutions works, but timeout's for larger 7+ digit inputs.. :(
Shame to the guys who assumed the adjacent relationship instead of infering them from the keyboard. What will happen if the given keyboard's keys change position or the layout is a different one? You will have to redo manually your funny hard coded dictionaries / lists. For this challenge to be real, both inputs must be the observed digits and the layout of the keyboard.
it gives me this error : Test Failed PIN: [8, System.String[]] Expected: equivalent to < "5", "7", "8", "9", "0" > But was: < "5", "7", "9", "0" > Missing (1): < "8" >
CoffeeScript translation
Anyone know why this error?
Test Crashed Caught unexpected signal: SIGSEGV (11). Invalid memory access.
It is C implementation
That generally means you tried accessing something out of bounds.
Where in the instruction says that an observed sequence of '11' could be a result of a real one-digit action in digit '2'?
One of the JS test expects exactly that.
I'm really confused. Any help?
I don't know where you see that, but it's not true. And your current code passes the kata.
12 test cases for javascript? make 300 hundred cases
Gives this error: Traceback (most recent call last): File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper func() File "/workspace/default/tests.py", line 12, in it1 test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'PIN: ' + tup[0]) ^^^^^^^^^^^^^^^^^^^^^^^^
Because you don't return a list, that's a problem with your code, not a kata issue.
Hey all! I made a Julia translation. Would appreciate it if any reviewers who are fellow Julia fans could take a look.
Scala translation
This Kata made me realise how much better I've got at programming these past few months. 4 kyu used to scare me off, but this one took maybe 10 minutes and I immediately went for a depth search algorithm. Nice tidy solution (if I do say so myself) and I only failed test cases once because of a minor typo.
Nice kata!!
It's very strange. But why so few people make a generative mapping from observed to possible digits? May be add a new input arg with PIN-pad mapping to next version of kata. Like get_pins(['012','345','678',' 9 '], '911')...
Hello! I have found bug for java script language: Testing PIN='2' needs array of 4 elements, but for digit 2 we have to get only 3 digit
An array with 4 elements is correct -
['1', '2', '3', '5']
are the possible PINs. Maybe you're not counting'2'
itself?Anyway, not an issue.
For starters, please take another look at digit
2
in your map - it's missing a neighbor.Function 'free_pins' in C implementation requires also an argument 'count' (returned by function 'get_pins'), specifying the number of pin compibations.
It does not, really.
If its you who allocated the result, you have all info needed to deallocate it. You write both functions, you have all control over them. You can write them in a way so they understand each other.
Teaser: its possible to create a solution which performs only a single call to
malloc
, and a single call tofree
.Of course, for this kata you can store the size and use in for freeing. However, in general this is not a good practice, as the module can be called several times and even concurrently. Therefore it appears logical to me that the calling function should handle that.
My work arround was placing NULL pointer at the end, so I loop until NULL is found. It's better than storing size, however I don't really like even that.
Well of course, no arguing here. and thats why a user has to write both functions in a way which would ensure this. And this is possible, and not overly difficult, with the current state. There is no requirement to use global variables, and global variable is a problem which you introduced into your solution. There are other ways to achieve the goal, you found one, theres more, and some might even require no overallocation and a single allocation. Its doable in a standard-compliant, portable way, in more than one way.
Having said that, I discussed your point with other users and it was explained to me that solvers might have difficulties with coming up with some nice allocation scheme and adding the parameter would make it easier for users who want to use the naive(and IMO far from good) solution.
I decided I will change thisI will consider changing this (and some other things, like constness of some values) to make things easier for users who like chopping memory into single transistors :)I willPossibly, I will add the parameter when I get to this kata in the queue of kata to fix :)Why break existing and valid solutions to a 4-kyu kata ? The de-allocation function makes sense as it is and as you said there are several allocation schemes that do not require global variables. And if the users do not come up with one of these, they can still use the global variable technique, the tests suite allows for that. What is the issue to fix here ? If anything, it will make 'naive users' think outside of their preconceptions. This is 4-kyu after all, C users are supposed to be comfortable with memory models at that level. I really do not understand the logic here ...
I also think it's a bit disrespectful to solvers to make a breaking change on a high level kata after this much time has passed since approval of the translation.
If the parameter is added after the pins, like so:
old solutions will still work (as if they ignored the extra argument). This relies on UB and on the calling convention of the underlying architecture, of course.
If you mean the logic behind the decision to change the behavior: mostly it's related to difficulty of collecting feedback and opinions. On one side, I like the current version, and I would like to keep it (duh, I wrote it after all). On the ther hand, users sometimes complain. Granted, not much - it happened like two or three times since the translation got approved. Difficult part (at least to me) is asking for opinons and getting answers: Codewars discourses are not really convenient (or, at least for me they are not, as I prefer direct chats much more). That's why after getting feedback from a single, very experienced user who seconded the confusion of other solvers, I got convinced that the change in interface to add one additional argument would be good. I don't like it, but I might not know everything. Now, you two say that it's good. Considering your opinons, the setup would stay as it is.
The difficult thing with C is that usually it has to be very precise w.r.t. expected allocation schemes. I hoped that the setup used here would allow for greater flexibility and a richer thought process when solving. Nice thing is, many users got it right. Bad thing is, it might be against good language practices. If it is or not, I am not to decide because there are other, smarter, and more experieneced people to know.
About preserving solutions: you are right that a blue kata is usually interesting enough to have solutions preserved, but I think only if it is good in general, and not fundamentally broken. If solutions are based on a fundamentaly invalid premise, and if the idea behind the setup forces users, without a good reason, violate a practie commonly recognized as correct, then I believe quality is more important than solutions. Is it like this in context of this kata? Initially I thought it's a good setup, then I got convinced that it might be plain wrong, now there are your opinions that it's not bad. Damn. Decisions are difficult, and things are never black and white.
I have no good conclusion for now. I like the current setup. You two guys like this setup. Large amount of users who managed to get the allocation correctly seem to support the idea of the setup. Three solvers complained on the setup. One very experienced C user said they don't like it because it's not clear enough and overengineered/confusing/artificial.
I don't have time to review the setup at the moment, so even if I were to change it, it would not be soon. But when I will get to this item in my queue, I will definitely account for all data I have and try to base my decision on this. If I were to do this today, I think I would say "I don't know" and leave things as they have been until today :)
But I think something would need fixing anyway, I am not sure whether the idea of the constness of the buffer is correct.
PS. thanks a lot for your opinions, to me they are very valuable to know whether things need improvement, and how. It would be great if Codewars made getting such opinions easier, in some way. Currently it works quite well in beta kata, but I think not that good for approved kata.
closing, as this would be a
suggestion
anyways, not anissue
. there are ways to properly free all of the memory in a standard-compliant way, and without using global variables.This comment has been hidden.
This comment has been hidden.
Hi, I've got the good answer, but in a different order and it doesn't want to validate....
Random tests don't sort the lists before comparing them, wait a little for it being fixed: https://www.codewars.com/kata/5263c6999e0f40dee200059d/discuss#63f7a0cb755b1a3d6d59d4cb
It should work now, sorry about that.
I'm afraid it does not sort. Instructions say nothing about sorting the result.
This kata is very fun :)
Amazing kata! Although my solution wasn't as smooth as the others, the end result was satisfying.
This comment has been hidden.
I don't how, BUT IT WORKS, i am so happy
This comment has been hidden.
From 956, you could indeed reach 659, but not from 369.
tests/Fixture.cs(41,29): error CS1061: 'IList' does not contain a definition for 'Sort' and no accessible extension method 'Sort' accepting a first argument of type 'IList' could be found (are you missing a using directive or an assembly reference?)
Error in C# attempt tests
This comment has been hidden.
I've got this error for the test, it should be changed :
Traceback (most recent call last): File "/workspace/default/tests.py", line 10, in test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'PIN: ' + tup[0]) TypeError: 'NoneType' object is not iterable
(Edit : changed because the markdown style didn't want to put it in python)
hi,
the tests are not wrong per se. they are just formatted in a way that they iterate through whatever the function returns, hence the
TypeError: 'NoneType' object is not iterable
error. you can work around this by returning any random iterable before you have completed the solution.not a kata issue AFAICT
Моя версия программы дает больше вариантов чем тесты, и поэтому немогу пройти полнкю проверку, вот пример тестов Expected: ["121", "122", "124", "131", "132", "134", "161", "162", "164", "221", "222", "224", "231", "232", "234", "261", "262", "264", "421", "422", "424", "431", "432", "434", "461", "462", "464"], instead got: ["112", "113", "116", "121", "122", "123", "124", "126", "131", "132", "134", "142", "143", "146", "161", "162", "164", "212", "213", "216", "221", "222", "223", "224", "226", "231", "232", "234", "242", "243", "246", "261", "262", "264", "412", "413", "416", "421", "422", "423", "424", "426", "431", "432", "434", "442", "443", "446", "461", "462", "464"]
или ========= Expected: ["101", "102", "104", "181", "182", "184", "201", "202", "204", "281", "282", "284", "401", "402", "404", "481", "482", "484"], instead got: ["101", "102", "104", "110", "118", "120", "128", "140", "148", "181", "182", "184", "201", "202", "204", "210", "218", "220", "228", "240", "248", "281", "282", "284", "401", "402", "404", "410", "418", "420", "428", "440", "448", "481", "482", "484"]
Please write in english, what was the input value?
I don’t know what value it is already a general test, it’s random there, but it’s really a non-mongo kata with a flaw, I just managed to skip the test when a successful random fell out
Your solution is incorrect, it returns wrong values. It's not possible to get
"221"
or"224"
for input"313"
.Your solution has a bug, it's not a kata issue.
but it is not logical if it can be 223 and 226, but for some reason 221 and 224 is not suitable. If we take the moment from the task that all numbers should not be typed diagonally, then a bunch of numbers still fall out, but they nevertheless pass
Why exactly?
If the input is
"313"
, then the observed key3
can be3
, or2
, or6
. It's not possible for the observer to see3
and confuse it with4
, or1
.3
and1
are too far (they are not adjacent)."223"
is OK, because if input is"313"
, then the last3
mathes exactly."226"
is OK too, because3
and6
are adjacent vertically, so the observer can confuse3
with6
.3
and4
are not even on the same line, and are not adjacent diagonally. There is simply no way that"313"
could be confused with"221"
or"224"
, the1
and4
totally do not fit.Why do you think that
"221"
and"224"
would be good answers?I have to agree that these two options are not suitable based on the task at hand. But the problem is darker, if it is excluded from the logic of the task, then it remains in the tests, because my "crooked" code passed the test after 20-30 attempts. I had no intention of bypassing the system, I was just looking for a pattern why it gave an error on several options, and not indiscriminately on all results, and suddenly the system missed
Yes, with this part you are right. Incorrect solution like yours shoould consistently fail and do not pass.
Unfortunately, I do not know Ruby well enough to understand where it is wrong, and what test cases need to be added to tests :(
This one was a time consuming kata.
I'm confused. Why in the second case 11 is one of the valid numbers but 333 isn't a valid number on the third?
As there are different languages available, it's best if you actually type out specifically which test input you are having a question about (for ex the "third" test on Python is with the digit '0' so obviously not the one you are talking about).
Is the test that you are referring to the one with input = '369' ? Then '333' isn't valid because the last '3' in '333' is not adjacent to the '9' in '369'.
I'm based on provided test cases in the Kotlin language. "Is the test that you are referring to the one with input = '369' ? "
That's correct.
"Then '333' isn't valid because the last '3' in '333' is not adjacent to the '9' in '369'."
I don't get it. How so 'last 3' is not adjacent? I believe I missing some concept.
See the keypad image in the description, adjacent to 9, there is only 6 and 8.
it took me around 5-6 hours to complete this kata. i've realized how much i need to improve... but very satisfied
I'm confused on how you get the final answer. Given [5,7,8,9,0] from one of the example tests, how do you get 8? There's certainly more than 8 possible permutations.
If these are the mappings based on digits adjacent neighbors:
1: ['1', '2', '4'],
2: ['1', '2', '5', '3'],
3: ['2', '3', '6'],
4: ['1', '4', '5', '7'],
5: ['2', '4', '5', '8', '6'],
6: ['3', '5', '6', '9'],
7: ['4', '7', '8'],
8: ['5', '7', '8', '0', '9'],
9: ['6', '8', '9'],
0: ['0', '8']
Then you could have the possible permutations:
1.) [5, 4, 8, 9, 0]
2.) [5, 4, 8, 9, 8]
3.) [5, 4, 8, 6, 0]
4.) [5, 4, 8, 6, 8]
5.) [5, 4, 8, 8, 0]
6.) [5, 4, 8, 8, 8]
7.) [5, 4, 5, 9, 0]
8.) [5, 4, 5, 9, 8]
9.) [5, 4, 5, 6, 0]
10.) [5, 4, 5, 6, 8]
etc, etc.
[5, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]
[2, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]
[4, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]
[8, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]
[6, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]
So how does 8 become the final answer?
You misunderstood the input with the output, the input is
"8"
and the ouput is["5", "7", "8", "9", "0"]
facepalm Thank you!
When i try to run tests it goes crazy and gives me an exception:
java.lang.UnsupportedOperationException at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142) at java.base/java.util.ImmutableCollections$AbstractImmutableList.sort(ImmutableCollections.java:261) at TestObservedPin.test(TestObservedPin.java:36) at TestObservedPin.testPins(TestObservedPin.java:31) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42) at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80) at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.codewars.junit5.TestRunner.executeTests(TestRunner.java:64) at com.codewars.junit5.TestRunner.lambda$execute$0(TestRunner.java:56) at com.codewars.junit5.TestRunner.callWithCustomClassLoader(TestRunner.java:147) at com.codewars.junit5.TestRunner.execute(TestRunner.java:56) at com.codewars.junit5.TestRunner.main(TestRunner.java:44)
Same problem
This comment has been hidden.
I did it using the construction of a bijection between five-digit numbers and codes, it turned out that everything could be done much easier)
in the C version, the free_pins() function doesnt receive the size of the array how can i release every single string inside if i dont know the array len?
It's you who allocates the array, so you know how many elements is there when you allocate, right?
You can use this knowledge while deallocating too.
I decided, but I made a crutch. I look at the decisions of others and somehow it became uncomfortable) nice kata
Tough Kata. Managed to get it working using itertools quite quickly, but took a bit of mental gymnastics to figure out the list permutations using first principles. Finally got it done. Not the prettiest, but think it worked quite nicely.
Much harder than expected.... Tried writing my own permutation function and failed miserably. Ended up using itertools library. Still lots to learn.
This comment has been hidden.
Nice Kata. For me, it was logical to try it with recursion, and, in the end, it worked. Then i decided to check out the other solutions and, well, i just realized how much i still have to learn.
D translation
Hi. I wrote a function that returns array of all variations of pin. But i don't understand what is in the task that should have 1-8 digits when pin has 4 digits?
All the elements in the output array must have the same length as the input.
python fork with new test framework and random tests:
https://www.codewars.com/kumite/62d3b850a93521000faf7135?sel=62d3b850a93521000faf7135
Improved the random tests and approved
Random tests should also sort both lists before comparing them.
Traceback (most recent call last): File "tests.py", line 18, in test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'Come on, detective! You can do it better! These are not the PIN variations for "' + tup[0] + '"') TypeError: 'NoneType' object is not iterable
Its also giving me this error for no reason. Can someone please help me?
And yeah, I am returning instead of printing, so why is it not working?
Please don't create 4 (!) separate messages for the same question, as it makes it hard for other users to reply in one place.
Also the mods are going to tell you to remove Issue tag on both (!) of your messages, as there is no issue with the kata for the time being, you just have to troubleshoot your code.
As for your problem, it's hard to say without seeing your code - if I had to guess, maybe you are iterating twice over a generator without realising it.
Run the following in your IDE:
and notice what happens when you try to make use of
gen
the second time.Now check your code for similar error - that you aren't making use of any generator twice before returning.
Also, as usual - print the input just to make sure you understand which tests you are failing on.
Why those lines? That's why your code fails the first sample test. Not a kata issue. Removed your other posts.
ok
Hello, I've been running my code in Python for a few times and passing all the tests, both sample and random. But every time I "attempt", I get the following stderr code 1 message:
Traceback (most recent call last): File "/workspace/default/tests.py", line 18, in test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'Come on, detective! You can do it better! These are not the PIN variations for "' + tup[0] + '"') TypeError: 'NoneType' object is not iterable
It'd be a great help if someone could help or even hint at where i'm lacking
how are you able to pass both sample and random tests, if an error is occuring
looking only at the message, it seems that one of the variables has a value of None/length 0, which is what results in this error. so you need to rethink your algo to handle these cases
Good kata!!!
(both including random tests)
Rust translation reviewed and can be approved by author.
This comment has been hidden.
Not a kata issue, you're using global vars and they keep their value between tests, read this: https://docs.codewars.com/training/troubleshooting/
It fails the second and third sample test because of that too.
Thank you, modified the code a bit and now it works!
This comment has been hidden.
My code (in C) keeps failing on attempts. It works everytime in the sample tests and for the exact same case. ("8") "0th PIN was expected to be '0', but was 's assertion were not met.'" I printed out the first element and it is '0' like it was asking for. When I print the whole list, the output shows up in the test results instead of the log box.
the error comes from your code: wrong index calculation, so you access invalid memory
should be:
(you forgot the + 1 for the nul terminator, and you got the pointer arithmetic wrong:
ptr + n
will addn * sizeof *ptr
toptr
, so you were going out-of-bounds ofpins
. The cast tochar *
needs to happen right away, in order to have byte-level memory access.)Why can not 233 be the first case instead of 236?? I figthing in python >:c
I guess you mean the third case. The third key is
9
, so3
is not a possibility since it's not adjacent to9
in the keyboard.AHhhh the order matters 369, mine - doesn't
Mark the question as resolved if it's ok :)
Before I used heap algorithm, now I'm stuck :D
The flavour of prerequisites and description is outstanding :)
Ah, the Cartesian product!
COBOL translation, including random tests (author is inactive).
can't use flatMap in js cus most recent node v. i can use on this kata is 8 </3
This comment has been hidden.
I've solved it (in C#) and compared my results with the cases and everything worked and was correct, When I'm testing here I'm getting the error in the first case which makes me unable to continue (the problem is not in the code, you probably wonder how I so sure? well I tried returning the exact list from the case answer and it was the same error ... and I checked that the number is 8 by throwing exception with the pin) the error ->
System.IndexOutOfRangeException : Index was outside the bounds of the array. at System.String.get_Chars(Int32 index) at Kata.GetPINs(String observed) at Tests.TestAll()
Look at the error you just posted, top to bottom. It clearly says the error comes from your function, from attempting to access something out of bounds?
I really can't understand your explanation why you're so sure, but I'm even more sure it's your code that's the problem. If you want to post proper kata issue, you need to provide exact examples: function input, expected result, your result, and why it's incorrect.
Over a thousand users completed it in C# so far, so this is not really a kata issue, but a problem with your code.
See if this article can help you pinpoint the problem: https://docs.codewars.com/training/troubleshooting
Ah, this kata is one of the early Codewars gems. Although had the kata been created now - it would probably be a 6kyu.
No way, this one's quite hard to figure out
yeah, mb 5
Good kata. It took for me about 1.5 hours.
it took me around 5-6 hours to complete this kata. i've realized how much i need to improve... but very satisfied
This comment has been hidden.
test 3 is '369' According to task, 1 number can be either one of '326' 2 - '6359' 3 - '968' So your choices aren't possible. Probably you're forgetting about sequence which is important
I enjoyed solving this
This one is giving me some odd issues on Python 3.9. When I copy/paste my code into the kata, I can only pass the first test and the rest are returning, for example:
PIN: 11: ['0', '11', '12', '14', '21', '22', '24', '41', '42', '44', '5', '7', '8', '9'] should equal ['11', '12', '14', '21', '22', '24', '41', '42', '44']
However, when i run the exact same code in pycharm on my system, I get exactly ['11', '12', '14', '21', '22', '24', '41', '42', '44']. There is no '5','7','8','9','0' that is being outputted by my code. And then for the '369' test it tells me that my code is outputting the results from '11' and '8' as well as the results for '369.' Each one it tests, it's telling me that my code is outputting the previous test's results, on top of the current test results...? It's really weird. But on my system, it's working as expected...
Are you using some global variables, or passing some stale state between test cases?
Oh, thank you. Yes that points me in the right direction to fixing this. Regards
took me a little bit..After trying some complicated solutions with recursions i finally figured it out. It was much easier than it seemed. Anyways, really amazing kata and im glad i could solve it :) .
This comment has been hidden.
fixed.
Now works! Thanks
I'm very satisfied of this kata 😁 I got new lvl of Impostor Syndrome. And now I'm sure, that I was confused with macaque in the maternity hospital. 7 hours to solve this kata. But thanks anyway 😉
./src/main/java/ObservedPin.java:45: error: incompatible types: String[] cannot be converted to List return stringArray; ^ Note: ./src/main/java/ObservedPin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
i got this error for java 11. any ideas?
This comment has been hidden.
Kotlin Translation Please review and approve :)
author is inactive.
PIN: 369: ['235', '236', '238', '239', '256', '258', '259', '263', '265', '266', '268', '269', '296', '298', '299', '323', '325', '326', '328', '329', '335', '336', '338', '339', '356', '358', '359', '363', '365', '366', '368', '369', '396', '398', '399', '568', '596', '598', '599', '635', '636', '638', '639', '656', '658', '659', '663', '665', '666', '668', '669', '696', '698', '699', '968', '996', '998'] should equal ['236', '238', '239', '256', '258', '259', '266', '268', '269', '296', '298', '299', '336', '338', '339', '356', '358', '359', '366', '368', '369', '396', '398', '399', '636', '638', '639', '656', '658', '659', '666', '668', '669', '696', '698', '699'] why isn't 235 a variation?/
To get 5 in 3rd position, you would have to go diagonally from 9, which isn't valid for this kata.
This comment has been hidden.
Not a kata issue,
flat
is not available in every Node's version.Failed asserting that false is true. don't know what does it mean solving by PHP passed all testFixed, passed 4-digits PIN, but if len of PIN > 4 printing me "Failed asserting that false is true."
I had the same problem, I looked once more at the problems description and it shows that PIN is a number with 1-8 digits, you need to validate that.
Had the same problem here (php). I tried to check the length and the nature of the data with some regex, it did no good. The answer was (in my case) : even if you render 1-digit-numbers, they must be string-typed. Hope I helped.
your solution is wrong, for example for
observed = "00001"
, it will return an array likearray(48) { "88818", "08818", "80818", "00818", ... }
--> the1
is treated as if it was in the 4th position, while it is in the 5th position in the input. though it is true that assertion messages are horrendous in PHP, i will raise an issue about that.This comment has been hidden.
After comparing my solution with the solution of other people i feel utterly stupid :E
Why? You solved it, didn't you? I think what you meant was inexperienced. Solve a few more of this type of problem and you'll instantly recognize the pattern needed to solve it. And you probably learned something along the way, at least enough to look at other solutions and understand how you could improve your solution.
Indeed. I learned quite a lot again, thanks for the nice words. Usually i find a solution but here i realized that i probably need to improve my workflow. Think first, work later, not the other way around. My initial approach gave me correct results on the first two test cases, on the third i got 216 possible pins (6^3) compared to 36 from the testcase. Now i basically have a pin bruteforce kit :E
I really like when people make test cases that surprise me like that :)
Node 12 should be enabled (Refer this and this for more info)
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
Node 14 enabled.
That was hardcore one!
Dears,
Please let me know what is the input for each of the tests. For the first one is clear and is displayed on the screen as the layout and for the others? For instance, I would like to know the input for the observed case "11".
Cheers, António Pedro
Hi,
this might help you
For those stuck, try brushing up on nested reducers and / or using recursion.
This comment has been hidden.
Very good kata. Thanks!
very cool kata!! so happy i could solve it
This comment has been hidden.
test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'Come on, detective! You can do it better! These are not the PIN variations for "' + tup[0] + '"') File "/home/codewarrior/solution.py", line 32, in get_pins prev_var = get_pins(pin.replace(list_of_pin[len(list_of_pin)-1],"")) File "/home/codewarrior/solution.py", line 32, in get_pins prev_var = get_pins(pin.replace(list_of_pin[len(list_of_pin)-1],"")) IndexError: list index out of range
I am getting this error. I could not understand why this "a[len(a)-1]" gives error although it passed all tests. Is there anyone to clarify?
This comment has been hidden.
This is probably an issue of your code, not the kata.
If it actually is a kata issue, please reraise, explaining in much excruciating detail why you think so.
This comment has been hidden.
This is because you are trying to do the calculation of 'd' within the loop- you have to do it after 'a' has been populated completely. Also, you have a typo when checking for v==8, a[i] == ...
This comment has been hidden.
The tests will sort the results, so you don't have to worry about order.
how to fix this bug(tests/Fixture.cs(41,29): error CS1501: No overload for method 'Sort' takes 0 arguments)in C#
Good kata. Thanks)
This comment has been hidden.
It's only available on node v11+, which isn't available for this kata.
All of the tests pass but I still get the following error:
Traceback (most recent call last): File "main.py", line 18, in test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'Come on, detective! You can do it better! These are not the PIN variations for "' + tup[0] + '"') File "/home/codewarrior/solution.py", line 20, in get_pins out.append(adj_keys[int(x)]) KeyError: 9
Well, it's time to start learning to read error messages.
If you search for what this means, you'll get that whatever dictionary/object you wanted to access doesn't have
9
as a key, hence the error.This shows you exactly the line that causes the error. It seems that your dict is called
adj_keys
, and it doesn't have9
as a key.Ah.. stupid me. Thank you!
Why there is no 963 in 3rd test case
The observed pin is 369. The first digit of the actual pin is therefore one of 2, 3 or 6 (i.e. 3 itself, or the number to the left, or the number below) - so 963 can't possibly be the actual pin (as the actual combination can't start with 9).
What's the 3rd case? (or language) Test cases can be in different order between languages.
Thanks got the answer.
This comment has been hidden.
How do you get from 3 to 5?
Okay thank you
This comment has been hidden.
One of the preliminary test cases for Haskell has an error. It's the third one, "369". The problems seems to be that the variable k isn't defined. I'm assuming k should have been bound to an array with the combinations for "369", but currently is not defined. The definitive test cases work fine though.
This comment has been hidden.
I need to add that all tests pass till 9173 . Looks like something is wrong with tests for pins of 4 digits and larger.
"There nust be something wrong with tests" is too vague and not a kata issue, rather a question. C# has 687 completions so far, and it's unlikely something is wrong (and you didn't bother to provide an example).
Currently your code is not formatted and very difficult to follow. Please post your code with proper markdown and maybe someone will take a look at your code then.
For general troubleshooting, please read this FAQ.
This comment has been hidden.
I guess I found the issue with my algorithm. I need to use recursion instead of loops.
I tried looking over the code, and one problem I noticed right away is that your list has a bunch of duplicates, and it's also not sorted (expected result is sorted list). With those problems fixed, here's what your code generates for pin "9173" in each iteration:
As you can see, that is not correct. The 2nd row should be
61,62,64,81,82,84,91,92,94
(I think). It looks like you're missing one more loop somewhere.Also, if you read error messages, they tell you what elements are expected, and which ones are missing.
BTW, recursion is definitely not needed, but it's possible both ways.
Thanks for reply and verification of my code. Sorting is not required - you can read on that in the author's comments in Discourse. Duplicates are the problem in my code. I found the issue . I am working hard on loops modification.
This comment has been hidden.
Order shouldn't matter, that's why the test is like this:
I've tried returning
["11", "12", "14", "21", "22", "24", "41", "42", "44"]
for"11"
and it works.Yeah, I see now, it was my fault, I take samples for my own testing inside IDE and didn't pay attention for assert properties. Thanks.
This comment has been hidden.
TypeError: Cannot read property 'sort' of undefined at /home/codewarrior/index.js:35:36 at /runner/frameworks/javascript/cw-2.js:152:11 at Promise._execute at Promise._resolveFromExecutor at new Promise at describe at /home/codewarrior/index.js:27:5 at /home/codewarrior/index.js:38:5 at Object.handleError
Trying to solve in JS, some tests return okay but others do not.
hi,
not an issue, a question. That comes from your code:
at /home/codewarrior/index.js:35:36
, so that's just an error in your logic.If not already done before, reading stuff in there might help you to debug your code.
cheers
PS:
;)
This happens when your solution returns no value. You probably have some path in your code which exits the function witohut returning anything.
I agree that assertion could be improved though.
@hobovsky: sure it comes from the assertions? looks like it comes from the code of the user, no (but assertions could be at stake, yes)
Test.assertSimilar(getPINs(pin).sort(), expectations[pin].sort(), message )
Test suite calls
sort
directly on returned result, so it will crash onundefined
falling out of user solution.yes I saw that. ;p
but considdering the stack trace:at /home/codewarrior/index.js:35:36
...?edit: yep, confirmed, it's the assertion. I just checked against the sampel tests with an empth body. Weird... Means the files are concatenated in JS too...
... because they are, although I do not remember were I know this from :)
Thank you for the quick reply!
The error was coming from the assertion, which is why I posted it as an issue. If it is an error on my part, the assertion IMO does not make this clear. I will check my pathing later but thank you for clarifying some of the errors! Happy Coding!
Just fire that colleague for not doing his job properly
yeah he better hope nobody catches him while he stands there trying 100+ combinations on this bad security system lol
I don't think you can write a C-solution that does not produce warnings. My program passes the tests but I do not know how to return my results as a const pointer, and I don't see how free_pins could be implemented without discarding the const of its parameter (stdlib free() takes a non-const pointer). Is the Kata just bad for C or is there something I miss?
otherwise cool kata though.
And how is that an issue?
You can always explicitly cast things if you really want the warnings to go. I'm not sure how much effect it has though. e.g.
or
This is a great example of a kata which isn't very hard to do in Haskell!
This comment has been hidden.
I don't know what are you talking about, try stating the input value so we know for sure, but if the input is "369" like the post below, the same answer applies to your question.
This comment has been hidden.
See the keyboard in the description, 3 and 9 aren't adjacent. While 3, 6 and 9 can be really a 6.
Easy once you know how; which I didn't for a long time...
Everything is easy when you know how to do it...
I guess it'll be fun:) Detective Mode - ON! Where's my magnifying glass, Watson?
Pretty fun little challenge! Maybe the challenge rating is language dependent, but I completed it in C# and it felt more on par with level 5 Katas I've previously completed.
This comment has been hidden.
Hi all I passed 10 tests but failed in random test with unexpected signal 6, any hint on the random test?
Are you using C? (this comment section is for all languages, and I dont think you can get a SIGABRT in most of them) A common cause for signal 6 is using free/malloc improperly. Make sure you free exactly the pointers you receive from malloc/calloc/realloc, and do not go out of bounds on the arrays you create with malloc (doing so may not always cause a segmentation fault, it may also corrupt your heap)
This comment has been hidden.
This comment has been hidden.
why he tell me " Cannot read property 'sort' of undefined" despite i didn"t use it??
try and do a
return []
even if you have no code.I think the test-runner somehow sorts the returned value, and the great and almighty sensei forgot to cater for such a simple mistake
And why would he? It's your job to return an array:
Very good Kata !
This comment has been hidden.
One string of digits is passed in
OP solved it, closing
This comment has been hidden.
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
This comment has been hidden.
oh, It seems like we gain language experience with solving each kata with different language. Sorry for this.
Sort error
When solving in PHP, there are issues with the final tests when a single digit pin is provided, despite passing sample tests and all other tests.
Managed to pass by trying over and over until the random tests did not include a single digit pin!
The tests expect the solution to be an array of strings, as indicated by the description:
Your solution does not meet that specification for single-digit tests.
This comment has been hidden.
The only way I was able to conceptualize this problem was to create a site tree then iterate through it. Is there a better way of looking at this problem that is easy-ish to understand? The short .reduce() solutions are very confusing to me.
Amazing Kata!
Is it just me, or do the instructions say "not diagonally", yet the 2nd test expects a diagonal match? Am I missing something?
2 and 4 are not in diagonal from 1.
This comment has been hidden.
I'm getting this error on the test - is it my code? It's weird since it past everything and the test doesn't point to what exactly failed
Traceback (most recent call last): File "main.py", line 18, in test.assert_equals(sorted(get_pins(tup[0])), sorted(tup[1]), 'Come on, detective! You can do it better! These are not the PIN variations for "' + tup[0] + '"') TypeError: 'NoneType' object is not iterable
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/is_not_iterable Might be this?
Got it too after a couple of test runs
Are you printing your answer instead of returning it
got same error and can't figure out the problem
I think it will be useful to someone. You must return the result in the "get_pins" function and then there will be no error.
Printing instead of returning. Closing.
Fun Kata, seems easy using higher order functions. 😀
is it not too easy for a 4kyu kata?
It sure is, yes.
Spelling mistake in C initial solution.
C translation - please review and let me know if it needs any improvements, especially some description or additional comments about memory management.
This comment has been hidden.
No, you have to include the observed pin too in the output. You can easily see that in the sample tests. Now if you meant another thing, the PIN in the kata description is an example, you have always to work with the function's input.
Thank you.
This comment has been hidden.
This comment has been hidden.
Python has random tests now.
This comment has been hidden.
Haskell fork with random tests
I published a fork with random tests rebalanced and unified with other languages (namely C++, because it has the most complete random tests suite compared to others): PIN length is 5 characters, 200 random PINs tested.
Current C# translation has a problem with the fact that, for some reason, Mono runtime is approx. 3 times slower than 7.3 runtime, and test suite sometimes times out when Mono is selected, but almost always passes when C# 7.3 is selected.
Please review and approve.
You are right.Increase the random test case to 2500 which will take 10000-11000ms.I think it will be enough.
This comment has been hidden.
This comment has been hidden.
nope: look at the tests
See - this is exactly why I suggested
List
is the wrong datatypeThis comment has been hidden.
Hmmm, have you considered the possibility your code make have a bug? (e.g. infinite loop for some incorrectly handled inputs)
I think it's unlikely. Unfornutately it doesn't show me for which case it time out. If I'm not mistaken infinite loops are impossible for my code and incorrect inputs would result in an instant error. Unless it really exceeds the 8 digit pin it shouldn't be too inefficient.
I've done this in Python/JS/Ruby/C++, and did not encounter inputs longer than 5 characters, this is probably true for other languages as well.
You can post your code in a comment with a spoiler tag, so somebody could review it if you want.
This comment has been hidden.
There is a problem that when you select
Mono 4.3.2
version of C# runtime, it's ~3 times slower than7.3
version, and quite often times out. I published a fork with rebalanced random tests so you can check again when it gets accepted, but it's highly probable that your solution will pass even currently, when you selectC# 7.3
version before you submit your solution.Let me know if it worked for you, and mark question as resolved if so.
Regards!
Java
List
implies order, but result order is not specified/required for this Kata so IMO method should be returning aSet
All language versions, including initial JavaScript, require ordered sequence to be returned, while each and every of them has sets. That's why I made C# tranlation return it too, for consistency with author's initial vision. Why do you consider
List
to be an issue particularly for Java?I don't. I only mentioned Java because I only solved for Java. Others may suffer the same problem.
On the contrary, the Kata description says nothing about "require ordering" and in fact the 1st thing test cases do is to take result order out of the returned value by sorting it.
IMO each translation should use the most appropriate method signature for their language. IMO List is not most appropriate type choice for Java.
This comment has been hidden.
In C#, the sample tests and the fixed tests seem to have the Actual and Expected values flipped, and random tests seems to be ok (about Actual and Expected in their right places, I've not seen the testing code), you can check that using this code:
That being said (I haven't solved it in C# yet), my js code returns results like the last ones you wrote for that observed pin "095561".
Thanks for the reply, I just want to confirm what you're saying to make sure I understand.
I did notice the expected and actual was flipped for the hard-coded tests. The random test appears to be the correct way around, I suppose it would be nice if the hard coded tests were fixed.
So your JS code agrees with my actual results? Does the JS code also have issues with the expected result? I wish I could see the random unit test and work out what's going on, but of course I have to be able to solve it first! Maybe they've just got their numbers flipped wrongly, I guess I could work out what it's using and update mine to be 'right'.
It seems it isn't that simply, just got this output:
Expected: equivalent to < "222972", "122972", "322972", "522972", "212972", "112972", "312972", "512972", "232972", "132972"... > But was: < "p: 452094", "c: 1920", "121861", "121864", "121865", "121867", "121881", "121884", "121885", "121887"... >
so pincode is 452094, lets look at the first two digits, 4 and 5. According to expected:
4 could be 2,1,3,5 5 could be 2,1,3 and of course 5.
So, obviously given an input of 4, and an input of 5, the possibilities should be different. 5 for example should include 8, and should not include diagonals.
I am on it right now. Could you please share your code (marked as a spoiler) so I could test the behavior in consistent conditions? Thank you!
This comment has been hidden.
As soon as I saw
static List<string> Combinations
in your class, I got a feeling what might be wrong... :) Actual issue is in linereturn Combinations;
in yourGetPINs
implementation - for every call, you return one and the same array with modified contents. If someone decided to collect your results from several calls, all of them get overwritten by most recent one. I consider it as an issue with solution, and not tests, because returning mutable result is, umm..., let's say uexpected ;)Small test case to illustrate your issue:
Swapped
actual
andexpected
are indeed an issue and I will fork and fix it.I added a fork with actual/expected placed (hopefully) correctly. Did no fixes in code, as I consider the issue a problem with solution, not the kata/tests. In case of other problems, let me know.
Haha, yep thanks, that's an interesting side effect. I wrote it that way as I needed to improve speed, have fixed it up, optimised some other areas and submitted. I'm fairly new here but I'm guessing Codewars used to be faster, even the solution in TestRandom takes about 10 seconds to execute, yet a few milliseconds on my PC!
How to return the button for testing kats?
Not a kata issue.
Kata is super and legend both in meaning and in legend.
Нow to unlock test validation. Of the buttons only there is a "discussion"?
https://github.com/Codewars/codewars.com/issues/1214 Change window size or zoom or scroll by wheel click.
Fun Kata :)
This comment has been hidden.
Thanks for this Kata. The keyboard made it very interesting.
C++ translation. Please, review and approve.
Bumping translation.
PIN: 8 - Expected: '['0', '5', '7', '8', '9']', instead got: '[0, 5, 7, 8, 9]'
Can anyone explain what's an issue? It's working for 2 and 3 characters but fails for 1.
You're returning an array of numbers and it expects an array of strings.
Thank you for your answer, but already solved. That was such a simple thing but I was trying to get it for a half an hour. Awesome kata, by the way!:)
This comment has been hidden.
That's easy. Your trying to get
.length
of undefined, and most probably intracker.push(nums[(parseInt(a) - 1)].length);
because yournums
array is wrong.Replace
a
with0
there and you'll see why.C# translation - please review.
Approved some time ago
Clojure translation
Please review and approve.
I added some short random tests, which probably should be added to other languages as well.
Approved some time ago
This comment has been hidden.
As always, not an issue unless you can point out why the tests might be wrong ;-)
Next time you should raise as a
question
and post your code with spoilers. You'll quickly get pointed out where your code has a bug ;-)This comment has been hidden.
Where is the
5 to 8
digits part? ;-)So I was getting a error at 1357 because I wasn't testing for 5 to 8 digits? 😶
Everything is working now. Thank you!
This comment has been hidden.
Not an issue, a question.
This comment has been hidden.
This comment has been hidden.
Hey, the problem I was having just had to deal with single digit inputs.
Awesome kata, thanks @BattleRattle!!!
Very nice idea ! Liked it so much that i had to do a Java-translation (please comment and/or approve).
This is confusing for me can some one explain to me where the second and third test case come from? Did we just increase the key pad size?
We increased the PIN length. The first test case covers the observation of exactly one key. The second case covers the input of a PIN with two digits (11), the third one a PIN with three digits (369). The expectations are then all combinations which can be possible considering all adjacent digits of the observed inputs.
This was really interesting! Thanks.
This comment has been hidden.
getting server execution error for my code for observed pin problem... code runs fine for sample tests ... when i try it using "ATTEMPT" button it gives server executione rror... please help
It is not a Kata issue. CW server had lots of issues back then.
Not a kata issue.
This comment has been hidden.
No, the numbers 9, 5 and 8 are not adjacent to 3. So when your first digit is 3, you can't have 6 possibilities to enter. Same rules apply to your 2nd and 3rd digit.
cannot read property sort of undefined javascript.
i have entered no code and the test cases are failing. I put in a condition in the test for loop if(getPINs(pin)) then run the test, still doesn't work
It is expecting an array, if no array is returned from the function, the sort property makes no sense. Hope this clears your doubt :)
This comment has been hidden.
This was good fun. I saw some functions I did not know about in the Haskell solutions. Thx BR.
Brilliant. Loved this!
Would someone please explain the following error: "Failed to process output. It is possible that too much data was written to STDOUT."
I have removed all console.log statements. I am using a cache to improve performance. If the cache gets too large, could that cause this error?
My solution is also getting this error, I had no problems completing sample tests.
Getting this error on tests.... Because of that I could not work with my code to see what changes do I have to make... TypeError: getPINs(...).sort is not a function at /runner/frameworks/javascript/cw-2.js:179:21 at Promise._execute at Promise._resolveFromExecutor at new Promise at describe at Object.handleError at ContextifyScript.Script.runInThisContext at Object.exports.runInThisContext
Probably you have to return array - not string.
This comment has been hidden.
First digit is 3, so the only possibilities for first digit are : -> 3 -> horizontal/vertical adjacents (in this case 2 or 6).
Interesting Kaka. Thank you @BattleRattle!
I have been getting the following message for the last 1 hr whenever I try to submit my code:- Request Timeout: The server timed out running the request. This may be due to an issue with the backend server. Please try again. The test cases all work nicely. ??????
Haskell
I have enjoyed this kata, but it's never a 4kyu, maybe 6 or 7.
8 kyu plz. this is nothing
How long do people think this kata should take for an intermediate Python programmer (loose phrase, I know)?
I am still a beginner and it took me around 2.5 hours. I definitely went off on a bunch of tangents before finding a reasonable solution, though.
If you're a beginner then I can't type cause I'm on 3 hours and still not close
Hello, I am new in programming and I don't understand the input. Can someone explain the input?
I have the same question. If the input is the PIN number as a string, then my code should work.
awesome. really fun
I really enjoyed this kata! Great job!
Good and exciting kata, just like the most of yours BattleRattle! I think 4 kyu is bit much for it, or am I getting better? :) Thank you!
Nice detective story and kata! Thank you very much!
It seems that in your solution 'observed' is a string but it is an int, doesn't it?
From requirements: "please note that all PINs, the observed one and also the results, must be strings, because of potentially leading '0's." Sorry, I don't understnad what was the question...