Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Test case 5 in Java is not about empty arrays. It's about nulls. Do you check for null in your code?
Try to write down the till's contents after each transation.
Take the series of customers with bills of [25, 50, 25, 100]:
Step 1:
Bills in till after the transation: 1x 25
(customer paid his ticket and did not need change)
Step 2:
Bills in till: 1x 50
(customer brought the 50 and received the 25 bill as remainder)
Step 3:
Bills in till: 1x 50, 1x 25
(the customer paid his 25, needed no change, so the bill goes in the till)
Step 4:
Bills in till: none
(customer came with a bill of 100, the clerk is able to use the 50+25 bills to hand him the change)
Apply the same for [25, 25, 50, 100], till contents per step are:
Hi @alex__c, granted, it may not be in the examples, but the
Remarks
portion of the directions do tell us thata or b might be [] (all languages except R, Shell)
. The word "or" instead of "and" that indicates that they could be different lengths. Best of luck!You can use the equality operator (==) with the null keyword. So, if (a == null) { do things differently }
@Mariam:
After careful consideration, I am fully sure I need to check for the abs() value when sorting, to handle negative numbers in the array. That is not the issue. Thank you for your contribution :)
However, after re-re-checking my logic, I have found a pesky off-by-one error, so I will consider my issue as moot. It wasn't test case 8's fault.
Instead, I have discovered that none of the examples even hint that the arrays might have different sizes, they are the same size in all examples. Another thing to consider....
@Hobovsky:
I have. It would have been more useful if you had directly quoted the parts you thought were relevant for me. In any case, thank you, I guess.
omg, it looks like test case 5 HAS NO array b? Is it possible? What code I have to write to find out did main method passed both arrays or no? I do Java
I have same problem. Cannot pass the test 5 that has two empty arrays. I do check empty arrays in the beggining. It works in IntellijiIdea but doesnt work here.
if((a.length == 0) && (b.length == 0)){
return true;
}
Please read this.
hobovsky, I do it in Java. Why it is wrong?
if((a.length == 0) && (b.length == 0)){
return true;
}
I tryed && and & - nothing helps
((a.length == 0) & (b.length == 0))
: It depends on language, but if this is exactly how you have it in code, then it's most probably wrong.no need to use abs. do not do it
I passed 12 and failed in 1. Cannot pass test 5 with two empty arrays. But I do check length of both arrays and if BOTH of them are 0 I return TRUE ((a.length == 0) & (b.length == 0)) Am I right??
Testcase 8 is strange. The last pair is definitely NOT a root and square pair, the root of 36481 is 191, not 195.
I am printing arrays a and b in ascending order of their abs(values).
Log:
0 0
1 1
-14 196
19 361
144 20736
161 25921
195 36481 <-- ????
expected: but was:
11 squared is 121, do the math