New answers tagged

0 votes

C++ custom string class implementation

The interface of your class is fine: you are following the rule 5; that means you have the 5 big special functions: Destructor Copy constructor Copy assignment operator Move constructor Move ...
Red.Wave's user avatar
  • 146
1 vote
Accepted

Redouble each occurrence of char recursively, and add n

You can calculate the number of doublings instead of looking it up in a map. The code below is otherwise copied from @Roman's answer. ...
Rainer P.'s user avatar
  • 2,622
0 votes

Redouble each occurrence of char recursively, and add n

You can simplify the calculation of the number of doubling operations using a mathematical formula instead of the pre-calculated map. ...
Mikael Stray Frøyshov's user avatar
1 vote

Concatenating optional strings in Scala

Options can be concatenated to get an Iterable, which then makes things easier... ...
Martin Stone's user avatar
1 vote

Redouble each occurrence of char recursively, and add n

Nested If-Statements You can simplify the code and improve the readability as a result. It is achievable by using the Guard Pattern which in short can break off nested if-statements by inverting the ...
Roman's user avatar
  • 2,783
1 vote
Accepted

String represents a road. One character travels on the road obeying the stops - Code challenge (advent.js day 5)

carefully read the requirements The original problem asks us to Create a function that simulates the sled's movement ... Somehow you leapt from that to All must be in just one function. I see no ...
J_H's user avatar
  • 17.1k
2 votes

Convert camelCase and PascalCase to Title Case

Instead of writing and maintaining this function, one could use this publicly available package: to-case. Sample usage: ...
Lydia Stepanek's user avatar
3 votes
Accepted

Image file uploader webpage in HTML5 and PHP

Back end code Add file type checking As this comment on PHP.net mentions: A note of security: Don't ever trust $_FILES["image"]["type"]. It takes whatever is sent from the browser,...
Sᴀᴍ Onᴇᴌᴀ's user avatar

Top 50 recent answers are included