What are these ? ه҈҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉ [closed] - string

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
These "characters" seem interesting. What are they?I would like to know more technical information about them. Thanks!
ه҈҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉ ه҈҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉ ه҈҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉҉

It's just a mass of combining marks. That alone is like 170 Combining Marks. You can do all sorts of weird rendering effects just by using a ton of combining marks together. But in this case just U+0489 COMBINING CYRILLIC MILLIONS SIGN is used.
Combining marks are not stand alone characters by themselves, but modify the previous base letter. For example a, a combining diaeresis ¨ renders as ä instead of a¨. Put more combining marks in there, and they all have to somehow render with the base character a, causing interesting rendering effect.
Code in the jsfiddle (SO didn't allow me to post otherwise):
var l = 1000;
var str = ":"
while(l--) {
str += String.fromCharCode(0x300 + Math.floor((Math.random() * 0x20)))
}
document.write(str);

Those are unicode characters that belong to another character set/language (in this case, Cyrillic). This information can be seen (on Windows) by using the Character Map tool, which is found in the Programs -> Accessories folder of the Start Menu.

Related

Where is this used in programming -->(') [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I thinking of mapping single quotation mark to double quotation mark i.e ' -> " in my vimrc.
Besides declaring chars in C, where is ' is used in programming?
Should I map it?
I'll reverse map them to access both.
Single quotes are used all over the place in programming.
In the Bourne shell (and derivatives, and csh and derivatives, and Perl and other languages) it is used to inhibit string exansion, so you can do this:
$ echo '$VARIABLE'
$VARIABLE
In C, the single quote is used to denote a character constant, rather than a string. So you can do this:
char c = 'c';
But this is an error:
char c = "c";
And of course if you are programming in a language called "English", the single quote is used to denote important things like possessives ("snihalani's question seemed sort of odd) as well as contractions ("I can't believe anyone would want to do this.").
These are just a few examples. There are, of course, more.
I use single quotes almost exclusively. They're useful when you're using double quotes inside of strings:
print 'Foo said, "Bar"'
It's easier than escaping them:
print "Foo said, \"Bar\""
Also, you won't be able to type normal sentences with possessives either:
# Attaches foo's signal to a slot
self.foo.bar.connect(self.baz)
PHP, for instance, doesn't perform variable substitution when strings are quoted with single quotes:
$var = 1;
echo('I will literally print $var');
In many languages (e.g., C, C++, Ada), ' delimits character literals and " delimits string literals.
In others (e.g., Perl, Bourne shell), either ' or " can be used for string literals, but with different semantics; " is handy when the string contains ' characters, and vice versa, and " causes references to variables to be expanded to the name of the variable, while ' prevents this.
Ada uses ' to delimit the name of an attribute.
And in all languages, you'll need ' in comments and string literals -- for example if you want to write "you'll need ' in comments and string literals".
They're distinct characters. Removing your ability to type one of them is Not A Good Idea.
You might consider mapping ' to " and vice versa, if that makes typing easier for you. But once you get into the habit of using your mappings, it could be awkward to use somebody else's setup, or to type text into something other than vim.

Searching for a "needle" in a two dimnesional "haystack" [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I guess this is one of the most commonly asked interview questions, yet I am unable to solve it in an efficient way(efficient meaning lesser time complexity and use of a suitable Data Structure).
The problem is this way:
If there is a m x n matrix of chars (say haystack) and a given char string of length k (the needle) . Write a program to check if the haystack contains the needle. Please note that we need to search the haystack only top to down or left to right.
For example
Haystack
ahydsfd
sdflddl
dfdfd
dfdl
uifddffdhc
Needle:
hdffi
Output:
Yes Found!!
The naive bruteforce is O(m*n*k). Here are some ideas for optimization.
Single Search
Instead of doing a search for horizontals and then another for verticals, do both simultaneously. Every time you find an occurrence of the first letter of the needle look for a horizontal and a vertical match starting at that letter. This won't improve the time complexity, but could halve the time since you'll only look at bad starts once.
Rare Letters
Instead of looking for the first letter of the needle, look for the rarest letter which occurs in the needle. This could rule out a lot of the possible matches quickly (though it won't improve the worst-case time complexity). To determine which letters are rarest either scan through the entire board or use random sampling.
Efficient String Searching Algorithm
String searching is a well-studied problem and there are several linear-time algorithms such as Knuth–Morris–Pratt and Boyer–Moore. Using a linear-time string searching algorithm to search each each row and each column reduces the time complexity to O(m*n). This is probably what the interviewers are after.
Exploit Short Rows
I notice that not all rows have the same length. When you look for vertical matches, you can stop searching on that row as soon as the needle 'pops out' of the sack, since all needles further along the row will also exit the sack and therefore cannot match.
The brute force method will have worst time complexity of m*n.That is if needle is single character and we start parsing matrix row wise or column wise.
You can restrict the search of the first char to n-k columns and m-k rows. Once found, 2(k-1) would comparisons are required for the answer.

Matching a line to a rule in c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have a line and a set of rules (other lines). Line to match (line = rule) may be very long; set of rules may be large and each rule may be long. Shorter rules may be part of longer (need to choose longer).
Currently, I have about 70 rules, <30 characters long, organized in a long if-else-if chain.
Is there any way to predict at what point there will be decrease in performance?
Is there a faster way of matching that comparing line with each of the rules?
Edit: There are no text files. I have an encoded sequence of characters, I go through if-elses comparing to "rules", and then act accordingly.
If you want to just check whether the input line is equal to any of the lines rules, then use an std::set (or std::map, if you want different behavior per rule) to store them. That takes the matching complexity down to O(lg N) where N is the number of rules.
Better yet, use an unordered_set (C++11) for O(1) performance.
If the behavior does not depend on which rule matched, then you can also compile a regular expression from the rules (e.g. (niVVVd__xniVVd__)|(niVVVdxniVVd)) with a tool like RE2 to get worst-case O(n) behavior, where n is the length of the input string.
Since you're comparing for equality, you don't need to match the longest rule first.

Is there any case where you must use ++var? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
The question is whether there is a situation where you can not use var++ and must use ++var (or the other way around).
That is, as far as I know, the only reason to use ++var over var++ (or the other way around) is to save space.
The question is, can we just have only the var++ abillity and not lose anything in the language's power?
You have to use ++var if you're using the expression within a bigger expression, and you definitely want the value of the expression to be the incremented one. For example, in C#:
int foo = 0;
foreach (var x in someCollection)
{
Console.WriteLine("{0}: {1}", x, ++foo);
}
Of course you could change this to use foo++ in a separate statement, but that isn't always feasible:
int foo = 0;
Expression<Func<int>> expression = () => ++foo;
That will return 1 the first time you call it, and you can't convert statement lambdas to expression trees.

Realworld example of when struct can be used [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 13 years ago.
Can anyone provide a realworld example of when a struct can be used?
A struct can be used when you have a complex return type for a method. i.e. you have to return several values, and they don't really warrant a full class's overhead.
A struct is notion of a record, a datatype that aggregates a fixed set of labelled objects, possibly of different types, into a single object. Structs are often used to group and relate objects in some manner.
If you mean a C struct, a great example is fixed scalar types in compilers. For example:
struct myScalar {
void *payload;
size_t psz;
unsigned int refs;
enum {
S_STR,
S_INT,
S_FLOAT,
S_OBJECT_INSTANCE
}type;
};
Or a union could be used. Not a robust example, but you get the idea. You can then do
switch(aVar.type){ ... }
Structs are great for helping you parse data that has been compressed to bits for sending over "The wire". You might have a bunch of bitfields to fill out a single byte, and a struct is a way to lay a template over this scrambled pile of variables and, without any real effort, change it into a collection of usable, easily referenced variables.

Resources