5 kyu

Is my friend cheating?

6,137 of 18,221g964
Description
Loading description...
Fundamentals
Mathematics
Puzzles
  • Please sign in or sign up to leave a comment.
  • alicefogliato Avatar

    This comment has been hidden.

  • Ahmedrt6 Avatar

    This comment has been hidden.

  • trashy_incel Avatar

    As previously reported there, it is unclear if a and b must be distinct. In C and OCaml at least, the author's solution returns (3, 3) for n = 5 (1 + 2 + 3 + 4 + 5 = 15, 15 - 3 - 3 = 3 * 3 = 9).

  • BkDkSide Avatar

    Wow, a really good kata!

  • Specterlab Avatar

    VERRY minor issue, in the java version in this kata, the List class is not imported, and as such gives an error, can be solved by adding: import java.util.List;

  • anya-ananasss Avatar

    Wonderful kata! I just love math puzzles

  • Jeremy Price Avatar

    method name removNb seemed unnecessary, any reason you didn't name it something clearer like removeNumbers?

  • sebaperez31 Avatar

    Amazing kata! It took me ages to pass the tests for large numbers. And when I checked out the solutions, I couldn’t believe my eyes, so simple!

  • SohaibMagrabi Avatar

    why this is wrong n = 103: expected [ [ 486, 10 ], [ 10, 486 ] ] to deeply equal []

  • rankinjo Avatar

    This comment has been hidden.

  • ahmet_popaj Avatar

    Very nice kata, well done.

  • MohammadJabir Avatar

    What are we supposed to return for if there are no values (in C#)? new long[0];? List<long[]>{ new long[0] };?

    I got all my successful cases working, but the null ones I'm not sure what they're asking for.

  • janAkali Avatar

    Nim tests are broken, all tests pass, but solution is rejected because of "Exit Code: 1"

  • bryanquille Avatar

    Tricky, 5 hours in front of my laptop hahaha, but that @subtalon said helped me to solve it in 5 minutes. It is not an algorithm problem at all, when you try it as an algorithm at all the code will be inefficient and the time will exceed the allowed to accomplish. It's better to understand it in a math way.

  • morre95 Avatar

    I get these error messages in c#: src/Solution.cs(15,26): error CS1026: ) expected src/Solution.cs(15,32): error CS1002: ; expected src/Solution.cs(15,32): error CS1513: } expected src/Solution.cs(19,7): error CS8803: Top-level statements must precede namespace and type declarations. src/Solution.cs(20,3): error CS1022: Type or namespace definition, or end-of-file expected src/Solution.cs(21,1): error CS1022: Type or namespace definition, or end-of-file expected If I copy and past the code into VS it works I can run it without error. But not here

  • Nlight91 Avatar

    Hey you who is trying to solve this, non spoiler-ish tips:

    • you gotta know a math trick
    • write equality on paper, and do some algebra.

    both tips are unrelated.

  • kirzaka8 Avatar

    This comment has been hidden.

  • TheChildOfProphecy Avatar

    This comment has been hidden.

  • MelinShoot Avatar

    after finishing, I felt dumb with the polynomial i divised...

  • MihaiS7 Avatar

    Tried 3 different algorithms, each one build differit, but same timeout error... Pretty hard this kata, but a good one

  • JulluisW Avatar

    It is so challenging yo!

  • ejini战神 Avatar

    C#: method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • Nullius Avatar

    Whew, that was hard

  • WiseStory Avatar

    im having timeout for all time im trying to sumbit this kata

  • cub8 Avatar

    This comment has been hidden.

  • 𝕚𝕝𝕪𝕒 Avatar

    After several hours of torment with double-passing, all sorts of squeezing intervals of variables, an elegant solution dawned on me. Thank you, g964. I used to hate your katas)

  • mrDans Avatar

    I'ts always you, g964, it's always you lmao. I'm having a hard time here because of timeout, this is incredible!

  • Quark Fox Avatar

    g964 kata, great kata, i think i would do it in 2 minute, and so i did, but only after 8 test timeout, twist is nice, after all math is beautiful!!

  • coryshrmn Avatar

    This comment has been hidden.

  • hugoferreirj Avatar

    This was really interesting and i learned a new way of solving problemas. It took me a few hours to solve this one. Writing the equation down really helped me! Thanks everyone for the hint

  • timleungtech Avatar

    This is one of the most satisfying katas I've ever solved

  • bleuebloom Avatar

    for removNB(26), {1, 175} is not a valid solution but should be because the total of all numbers in the sequence is 351, and 351 - 1 -175 == 175 * 1

    but the answer doesn't pass the test.

  • JoaoFelipe3 Avatar

    "A friend of mine takes the sequence of all numbers from 1 to n (where n > 0)."

    Inclusive or exclusive?

  • Bivvercode Avatar

    This is a nice problem, I am stuck with how to make my code faster... Anyone have any suggestions for me? Writing in swift

  • subtalon Avatar

    This is not a algorithm problem as much as it is a math problem. Perhaps having a hint left here would have helped, enjoyed the challenge though.

  • manstolethefruit Avatar

    This comment has been hidden.

  • 4500zenja1 Avatar

    JS translation with adding more random big tests

  • 4500zenja1 Avatar

    Ruby translation for upgrading to 3.0

  • strongnoy Avatar

    I get task wrong, aren't I? In example sum of all elements from 1 to 26 is 325, if a and b equal 15 and 21, sum of sequence without a and b would equal 289, while 15*21 = 315 which is wrong in the way I get this

  • EdoardoLaGreca Avatar

    My Go code works fine, it has a time complexity of O(n^2) (which is the best I could do) and passes the basic cases but times out when trying to submit. Quite frustrating.

    Edit: I optimized the code which now is O(nlogn) I think. It works and passes all the submit tests in less than 2000 ms.

  • rlau1209 Avatar

    I like how we are told to return an empty array if there are more than one solution and return "nil" if there is no solution but we acctually dont need to do that

  • nomennescio Avatar

    Factor translation issue.

    Test code has:

    : to-array ( seq -- arr ) >array [ >array ] map ;
    ...
    : run-tests ( -- )
      "Is my friend cheating?" describe#{
        "Basic tests" it#{
          <{ 26 remove-nb to-array -> { { 15 21 } { 21 15 } } }>
    

    Calling to-array on the output of the user function will give very cryptic error messages if the user does not return an sequence of sequences, due to an error on his side:

    Thrown: Generic word length does not define a method for the fixnum class.
    Dispatching on object: 15
    

    which is unnecessary difficult to diagnose

    Consider either a more robust implementation of to-array, don't use it all, or introduce custom error handling.

  • rxe Avatar

    Nim translation fixes

    • fix issues with always passing tests
    • 1.6 fixes
  • user204650 Avatar

    About two months ago, I had no idea how to code. I cannot believe that I solved this today. Excellent kata!

  • spyhere Avatar

    After I've solved it, I can't believe I hate math even more, whoa...

  • H-s Avatar

    n = 1000003: expected [ [ 550320, 908566 ], [ 908566, 550320 ], [ 559756, 893250 ], [ 893250, 559756 ] ] to deeply equal [ [ 550320, 908566 ], [ 559756, 893250 ], [ 893250, 559756 ], [ 908566, 550320 ] ] Just have this issue where I have to sort result even tho it's technicaly right but order is wrong?

  • olypmanel Avatar

    My program works perfectly when tested, but fails just one test all because of the timeout issues. I feel down, after racking my brain to put down a code that works fine only to be rejected due to timeout issue.

  • grebenkin_vd Avatar

    I'm wondering if there is better java collection to use than ArrayList? (in that current kata)

  • LS2008 Avatar

    This comment has been hidden.

  • LS2008 Avatar

    my math isn't that bad but the problem here is Im like 14 years old, does it have something to do with high school math or it's solvable for a year 8 student?

  • jakelyson Avatar

    My solution passed, I don't know why.

    Great kata anyway.

  • gabopereyra Avatar

    Tests 10 and 11 tell me that the arrays don't have the same size (I fulfill 10/12 tests), I can only see the stack of the exception, it doesn't show me what the test expects (which would be useful to guide me in the code correction) any suggestions? I'm working with Java

  • runestextwa Avatar

    After spending MUCH more time than I should've trying to optimize the code, I wonder why I didn't decide to just solve the equation in the first place, instead of using two loops with the same damn equation in the core. A great kata, actually

  • Vladiyudi Avatar

    This comment has been hidden.

  • vlasec Avatar

    This comment has been hidden.

  • Rig14 Avatar

    for me, the thing that helped me the most, was writing the equation out on a piece of paper.

  • kands_code Avatar

    This comment has been hidden.

  • Rendxnn Avatar

    haha just when I thought I finally figured it out I noticed you had to give more than just one pair of numbers.

    I really wanna cry rn.

    nice kata btw

  • lahongvy Avatar

    I spent almost an hour for this kata. Probably I'm kinda slower than other people. I can do it, you can too.

    This kata is all about math. If you fucked up at math, go learn about sumation notation.

    Don't ever think you can solve this with O(n^2). The test cases have big numbers. One for loop is enough.

  • Qoobick69 Avatar

    This comment has been hidden.

  • hosua Avatar

    Good kata, I took advice from a comment below and did the math on paper, then the implementation was trivial.

  • shwagmoney31 Avatar

    Awesome Kata! I was about to cry for help and give up when I got the right idea; it's actually pretty trivial. The only hints I will give: if your code times out, it's not the right way to solve this. And if you're really stuck, /// try solving it like you would solve a math problem, not a CS problem. ///

    If you need help, feel free to comment under this post and I will try my best to help you figure it out. Took me about an hour and a half, but it was very satisfying in the end. You can do it too!

  • marvey11 Avatar

    I like the fact that the trivial solution is failing for the big numbers due to the tests timing out, and you have to actually think about how to solve this one. Thanks for this kata!

  • Hyrtsi Avatar

    This comment has been hidden.

  • ktoto335 Avatar

    This comment has been hidden.

  • griever_ Avatar

    Issue with C expected pair format:

    Error. Expected {{505, 811}{615, 666}{637, 643}{643, 637}{666, 615}{811, 505}} but got {{505, 811}{811, 505}{615, 666}{666, 615}{637, 643}{643, 637}}

    Only "failing" this one test, which doesn't juxtapose the two like-pairs of each set together like apparently every other test case does. Only 182 of 12,347 C programmers finished this one, so I would call this an issue. Please adjust the expected order of the pairs.

  • Whitedaddy Avatar

    For some reason I have complete Basic Tests which follows the "Test" Button. But when I entering the "Submit" button, Random Test is completed and Basic test is not. I can not figure out why

  • Joec05 Avatar

    This comment has been hidden.

  • gurrugod Avatar

    Thanks! Good exercise! But I think is 6 or 7 kyu, but not 5 kyu. Because for O(n) you need know one rule from math and pair of condition for <O(n)

  • Joec05 Avatar

    This comment has been hidden.

  • nauseous_spartan Avatar

    This comment has been hidden.

  • gurelit Avatar

    I pass the test but I cannot pass the attempt. :(

  • SergeyFM Avatar

    The next morning I came up with a frustratingly simple solution that makes you wonder, man, are u stupid?

  • psykido Avatar

    A lot of dust had to be blown off my school maths to get this to pass efficiently. Thanks for the challenge - boy I found this haaard!

  • Shakinnn Avatar

    Gorgeous kata! I thoght of it all day and can't sleep tonight unlit it's done

  • user1430804 Avatar

    wow. one of the best challenges on this website. thank you

  • RollinSafary Avatar

    This comment has been hidden.

  • dfhwze Avatar

    C#: src/Solution.cs(3,16): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)

    The following should be added to the initial solution setup:

    using System.Collections.Generic;
    
  • HugoDerre Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • Stranger2010 Avatar

    This comment has been hidden.

  • Ariel-Lapidus-vayyar Avatar

    fixed tests work fine, but when trying to submit the solution it times out

  • kikirac Avatar

    Amazing kata! Well done to creator, I just don't know why is it 5kyu and not 4kyu.

  • CarlosDLMC Avatar

    I pass all the tests, but when I submit my program I run into an error because it executes too long. How can I see the example where my program is having problems with, so I con reply it by myself and see what's wrong?

  • Lahrmus Avatar

    This comment has been hidden.

  • Bokhylle Avatar

    This comment has been hidden.

  • dsagman Avatar

    This comment has been hidden.

  • Lucasss Avatar

    This comment has been hidden.

  • andreak Avatar

    This comment has been hidden.

  • Gaiboru Avatar

    Wonderful puzzle, as a newb in programming I learnt plenty to finish this kata.

  • sharmapranav25 Avatar

    can more than one combination exist

  • pmadronero Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    This comment has been hidden.

  • ejini战神 Avatar

    This comment has been hidden.

  • Glaoui Avatar

    This comment has been hidden.

  • JohnSmithX Avatar

    This comment has been hidden.

  • user624817 Avatar

    This comment has been hidden.

  • Daniel-Himme Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    This comment has been hidden.

  • paulo_techie Avatar

    Why does the test have an issue with the same result? I thought my code was wrong till I realized it is the same thing!

    Expected: [[550320, 908566], [559756, 893250], [893250, 559756], [908566, 550320]], instead got: [[559756, 893250], [893250, 559756], [550320, 908566], [908566, 550320]]

  • ianhaggerty Avatar

    This comment has been hidden.

  • zhotice011z Avatar

    This comment has been hidden.

  • wszuc Avatar

    WOW, what a great Kata! I spent almost whole day to figure out the formula. It was worth it. Added to favourites!

  • Zipfer Avatar

    I'm getting this tests error not sure maybe I'm wrong by looks like tests checking only one particular sequence: Expected: [[550320, 908566], [559756, 893250], [893250, 559756], [908566, 550320]], instead got: [[559756, 893250], [893250, 559756], [550320, 908566], [908566, 550320]]

  • zzjzgz Avatar

    This comment has been hidden.

  • Ciprian Amza Avatar

    I love this kata! It literally rememberd me of the math tricks from high-school (like a = b <=> a+1-1 = b). Thank you!

  • Stardust007 Avatar

    This comment has been hidden.

  • EbenZergaw Avatar

    Code works except for the higher value (500003500006). It either times out or returns this: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

  • LuxF3rre Avatar

    Sometimes tests expect only (x, y) and sometimes (x, y) AND (y, x) which makes it impossible to pass. I use Python version.

  • Ziad251 Avatar

    How is it possible to return 2 values as a List of type long in C#? Like the form required [(a, b), ...]...or should I change it to a tuple of type long? like Tuple<long, long>[] removNb

  • Dhaivat717 Avatar

    This comment has been hidden.

  • Nata_Case Avatar

    The instructions are poorly written. (1,-5,47,n) fits the description of "a sequence of numbers from 1 to n." Sequence has a clear mathematical meaning and it is not as assumed here. It should be re-worded as something like "all integers from 1 to n" to fix this ambiguity.

  • SoundAsleep192 Avatar

    This comment has been hidden.

  • code_warrior7 Avatar

    Please check my reply in my previous issue report. I know you marked it as resolved but I don't think it's resolved yet. Thanks

  • EricB10 Avatar

    This comment has been hidden.

  • hodgesb Avatar

    Fascinating kata! The performance requirements make this a deceivingly complex challenge. Somewhat astonisting how little code the performant solution requires. And I felt so proud of my cunning brute-force solution, LOL!

  • code_warrior7 Avatar

    This comment has been hidden.

  • bonesire Avatar

    This comment has been hidden.

  • alexanderholmberg Avatar

    Can't figure out how to reduce my 2 for loops to 1.... great kata though

  • nrupesh Avatar

    This comment has been hidden.

  • Lolshh Avatar

    My code works fine except I just don't understand why sometimes you need to return only one pair of integers when several others would work and sometimes you need to return more but not every single one of them. Could someone explain me this please?

  • Litusiano Avatar

    This comment has been hidden.

  • kamil.sikora92 Avatar

    This comment has been hidden.

  • Bubbler Avatar

    This comment has been hidden.

  • yannotron Avatar

    What a struggle at first! Thank you everyone for guiding me through it.

  • keithzyyy Avatar

    Nice kata, although it had me overthinking for a bit since I thought that it's going to be relatively difficult, but turns out that the implementation is not quite complicated.

  • vj0r Avatar

    This comment has been hidden.

  • RealKenshiro Avatar

    Simple yet very funny and interesting Kata!

    Thanks to the author!

  • ale444113 Avatar

    This comment has been hidden.

  • Krachi Avatar

    Awesome Kata, really had to twist my brain to come up with a solution that is fast enough with bigger numbers too.

  • wei! Avatar

    This comment has been hidden.

  • LowellJustice Avatar

    Just figured this one out, wow what a great kata. I know a bunch of you are having difficulties figuring out how to simplify your code, so just remember that you can have one for-loop and still be fine. Don't focus on making it completely in terms of n, just figure out how you can simplify the nested for-loop to a single for-loop. Great kata.

  • nomennescio Avatar

    This comment has been hidden.

  • kozmarti Avatar

    It was fun to find out, inner loop is simply replaceable by an equation. Algebra is needed to solve the "Execution Timed Out (12000 ms)" Great exercise

  • kelkamish Avatar

    This comment has been hidden.

  • rge123 Avatar

    a sequence of numbers from 1 to n (where n > 0)

    I presume this must be the sequence {1,2,3,4,5,6....n} but I don't see anything in the description to confirm this?

  • Haksell Avatar

    Python version should use snake_case.

  • Manib92 Avatar

    This comment has been hidden.

  • farazalikhan33 Avatar

    This comment has been hidden.

  • sebc Avatar

    Hi I have a Problem in C++. So i get the correct Values, but if i push them into my vector<vector> I get the error message "wrong return type". If I push some random numbers into the vecotr everything works. Even if I push, like in the first test, 15,21 into the first vector and then 15,21 into the second one everything works, but if i push 21,15 into the second one it magically wont work anymore (at least it seems to me). Has anyone experienced the same problem?

  • uykusuZzZz Avatar

    Just FYI on R, it requires the list elements to be sorted on the first number (a). If you submit the same list just ordered on b, you will get errors.

  • colossalg Avatar

    This comment has been hidden.

  • ImmePak Avatar

    This comment has been hidden.

  • jcraffaello Avatar

    Made it! I really learned a LOT from this Kata and it directly pushes me to turn to gcc in linux from VS! Thank you Sensei!

  • Voile Avatar

    Some languages do not have random tests, e.g Haskell.

  • jcraffaello Avatar

    Hi all another question: as per the returning type of removeNb I have a Pair** type pointer as the return value, but from the instruction and the debugging error I got, the return value shall be a 2-D array as {{15, 21}{21, 15}}. Apparently I got {} as the submitted value. Anybody can give a hint on that? How it is possible to return {{15, 21}{21, 15}} as a Pair** type?

  • jcraffaello Avatar

    Hello all! could anybody tell me what the hack the parameter length means?

  • biscuitlegs Avatar

    Really challenging kata for me, had me so frustrated at times. Anyone who's stuck, the other comments here will guide you in the right direction.

  • prprDog Avatar

    This comment has been hidden.

  • Yohber Avatar

    This comment has been hidden.

  • DeathWraith Avatar

    This comment has been hidden.

  • fedefrancescon Avatar

    Hi, I have I problem testing my code in C. Maybe I did something wrong but the function array2String function gets an INVALID MEMORY ACCESS while testing. The weird thing is that if I comment out the call to array2String and print the array... it works without problem. Could you please help me?

  • shankssc Avatar

    I want to thank everyone who suggested the use of pen and paper, it becomes very simple once you get the algebra behind the problem.

  • celsoc Avatar

    7AM here, and I am finally done with this one! Congratulations on the creator for keeping me home on a Friday night...

  • IceColdPT Avatar

    im always getting time out...

  • fibonaccios Avatar

    One of the best 5Kyu's I have solved... Use pen and paper people...it will just come to you!

  • meiblorn Avatar

    Awesome kata. Not all the solutions are made of code, this one proves it. Try to play with algebra, then you will easily solve it in a few minutes.

    Big thanks to authors!

  • nikonor Avatar

    This comment has been hidden.

  • kipawaa Avatar

    Strongly suggest letting users know that time constraints will be a concern and to prioritize timing, was frustrating taking a more "coder" approach only to realize after reading comments that i should use algebra. Otherwise, great kata!

  • Alexandr Krylov Avatar

    I can't resolve the kata on PHP becouse take timeout during attept tests.

  • joespinelli7 Avatar

    This comment has been hidden.

  • LJBD Avatar

    Using Vec<(i32, i32)> as output in Rust requires everybody to sort their solutions the way the author wants. Using a HashSet<(i32, i32)> would be more fitting. Also, since the numbers are strictly positive, u32 should be used instead of i32.

  • AlexanderG Avatar

    The feeling I got after thinking that I suck at math for so many years and finally solving this kata...

  • devLeopar Avatar

    This comment has been hidden.

  • oruntachukwuemeka Avatar

    This comment has been hidden.

  • dsmcclain Avatar

    This Kata is a nice little algebra problem, not really a coding challenge per se.

    However -- I think it's silly that the test examples contain such small numbers and the description makes no mention of constraints on algorithmic efficiency.

    It's like the designer wants to bait you into choosing a brute force method and then GOTCHA! the actual test suite contains very large numbers. I'm not sure why this is. For many programmers, choosing a brute force method will be quicker and more natural than doing a little algebra to find a method with O(n). It's clear from the comments here that this is confusing to a lot of users.

    TLDR - Kata would be significantly improved by providing a clue about its true constraints.

  • chwostian Avatar

    This comment has been hidden.

  • happyAlexst Avatar

    This comment has been hidden.

  • miller777 Avatar

    This comment has been hidden.

  • zeronumbers Avatar

    This comment has been hidden.

  • yellowBunny Avatar

    playing with list in this case isn't good idea ? my solution is extremly slow O(n*2) maybe any hint :)?

  • brMerak Avatar

    This comment has been hidden.

  • vlad413 Avatar

    This comment has been hidden.

  • hksong Avatar
    n = 1000003 - Expected: '[[550320, 908566], [559756, 893250], [893250, 559756], [908566, 550320]]', instead got: '[[550320, 908566], [908566, 550320], [559756, 893250], [893250, 559756]]'
    

    Maybe my eyes are tricking me, but those look like similar arrays to me.

  • cadet01011010 Avatar

    Wow, that took me a while. It has been a really long time since I did much algerbra. Pretty cool!

  • Rkardo58 Avatar

    This comment has been hidden.

  • metalim Avatar

    Wow... This is really stupid. removNb(26) should return [(15, 21), (21, 15)] Why should it return same numbers twice? This is kata design flaw. And it got translated to shitton of languages. Awful.

  • Brian_GTech Avatar

    This comment has been hidden.

  • gitricharde Avatar

    This comment has been hidden.

  • IonutArhire Avatar

    This comment has been hidden.

  • apeipo Avatar

    This comment has been hidden.

  • hgfeaon Avatar

    This comment has been hidden.

  • lanfeiyung Avatar

    No matter how I modify it, it prompts timeout.

  • K.E. Avatar

    hi. test10 gave error "Arrays not the same length" Incoming value: 1000003 Result pairs are: [[550320, 908566], [908566, 550320]] and this answer is correct, but the test doesn't pass Why?:(

  • justin.ndwiga Avatar

    Does this kata has a problem? I keep getting the "execution time out" error even after optimizing the code endlessly.

  • jakeneild Avatar

    I can get my code to solve the problem, but it times out with the higher values.

    I can use a simplified code to find only one solution, but that doesn't satisfy the conditions either.

  • AjinathJedhe Avatar

    This comment has been hidden.

  • vvg3 Avatar

    I am currently not passing even the simple sample test where n = 26, which should return [15, 21] and [21, 15]. My error is that essentially the arrays are flipped, returning [21, 15] and [15, 21], so the arrays differ at each element. When running my own IDE and test cases, this is not the case. I can see clearly that I return [15, 21] followed by [21, 15]. I do not understand why this is happening on the CW site. Anyone else same issue?

    From reading the other comments/questions, I understand that I may run into some complexity issues later, but its frustrating that I cannot even pass these sample tests on CW.

  • Phil157 Avatar

    A nice little problem - easy to time-out. Why not use "a" in place of "i" in your solution? :o) I think your description with "chooses two numbers, a and b" is quite clear, a and b are not the same number, jcolicchio. But what happened to n being "relatively small"?

  • jcolicchio Avatar

    The instructions seem ambiguous regarding whether or not you can select the same value for a and b. There are three interpretations I can come up with:

    1. (Remove a once) The sum of 1..n - a must be equal to aa In this case, (14, 14) is a solution for n=20, since 210 - 14 = 1414

    2. (Remove a twice) The sum of 1..n - a - a must be equal to aa In this case, (10, 10) is a solution for n=15, since 120 - 10 - 10 = 1010

    3. a and b must be distinct In this case, neither (10, 10) for n=15 nor (14, 14) for n=20 should be accepted as solutions

    Judging by the wording of the problem, I would assume interpretation 1, since the value a only shows up in 1..n once, we can only remove it from the series once, and (1..a-1) + (a+1..n) should be our target sum

    However, occasionally {a, a} shows up as a solution in the random trials, and the solution grader behaves consistently with interpretation 2. That is, the sum of 1..n - a - a must be equal to a*a

    I understand how this can be a valid interpretation mathematically, but I think the word problem framing this question leads to some ambiguity

  • dvbuntu Avatar

    This comment has been hidden.

  • kinluek Avatar

    argh i pass every test but apparently my code doesnt execute quick enough :(

  • Jomopipi Avatar

    O(n) enforcement made this fun :D

  • Daniel57910 Avatar

    This comment has been hidden.

  • jozefmak Avatar

    Hi. Im not sure if it's just some dumb problem on my side, but whenever I try to run the tests or attempt(Java), it throws this compilation error(even if there's just return null in the method):

    /home/codewarrior/src/main/java/RemovedNumbers.java:3: error: cannot find symbol public static List<long[]> removNb(long n) { ^ symbol: class List location: class RemovedNumbers

    Thanks.

  • mrkristin Avatar

    This comment has been hidden.

  • lbvf50mobile Avatar

    This comment has been hidden.

  • lbvf50mobile Avatar

    This comment has been hidden.

  • marrakchino Avatar

    STDERR: *** Error in `/home/codewarrior/solution': double free or corruption (out): 0x0000000001c5f620 ***

    (C) It's seems like a heap overflow, is this normal or am I missing something? (I only allocated the Pair to return)

  • Adrianval96 Avatar

    This comment has been hidden.