[Solved] Class toggle in jQuery

Fix the toggleClass call, you only need the class name, not the selector: toggleClass(‘over’) instead of toggleClass(‘p.over’). Then, you have two opening script tags: <script type=”text/javascript” language=”javascript”> <script> Remove the first one. Next, you’re binding an event listener to an element that’s not in the DOM yet at the time the script executes. Simple fix: … Read more

[Solved] C++ Functions run no matter input

Your if statements have more entries then a teenage girls phone. 🙂 You should invest in some structures, containers and loops. For example: const static std::string question_words[] = {“am”, “are”, “can”, “did”, “could”, “do”, “does”}; const static unsigned int word_quantity = sizeof(question_words) / sizeof(question_words[0]); //… bool is_question = false; for (unsigned int i = 0; … Read more

[Solved] Find next Aloha Number

Despite my comment above, I wondered about the “time and space complexity”. It turned out to be trivial; this only takes 3 long integer variables and a single loop over each input digit (which can be incremented by this algorithm to use 1 more digit; and this will not cause an integer overflow). Starting from … Read more

[Solved] Java replace with regex [closed]

It is as simple as: “The Shawshank’s Redemption”.replaceAll(“\\S”, ” _”); We replace all non white-space characters \S with an underscore followed by a space. This would automatically make what is a space originally, 2 spaces. Note that a trailing space will be produced. 2 solved Java replace with regex [closed]

[Solved] HTML CSS layout pushing elements down the page [closed]

As usual, Flexbox is our lord and saviour. Here’s your layout made with Flex. .container { width: 500px; height: 250px; display: flex; border: #00f solid 2px; } .container .side { border: #ff0 dashed 3px; flex-basis: 33%; flex-shrink: 0; /* Prevents shrinking if .four grows */ display: flex; flex-direction: column; justify-content: space-between; /* Ensures perfect spacing … Read more

[Solved] Default method parameters [closed]

In c# 4 and above you can specify default values for parameters, so it’s not necessary to specify them at the call site: public void DoIt(string text = “”) { //do something with text //do other things } and then you can call it either passing a parameter, like this: DoIt(“parameterValue”); or without passing a … Read more

[Solved] pattern drawing programming logic [closed]

A C++ implementation : Without any formatting void print(int n) { for(int i=n, cl=1, cr=n*n+1; i>0; cl+=i, –i, cr-=i) { for(int j=0; j<i; ++j) cout << cl+j; for(int j=0; j<i; ++j) cout << cr+j; cout << endl; } } With dashes and stars void print(int n) { for(int i=n, cl=1, cr=n*n+1; i>0; cl+=i, –i, cr-=i) … Read more