create this array - arrays
i know this sounds silly, but can someone please post the arrays described by rfc2612:
Cm = 0x5A827999
Mm = 0x6ED9EBA1
Cr = 19
Mr = 17
for (i=0; i<24; i++)
{
for (j=0; j<8; j++)
{
Tmj_(i) = Cm
Cm = (Cm + Mm) mod 2**32
Trj_(i) = Cr
Cr = (Cr + Mr) mod 32
}
}
i think im doing is wrong for some reason
i get this for Tr
[[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2],
[10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2]]
Tr0 = { 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11, 19, 27, 3, 11 }
Tr1 = { 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28, 4, 12, 20, 28 }
Tr2 = { 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13, 21, 29, 5, 13 }
Tr3 = { 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30, 6, 14, 22, 30 }
Tr4 = { 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15, 23, 31, 7, 15 }
Tr5 = { 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0, 8, 16, 24, 0 }
Tr6 = { 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17, 25, 1, 9, 17 }
Tr7 = { 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2, 10, 18, 26, 2 }
..and Tm (in hex):
Tm0 = { 5a827999, d151d6a1, 482133a9, bef090b1, 35bfedb9, ac8f4ac1, 235ea7c9, 9a2e04d1, 10fd61d9, 87ccbee1, fe9c1be9, 756b78f1, ec3ad5f9, 630a3301, d9d99009, 50a8ed11, c7784a19, 3e47a721, b5170429, 2be66131, a2b5be39, 19851b41, 90547849, 723d551 }
Tm1 = { c95c653a, 402bc242, b6fb1f4a, 2dca7c52, a499d95a, 1b693662, 9238936a, 907f072, 7fd74d7a, f6a6aa82, 6d76078a, e4456492, 5b14c19a, d1e41ea2, 48b37baa, bf82d8b2, 365235ba, ad2192c2, 23f0efca, 9ac04cd2, 118fa9da, 885f06e2, ff2e63ea, 75fdc0f2 }
Tm2 = { 383650db, af05ade3, 25d50aeb, 9ca467f3, 1373c4fb, 8a432203, 1127f0b, 77e1dc13, eeb1391b, 65809623, dc4ff32b, 531f5033, c9eead3b, 40be0a43, b78d674b, 2e5cc453, a52c215b, 1bfb7e63, 92cadb6b, 99a3873, 8069957b, f738f283, 6e084f8b, e4d7ac93 }
Tm3 = { a7103c7c, 1ddf9984, 94aef68c, b7e5394, 824db09c, f91d0da4, 6fec6aac, e6bbc7b4, 5d8b24bc, d45a81c4, 4b29decc, c1f93bd4, 38c898dc, af97f5e4, 266752ec, 9d36aff4, 14060cfc, 8ad56a04, 1a4c70c, 78742414, ef43811c, 6612de24, dce23b2c, 53b19834 }
Tm4 = { 15ea281d, 8cb98525, 388e22d, 7a583f35, f1279c3d, 67f6f945, dec6564d, 5595b355, cc65105d, 43346d65, ba03ca6d, 30d32775, a7a2847d, 1e71e185, 95413e8d, c109b95, 82dff89d, f9af55a5, 707eb2ad, e74e0fb5, 5e1d6cbd, d4ecc9c5, 4bbc26cd, c28b83d5 }
Tm5 = { 84c413be, fb9370c6, 7262cdce, e9322ad6, 600187de, d6d0e4e6, 4da041ee, c46f9ef6, 3b3efbfe, b20e5906, 28ddb60e, 9fad1316, 167c701e, 8d4bcd26, 41b2a2e, 7aea8736, f1b9e43e, 68894146, df589e4e, 5627fb56, ccf7585e, 43c6b566, ba96126e, 31656f76 }
Tm6 = { f39dff5f, 6a6d5c67, e13cb96f, 580c1677, cedb737f, 45aad087, bc7a2d8f, 33498a97, aa18e79f, 20e844a7, 97b7a1af, e86feb7, 85565bbf, fc25b8c7, 72f515cf, e9c472d7, 6093cfdf, d7632ce7, 4e3289ef, c501e6f7, 3bd143ff, b2a0a107, 296ffe0f, a03f5b17 }
Tm7 = { 6277eb00, d9474808, 5016a510, c6e60218, 3db55f20, b484bc28, 2b541930, a2237638, 18f2d340, 8fc23048, 6918d50, 7d60ea58, f4304760, 6affa468, e1cf0170, 589e5e78, cf6dbb80, 463d1888, bd0c7590, 33dbd298, aaab2fa0, 217a8ca8, 9849e9b0, f1946b8 }
(I'm not sure why they didn't just include these as tables in the spec).
Related
How to remove the error values by replacing them?
I have an array with values collected from a sensor. However, once in a while, the sensor returns an error value. I want to replace these values by interpolating them using the closest values in the array. How can I do that easily, considering I can have several error values consecutively? sensor = [20, 21, 22, 21, 8190, 20, 19, 20, 21, 22, 23, 24, 8190, 8190, 25, 21, 8190] I want to have this: sensor = [20, 21, 22, 21, 20.5, 20, 19, 20, 21, 22, 23, 24, 24.5, 24.5, 25, 21, 21]
You can just do something like const sensor = [20, 21, 22, 21, 8190, 20, 19, 20, 21, 22, 23, 24, 8190, 8190, 25, 21, 8190] //create a new array and variable let arr=[] let currentNum //iterate over the old array sensor.forEach(element =>{ if(element!==8190){ arr.push(element) currentNum=element }else{ currentNum=currentNum+.5 arr.push(currentNum) } }); console.log(arr)
Setting up a list of indexed variables in C
I'm trying to set up a 320x240 "room" in a game. I want to use a list of 16x16 tiles. Each tile is a predefined list, consisting of the each pixel's color. extern char blue27tile[] ={ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55}; extern char grey10tile[] ={ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17}; So above would be my tile definitions. Ignore that they're all just blocks of one color, that would change in the future. My question is how to set up the same array/list for the room? I was thinking a room like: extern int testroom1[] ={ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; where "1" refers to the grey10tile and "0" refers to the blue27tile. I would correspond numbers to the variables with something like: extern int *tilelist[2]; tilelist[0] = &blue27tile; tilelist[1] = &grey10tile; but this gives me a "typemismatch in redeclaration of tilelist" error. I know this is a simple question, I don't know C and am trying to learn with this project. I can't describe the problem well enough to find a solution by googling. If this was python, I would just do something like tilelist[0] = [17,17,17,...] //all of my grey10tile 17s tilelist[1] = [55,55,55,...] //all of my blue27tile 55s tilelist[0][1] -> 17 //the first of my grey10tile 17s How can I set this up to do something similar in C? Thanks a ton.
You cannot place statements outside of functions in C. At global scope only declarations are allowed. tilelist[0] = &blue27tile; is a statement, for example. Try: char *tilelist[] = { blue27tile, grey10tile };
Split string to a 2-dimensional array in Scala
In Scala: Is there a way to directly split a string that contains 72 numeric values separated by ; into a 2-dimensional array of 9 rows and 8 columns with those numeric values -in numeric data type-?
val input = List.tabulate(72)(_.toString).mkString(";") input.split(";").map(_.toInt).grouped(9).toArray transforms 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40;41;42;43;44;45;46;47;48;49;50;51;52;53;54;55;56;57;58;59;60;61;62;63;64;65;66;67;68;69;70;71 into Array( Array(0, 1, 2, 3, 4, 5, 6, 7, 8), Array(9, 10, 11, 12, 13, 14, 15, 16, 17), Array(18, 19, 20, 21, 22, 23, 24, 25, 26), Array(27, 28, 29, 30, 31, 32, 33, 34, 35), Array(36, 37, 38, 39, 40, 41, 42, 43, 44), Array(45, 46, 47, 48, 49, 50, 51, 52, 53), Array(54, 55, 56, 57, 58, 59, 60, 61, 62), Array(63, 64, 65, 66, 67, 68, 69, 70, 71) ) If you want to swap the dimensions of rows/columns, replace 9 by 8.
using Range and grouped functions scala> val a = (0 to 71).map(_.toString).toArray.mkString(";") a: String = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40;41;42;43;44;45;46;47;48;49;50;51;52;53;54;55;56;57;58;59;60;61;62;63;64;65;66;67;68;69;70;71 scala> a.split(";").map(_.toInt).sliding(9,9).toArray res269: Array[Array[Int]] = Array(Array(0, 1, 2, 3, 4, 5, 6, 7, 8), Array(9, 10, 11, 12, 13, 14, 15, 16, 17), Array(18, 19, 20, 21, 22, 23, 24, 25, 26), Array(27, 28, 29, 30, 31, 32, 33, 34, 35), Array(36, 37, 38, 39, 40, 41, 42, 43, 44), Array(45, 46, 47, 48, 49, 50, 51, 52, 53), Array(54, 55, 56, 57, 58, 59, 60, 61, 62), Array(63, 64, 65, 66, 67, 68, 69, 70, 71)) scala>
Swift 4 Sorting Multidimensional array
Very new to Swift I have a multidimensional array of some 500 records [10, 2, 4, 10, 23, 56] [0, 12, 14, 20, 28, 42] [0, 2, 4, 10, 26, 54] [1, 24, 34, 40, 47, 51] [1, 23, 24, 30, 33, 50] so that I would have [0, 2, 4, 10, 26, 54] [0, 12, 14, 20, 28, 42] [1, 23, 24, 30, 33, 50] [1, 24, 34, 40, 47, 51] [10, 2, 4, 10, 23, 56] I am fine for the individual record sort. But when looking at the 500 records, to sort the records for the first column I used arr.sort { $0[0] < $1[0] }. which worked fine, I need to extend that to columns 2,3,4,5,6. I want to be able to sort on Column 1 then by 2, by 3, by 4, by 5, by 6.
Assuming that all subarrays contains 6 elements you can use a tuple (which conforms to Comparable to an arity of 6) to sort your array: let array = [[10, 2, 4, 10, 23, 56], [0, 12, 14, 20, 28, 42], [0, 2, 4, 10, 26, 54], [1, 24, 34, 40, 47, 51], [1, 23, 24, 30, 33, 50]] let sorted = array.sorted(by: { ($0[0],$0[1],$0[2],$0[3],$0[4],$0[5]) < ($1[0],$1[1],$1[2],$1[3],$1[4],$1[5]) }) print(sorted) // [[0, 2, 4, 10, 26, 54], // [0, 12, 14, 20, 28, 42], // [1, 23, 24, 30, 33, 50], // [1, 24, 34, 40, 47, 51], // [10, 2, 4, 10, 23, 56]]
C# setting new values to array
How can I rewrite all values in array? For example I have array: int[] polyX = { -22, 21, 166, 174, 106, 33, 20, 14, -30, -19, -24 }; And now I want to set these values: polyX = { -43, 5, 23, 65, -64, 33, 4, 14, -30}; Is it possible to set new values to arrays like to any other variable?
There's a syntax error in your second line. It should actually be: polyX = new[] { -43, 5, 23, 65, -64, 33, 4, 14, -30, -3, -321};