I need a Hexadecimal Number List [closed] - numbers

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need a script that generates all 65536 Hexadecimal numbers from 0000 to FFFF and puts them in a text file like this:
0000
0001
0002
0003
...
FFFF
I don`t care what programming language it is written in, but please not one that I have to run a web server (PHP) or that is Windows only.

#include<stdio.h>
int main(int argc, char** argv){
for(long i = 0x0; i <= 0xFFFF ; i++){
printf("%X\n", i);
}
return 0;
}

the core is a Python one liner :
a = [hex(x) for x in xrange(0,pow(2, 16))]
or
a = map(hex, xrange(pow(2,16)))
print A
the rest is slicing out 'oxd' and writing to your file ie
f = open('workfile.txt', 'w')
for x in a:
f.write(x[3:])

Related

How to compute the mean-square in Matlab? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to compute the square of mean-square for each element of l
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549,
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593,
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599,
-0.60809913]'
k= -0.2224834
sum(l-k)^2/22
I am not sure if sum(l-k)^2/22 is the sum of each (l[j]-k) for j=1,2,...,22?
ans = 2.4223e-14
I guess what you need might be
>> mean((l-k).^2)
ans = 0.10945
Data (You need ... for line continuation if you have data in different lines for l)
l=[0.02817088, -0.74100320, -0.54062120, -0.24612808, 0.06945337, -0.58415690, -0.51238549, ...
-0.07862326, -0.42417337, -0.33482340, -0.21339753, -0.03890844, -0.59325371, 0.28154593, ...
-0.32133359,-0.13534792, 0.14060645, 0.32204972, 0.44438052, -0.21750973,-0.59107599, ...
-0.60809913]'
k= -0.2224834

Display only some digits of an Int [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Let's say you have an Int.
let int = 12345
I want it to only display some of the digits.
For example: print(firstTwoDigits) --> 12
How do I do this and thank you in advance.
It depends on your specific requirements.
This prints the first two digits of an integer number
let intVal = 12345
print(String(intVal).prefix(2))
Output: 12
Another way which only prints certain ones in the number:
let intVal = 12345
let acceptableValues = ["1", "2"]
let result = String(intVal).filter {
acceptableValues.contains(String($0))
}
print(result)
Output: 12

What are my errors in the following code? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This is the function:
for (i = 0; i <= array.Length; i++) {
if (array[i].transform.position = 0)
array.RemoveAt(i);
print(“Removed element: “ + array[i].name);
else if (array[i].transform.position > 0)
array[i].transform.forward = Vector3(1,0,0);
}
I'm not sure if this is a valid question but there is for sure some logic errors :
First of all i'm not sure there is a RemoveAt(int index) for arrays
(but i'm not a big unityscript user) (there is for List though)
You should absolutely never (even if some weird languages maybe allow it to you) try to access an object you just deleted... which is what you try to do here :
array.RemoveAt(i);
print(“Removed element: “ + array[i].name);
Position is a Vector3 NOT a int or float so you cannot do : array[i].transform.position = 0
You should never use the = (assignment operator) in an if() you should use the == (comparison operator) (because = returns always true when assignment is possible)
That line is wrong for the same reason as before array[i].transform.position > 0
array[i].transform.forward = Vector3(1,0,0); Leaves me wondering because if it was C# i'd try the new keyword before Vector3() and i'd prefer floats that way :
array[i].transform.forward = new Vector3(1.0F,0,0); But even there Unity will throw you an error stating that you cannot modify components of Transform without making a copy first i believe...
But nice try :D
you can't compare a vector to 0 it needs to be like this
if(myObject.transform.position==Vector3.zero)
and for removing things I'd suggest to include System.Collections.generic lib
then use Listarray then you can use array.RemoveAt(index);

How to express the performance of loop & inner loop in big o notation? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
For below loop and inner loop to express the performance in big o notation is :
O(N squared) as its performance is proportional to the square of the size of the input data set.
var counter = 0
var counterval = 0;
for ((key, value) <- m2.par){
for ((key2, value2) <- m2.par){
counter = counter + 1;
println(counter)
}
println(counterval)
}
Is this correct ?
Yes, if you consider the size of m2 to be the input size and that increasing counter and printing it are both O(1) (which is a very reasonable assumption).

Trimming multiple columns in a file with perl [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to trim out this particular file and need just the highlighted portion as it contains the data. I have looked at some other scripts but they are written to remove columns of constant value.
The data is:
id=69 rna=**5_8S_rRNA** ntax=61
id=58 rna=**U1** ntax=100
id=56 rna=**U2** ntax=211
id=37 rna=**tRNA** ntax=967
id=75 rna=**Vault** ntax=75
id=53 rna=**RNaseP_nuc** ntax=117
id=57 rna=**RNaseP_bact_a** ntax=306
id=62 rna=**RNaseP_bact_b** ntax=114
id=41 rna=**U3** ntax=26
id=50 rna=**6S** ntax=154
id=84 rna=**DsrA** ntax=5
id=48 rna=**U4** ntax=178
id=46 rna=**SRP_euk_arch** ntax=102
id=46 rna=**U5** ntax=181
id=65 rna=**GcvB** ntax=26
id=71 rna=**Telomerase-vert** ntax=37
id=50 rna=**Telomerase-cil** ntax=20
id=49 rna=**U6** ntax=200
id=43 rna=**Intron_gpI** ntax=30
id=51 rna=**RNase_MRP** ntax=67
id=33 rna=**SECIS** ntax=61
id=90 rna=**Histone3** ntax=64
id=86 rna=**OxyS** ntax=5
id=98 rna=**RRE** ntax=65
id=54 rna=**IRE** ntax=39
id=73 rna=**rne5** ntax=6
id=88 rna=**snoR9** ntax=5
id=91 rna=**GlmZ_SraJ** ntax=21
id=77 rna=**HDV_ribozyme** ntax=33
id=72 rna=**U8** ntax=49
id=87 rna=**7SK** ntax=45
id=78 rna=**VA** ntax=54
id=79 rna=**RNAI** ntax=10
id=98 rna=**FinP** ntax=6
id=82 rna=**Vimentin3** ntax=19
id=74 rna=**S15** ntax=79
I simply wish to keep the items in asterisks, everything else has to go.
If this is on a Linux system, this Perl one-liner will produce the result you require.
perl -ne '/rna=(\S+)/ and print "$1\n"' myfile
If you are on Windows, use
perl -ne "/rna=(\S+)/ and print qq($1\n)" myfile
output
5_8S_rRNA
U1
U2
tRNA
Vault
RNaseP_nuc
RNaseP_bact_a
RNaseP_bact_b
U3
6S
DsrA
U4
SRP_euk_arch
U5
GcvB
Telomerase-vert
Telomerase-cil
U6
Intron_gpI
RNase_MRP
SECIS
Histone3
OxyS
RRE
IRE
rne5
snoR9
GlmZ_SraJ
HDV_ribozyme
U8
7SK
VA
RNAI
FinP
Vimentin3
S15