How read array input in hackerearth or techgig rhinojs editor?
Please help me to read array of inputs in rhinojs.
you didn't mention which programming language you are using.In python programming language it is very easy to get the array input
CODE:
p=list(map(int,input().split()))
Related
I am beginner in Pandoc and Lua who is experimenting with converting Word documents to Markdown. I want to convert chapter headings in Word to paragraph of text in Markdown. Furthermore, I want to insert some text before and after the chapter headings.
To achieve that, I used the following lua filter (sample.lua)
function Header(el)
if el.level == 1 then
return {"something before (",el.content,") something after"}
end
end
after which I performed the conversion using
pandoc --lua-filter=sample.lua -s file.docx -t markdown -o file.txt
where file.docx is just minimal example document containing one chapter heading. However, using this filter, I obtained
something before (
Chapter title
) something after
What I want to get, however, is
something before (Chapter title) something after
but since (if I am not mistaken) el.content is inline element, there are linebreaks around it. I tried to solve this problem by using pandoc documentation and various lua functions, but to no avail, which is why I would kindly ask for help.
Try this instead:
function Header(el)
if el.level == 1 then
return {{"something before ("} .. el.content .. {") something after"}}
end
end
The reason is that el.content is a list of inline elements, and it can be be extended by concatenating lists with additional content. The operator .. is the concatenation operator; it works with strings and pandoc lists.
Hope you can help me, I am a bit of a newbie and have progressed without needing help but now I am stuck.
Firstly could somebody please tell me what this is below, I think it is ASCII but maybe wrong???
"\0\u{01}\0\0\0\u{1E}\0\0\u{02}\u{06}\0ÿ\0\0\0\0\0\u{02}.\u{01}(\0\t\0ü\0\u{07}\0\u{04}"
Secondly how would I convert this to an NSArray so I could get iterate through it and get a value at a given location in the array?
I am using Swift
Many thanks in advance
Charles
As mentioned above, your string looks quite weird, and the \u{xx} values tell Swift to replace that part with the unicode character corresponding to hexadecimal value xx (see unicode-table).
I do not know why you would want to convert it to the Objective-C type NSArray while you could just use the Swift type Array. By that, I mean you can generate an array of the string by using var strArray = Array(str), where your string is stored in str. From that point on, you can use the following code to iterate over the contents of the string:
for var char in strArray {
//do something with char
}
char then loops through all indices of the strArray, holding the value at the current index.
I am using DDMathParser to parse the string expressions. I am working on one expression which is "(2+x)6+2x+2y=5y+2x", I am trying to parse it and evaluate it using DDMathParser. It can be considered as first degree function that I need to solve using Objective C.
Guys any ideas?
Help would be highly appreciated.
DDExpression * e = [DDExpression expressionFromString:expression error:error];
NSNumber *num = [e evaluateWithSubstitutions:substitutions evaluator:nil error:error];
I don't know much about DDMathParser (OK, I don't know anything about it), but taking a look at the documentation gives some clues about what is going wrong with your code.
Based on the documentation, I could find not example of where DDMathParser could handle symbolic expressions. All of the examples on the Usage page show numeric expressions.
For symbolic math, see Symbolic Math Library in C/C++/Obj-C .
In addition, it looks like you are trying to solve for two variables with a single equation, which is certainly not going to result in a numeric solution.
However, if you are just trying to substitute values in for x and y, you should use the $ sign before them as the documentation says:
If you don't know what the value of a particular term should be when
the string is constructed, that's ok; simply use a variable:
NSString *math = #"6 * $a";
So if you just want to substitute values in your expression, try using:
string expression = #"(2+$x)6+2*$x+2*$y";
Then fill in with values.
NSDictionary *s = #{#"x" : 42, #"y" : 43};
And evaluate.
DDMathEvaluator *eval = [DDMathEvaluator sharedMathEvaluator];
NSLog(#"%#", [eval evaluateString:expression withSubstitutions:s]);
I have a text file which read:
config<001>25
23<220>12
.....
how can i parse so that i need only the values config,001(to be converted into integer after extracting using strtok or any ohter methods please suggest), and 25(to be converted into integer) seperately. i tries strtok its not working as the way i need. Please help me.
Use LINQ 2 SQL to import the file on the delimiters and then use something like AutoMapper to do the mapping of fields to say specific objects with specific types.
I did this exact thing in another project and it works great.
Based on the mention of strtok I'm guessing that you're using C or C++. If you're using C++, I'd probably handle this by creating a ctype facet that treats < and > as white space, which will make the parsing trivial (infile >> string >> number1 >> number2;).
If you're using C, you can use the scan-set conversion with scanf, something like: sscanf(line, "%[^<] %d> %d", string, &number1, &number2);
guess its getting late, and Im a beginner, just need a little help..
Im trying to find the length of a list.. BUT NOT of the lists themselves, rather the length of the values within..
I take something like:
Other = [<<"366">>,0,
<<1>>,
<<"344">>,<<"Really"
<<1>>,
<<"989">>,<<"NotReally">>
<<1>>,
<<"345">>,4,
<<1>>,
<<"155">>,"209.191"]
I would really want to first convert Other into its RAW constituent binary
Example:
Other = [<<3>>,<<4>>,<<7>>,<<56>>,<<45>>,<<56>>...]
This, of course, is an example of way the original Other would look like(Not right conversion values). So that all of the values in there are there most basic binary data.
Then I could simply iterate through counting each <<_>> and determining the total message length.
Hope I was clear enough to find a solution.
Thanks all for the help, GN
iolist_size/1 is what you are looking for.
1> iolist_size([<<"366">>,0,<<1>>,<<"344">>,<<"Really">>,<<1>>,<<"989">>,<<"NotReally">>,<<1>>,<<"345">>,4,<<1>>,<<"155">>,"209.191"]).
43
2> v(1) - 1.
42
P.S.: Why your example data have this one surplus character? ;-)
If all you're trying to do is find the length of the entire structure, I'd try something like this:
my_length(X) when is_integer(X) -> 1;
my_length(X) when is_binary(X) -> erlang:size(X);
my_length(Lst) when is_list(Lst) ->
lists:sum([my_length(X) || X <- Lst]).
If you really want to build a flat version of your structure, then erlang:list_to_binary gets you pretty close to what you need, then just call size on that. (Actually, this may be better than my first attempt.)
1> erlang:list_to_binary([<<"366">>,0,<<"155">>,"209.191"]).
<<51,54,54,0,49,53,53,50,48,57,46,49,57,49>>