I was wondering if there is a faster way to randomly choose a value from a list and deleting this value from this list so it cannot be chosen again. This drawing of a value will continue until there aint no values left anymore.
The way I did it soved the problem but it takes almost 8 seconds. So I'm wondering if there is a faster way. I am using Jupyter notebook through the Anaconda software. Since this goes through a server, could it be the problem?
This is what I did:
TotalNumbcol = 266
Column_Numbers = list(np.arange(1,TotalNumbcol+1,1)) # creating a list with all column numbers in it from which can be drawn.
#print Column_Numbers
ABC = Column_Numbers # Creating a variable for the len command in the for loop below, since the Column Numbers length will change.
Chosen_Columns = [[0] for i in range(0,len(Column_Numbers))]
for i in range(len(ABC)):
RandChoiceCol = int(random.choice(Column_Numbers)) # chosing a random number from the Column_Numbers range
Chosen_Columns[i]=(RandChoiceCol) # adding each randomly chosen column number to a list in list showing which column has been chosen.
Column_Numbers = [x for x in Column_Numbers if x not in Chosen_Columns] # delete chosen_column from RandChoiceCol
print Chosen_Columns
print Column_Numbers
[21, 131, 145, 218, 153, 60, 201, 15, 158, 189, 230, 210, 18, 103, 69, 76, 226, 180, 67, 187, 238, 20, 157, 24, 48, 11, 47, 117, 101, 51, 122, 155, 109, 225, 86, 243, 146, 30, 58, 7, 66, 132, 22, 110, 1, 142, 234, 245, 266, 129, 232, 39, 184, 49, 114, 182, 162, 144, 92, 126, 5, 254, 150, 102, 135, 173, 36, 52, 42, 26, 228, 63, 17, 8, 163, 40, 78, 174, 222, 205, 183, 140, 221, 70, 125, 72, 247, 237, 64, 246, 185, 130, 248, 90, 197, 53, 107, 77, 108, 256, 207, 139, 176, 192, 2, 164, 4, 124, 241, 113, 188, 178, 235, 265, 190, 212, 99, 175, 79, 231, 257, 202, 50, 242, 181, 46, 161, 133, 104, 28, 251, 213, 204, 59, 149, 252, 179, 43, 137, 195, 160, 220, 119, 74, 87, 255, 98, 208, 105, 239, 170, 203, 167, 136, 250, 134, 32, 165, 229, 9, 258, 13, 141, 240, 262, 34, 227, 148, 41, 111, 54, 71, 61, 94, 249, 29, 75, 10, 193, 152, 73, 123, 65, 6, 116, 68, 91, 56, 25, 233, 156, 261, 35, 171, 211, 215, 186, 154, 138, 200, 44, 112, 57, 166, 120, 147, 89, 31, 106, 118, 199, 198, 81, 223, 83, 12, 214, 45, 121, 244, 95, 168, 55, 37, 206, 263, 93, 196, 115, 169, 217, 236, 82, 143, 96, 33, 209, 14, 100, 216, 128, 259, 219, 151, 16, 177, 159, 23, 38, 84, 80, 27, 19, 264, 62, 85, 127, 97, 224, 172, 191, 88, 253, 3, 260, 194]
[]
If there is a more efficient way saving time please let me know.
Regards,
You may just shuffle the list in place instead of creating a new list and a new number every time:
Column_Numbers = list(np.arange(1,TotalNumbcol+1,1))
random.shuffle(Column_Numbers)
while Column_Numbers:
rand = Column_Numbers.pop()
print(rand)
I am trying to process some data and write the output in such a way that the result is partitioned by a key, and is sorted by another parameter- say ASC. For example,
>>> data =sc.parallelize(range(10000))
>>> mapped = data.map(lambda x: (x%2,x))
>>> grouped = mapped.groupByKey().partitionBy(2).map(lambda x: x[1] ).saveAsTextFile("mymr-output")
$ hadoop fs -cat mymr-output/part-00000 |cut -c1-1000
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420,
$ hadoop fs -cat mymr-output/part-00001 |cut -c1-1000
[2049, 2051, 2053, 2055, 2057, 2059, 2061, 2063, 2065, 2067, 2069, 2071, 2073, 2075, 2077, 2079, 2081, 2083, 2085, 2087, 2089, 2091, 2093, 2095, 2097, 2099, 2101, 2103, 2105, 2107, 2109, 2111, 2113, 2115, 2117, 2119, 2121, 2123, 2125, 2127, 2129, 2131, 2133, 2135, 2137, 2139, 2141, 2143, 2145, 2147, 2149, 2151, 2153, 2155, 2157, 2159, 2161, 2163, 2165, 2167, 2169, 2171, 2173, 2175, 2177, 2179, 2181, 2183, 2185, 2187, 2189, 2191, 2193, 2195, 2197, 2199, 2201, 2203, 2205, 2207, 2209, 2211, 2213, 2215, 2217, 2219, 2221, 2223, 2225, 2227, 2229, 2231, 2233, 2235, 2237, 2239, 2241, 2243, 2245, 2247, 2249, 2251, 2253, 2255, 2257, 2259, 2261, 2263, 2265, 2267, 2269, 2271, 2273, 2275, 2277, 2279, 2281, 2283, 2285, 2287, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 2305, 2307, 2309, 2311, 2313, 2315, 2317, 2319, 2321, 2323, 2325, 2327, 2329, 2331, 2333, 2335, 2337, 2339, 2341, 2343, 2345, 2347, 2349, 2351, 2353, 2355, 2357, 2359, 2361, 2363, 2365, 2367, 2369, 2371, 2373, 2375, 2377, 2379, 238
$
Which is perfect- satisfies my first criteria, which is to have results partitioned by key. But I want the result sorted. I tried sorted(), but it didn't work.
>>> grouped= sorted(mapped.groupByKey().partitionBy(2).map(lambda x: x[1] ))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'PipelinedRDD' object is not iterable
I don't want to use parallelize again, and go recursive. Any help would be greatly appreciated.
PS: I did go through this: Does groupByKey in Spark preserve the original order? but it didn't help.
Thanks,
Jeevan.
Yes, that's an RDD, not a Python object that you can sort as if it's a local collection. After groupByKey() though, the value in each key-value tuple is a collection of numbers, and that is what you want to sort? You can use mapValues() which called sorted() on its argument.
I realize it's a toy example but be careful with groupByKey as it has to get all values for a key in memory. Also it is not even necessarily guaranteed that an RDD with 2 elements, and 2 partitions, means 1 goes in each partition. It's probable but not guarnateed.
PS you should be able to replace map(lambda x: x[1]) with values(). It may be faster.
Similar to what is said above the value in key-value is an RDD collection; you can test this by checking type(value). However, you can access a python list via the member .data and call sort or sorted on that.
grouped = mapped.groupByKey().partitionBy(2).map(lambda x: sorted(x[1].data) )
I've got this piece of coding which, when displayed in Firefox or Chrome, throws an exception (the image cannot be displayed because it contains errors).
byte[] img2 = { 105, 86, 66, 79, 82, 119, 48, 75, 71, 103, 111, 65, 65, 65, 65, 78, 83, 85, 104, 69, 85, 103,
65, 65, 65, 68, 65, 65, 65, 65, 65, 101, 67, 65, 89, 65, 65, 65, 66, 113, 112, 74, 51, 66, 65, 65, 65,
65, 71, 88, 82, 70, 87, 72, 82, 84, 98, 50, 90, 48, 100, 50, 70, 121, 90, 81, 66, 66, 90, 71, 57, 105,
90, 83, 66, 74, 98, 87, 70, 110, 90, 86, 74, 108, 89, 87, 82, 53, 99, 99, 108, 108, 80, 65, 65, 65, 65,
50, 112, 74, 82, 69, 70, 85, 101, 78, 114, 115, 87, 69, 49, 73, 86, 71, 69, 85, 118, 102, 54, 107, 111,
87, 108, 69, 97, 101, 85, 89, 113, 73, 115, 89, 85, 55, 82, 78, 106, 107, 81, 104, 87, 81, 109, 90,
103, 90, 67, 103, 76, 105, 113, 85, 119, 69, 88, 89, 72, 119, 81, 117, 99, 117, 85, 109, 107, 66, 90,
87, 71, 122, 99, 87, 69, 112, 82, 85, 71, 66, 81, 73, 47, 85, 99, 82, 97, 89, 69, 74, 97, 111, 71, 107,
107, 87, 78, 81, 75, 108, 79, 97, 83, 85, 111, 47, 99, 57, 53, 52, 72, 47, 102, 55, 51, 110, 115, 122,
85, 113, 115, 72, 99, 43, 69, 78, 56, 55, 53, 53, 99, 57, 56, 57, 53, 53, 53, 55, 118, 106, 99, 84,
107, 49, 86, 53, 113, 88, 57, 76, 57, 114, 113, 116, 113, 99, 109, 74, 53, 75, 97, 89, 109, 102, 116,
74, 119, 50, 78, 84, 98, 54, 106, 56, 49, 80, 85, 47, 98, 103, 51, 85, 72, 117, 115, 50, 53, 109, 87,
103, 57, 108, 104, 121, 101, 85, 81, 66, 82, 65, 72, 56, 90, 56, 84, 106, 53, 102, 102, 67, 78, 49,
111, 77, 68, 78, 107, 106, 84, 69, 105, 108, 70, 87, 118, 121, 76, 101, 116, 66, 67, 122, 79, 115, 106,
67, 78, 111, 120, 101, 84, 47, 77, 109, 116, 90, 107, 121, 97, 66, 122, 43, 55, 49, 106, 116, 72, 69,
53, 75, 121, 53, 53, 107, 108, 76, 111, 84, 74, 102, 78, 117, 108, 109, 115, 109, 83, 84, 121, 115, 65,
105, 110, 121, 48, 65, 120, 75, 43, 53, 99, 90, 111, 102, 55, 54, 70, 53, 102, 52, 47, 108, 111, 114,
81, 57, 51, 90, 83, 52, 102, 114, 117, 83, 102, 80, 47, 112, 76, 105, 88, 53, 115, 47, 90, 68, 49, 78,
76, 120, 110, 70, 52, 79, 84, 112, 106, 114, 65, 49, 101, 80, 109, 116, 101, 51, 100, 98, 50, 105, 106,
106, 115, 68, 116, 105, 84, 100, 101, 117, 121, 104, 97, 121, 50, 86, 121, 108, 112, 116, 56, 50, 48,
70, 65, 71, 75, 115, 43, 53, 105, 57, 104, 71, 73, 84, 86, 108, 78, 83, 84, 106, 87, 116, 76, 98, 108,
67, 71, 121, 116, 102, 85, 50, 66, 86, 117, 88, 75, 82, 68, 117, 114, 109, 111, 51, 102, 75, 79, 84,
79, 111, 77, 56, 97, 115, 78, 112, 122, 114, 99, 83, 119, 101, 85, 90, 122, 118, 85, 99, 55, 82, 74,
98, 49, 52, 55, 110, 114, 69, 71, 89, 104, 76, 51, 107, 82, 120, 66, 97, 49, 48, 47, 79, 107, 82, 43,
114, 54, 52, 48, 108, 104, 98, 68, 65, 120, 113, 106, 75, 107, 65, 84, 108, 81, 88, 109, 85, 120, 76,
43, 84, 66, 89, 50, 82, 87, 65, 113, 106, 57, 81, 83, 67, 100, 114, 105, 113, 105, 113, 49, 71, 117,
99, 81, 48, 89, 121, 76, 116, 43, 49, 66, 50, 115, 72, 73, 78, 55, 117, 81, 116, 122, 56, 47, 89, 47,
78, 81, 82, 67, 72, 54, 85, 74, 74, 74, 57, 72, 110, 70, 48, 111, 83, 109, 81, 106, 115, 90, 97, 97,
110, 75, 69, 86, 75, 65, 70, 76, 118, 105, 79, 98, 54, 72, 85, 98, 104, 72, 75, 50, 78, 75, 110, 68,
77, 107, 90, 54, 76, 111, 51, 100, 111, 81, 118, 108, 117, 87, 66, 99, 113, 122, 115, 43, 103, 107, 97,
56, 98, 68, 66, 68, 111, 66, 72, 100, 66, 90, 43, 102, 103, 76, 113, 57, 53, 89, 120, 107, 54, 113,
120, 121, 89, 69, 49, 50, 67, 99, 111, 68, 98, 117, 118, 113, 85, 100, 83, 109, 118, 90, 85, 109, 73,
119, 53, 99, 88, 43, 105, 74, 65, 100, 65, 121, 88, 109, 67, 52, 70, 102, 88, 75, 65, 101, 87, 90, 69,
90, 53, 111, 55, 52, 77, 118, 76, 115, 76, 106, 76, 109, 89, 115, 80, 97, 87, 100, 68, 112, 52, 86,
112, 100, 105, 107, 53, 87, 47, 56, 77, 111, 77, 121, 88, 89, 55, 54, 47, 77, 101, 75, 106, 106, 51,
54, 47, 119, 90, 120, 115, 100, 49, 86, 112, 114, 118, 110, 101, 83, 85, 73, 111, 111, 76, 86, 120,
116, 121, 85, 47, 79, 103, 97, 110, 107, 100, 51, 81, 56, 57, 100, 86, 70, 70, 74, 117, 108, 109, 113,
100, 43, 110, 48, 99, 65, 89, 66, 100, 72, 66, 122, 110, 110, 51, 106, 111, 102, 116, 43, 111, 114, 88,
120, 67, 66, 99, 51, 89, 79, 108, 65, 73, 113, 78, 101, 119, 83, 100, 49, 116, 87, 70, 74, 99, 116, 74,
81, 110, 55, 103, 48, 83, 73, 71, 86, 49, 68, 106, 53, 70, 72, 109, 73, 53, 111, 77, 122, 81, 103, 47,
55, 112, 52, 79, 117, 48, 85, 112, 81, 69, 75, 71, 102, 65, 98, 115, 78, 66, 76, 104, 121, 81, 67, 67,
84, 69, 82, 102, 79, 71, 78, 84, 79, 51, 89, 74, 107, 106, 100, 77, 106, 113, 82, 74, 80, 76, 102, 53,
84, 89, 87, 53, 84, 106, 43, 74, 108, 107, 51, 48, 107, 43, 87, 74, 101, 83, 89, 70, 49, 76, 52, 69,
55, 87, 121, 87, 54, 107, 53, 57, 98, 110, 73, 69, 73, 72, 77, 104, 122, 108, 74, 101, 87, 103, 77, 56,
102, 121, 119, 101, 54, 76, 65, 112, 106, 57, 107, 65, 109, 77, 87, 106, 97, 56, 122, 80, 82, 85, 82,
43, 117, 48, 109, 120, 48, 99, 84, 69, 74, 56, 112, 66, 56, 77, 89, 70, 78, 72, 122, 82, 115, 88, 104,
43, 53, 65, 55, 68, 122, 56, 80, 84, 115, 109, 53, 98, 52, 103, 114, 82, 79, 66, 84, 85, 54, 54, 70,
47, 74, 103, 86, 117, 81, 53, 65, 52, 106, 52, 78, 75, 111, 80, 72, 107, 66, 66, 66, 117, 71, 99, 65,
89, 122, 113, 79, 55, 78, 100, 70, 57, 117, 98, 121, 111, 49, 99, 48, 106, 113, 82, 118, 54, 54, 105,
119, 79, 119, 97, 68, 117, 122, 99, 77, 116, 53, 43, 109, 70, 113, 101, 104, 69, 74, 115, 98, 119, 118,
79, 81, 114, 97, 106, 119, 122, 67, 76, 115, 108, 104, 109, 66, 119, 57, 122, 89, 69, 115, 54, 82, 48,
112, 83, 119, 112, 75, 55, 101, 69, 121, 81, 55, 85, 51, 55, 119, 117, 90, 72, 121, 73, 99, 57, 53,
102, 79, 97, 115, 57, 50, 117, 47, 86, 71, 80, 50, 113, 79, 47, 121, 75, 73, 65, 111, 103, 68, 99, 68,
105, 67, 99, 86, 55, 115, 104, 89, 116, 122, 43, 53, 43, 53, 102, 65, 81, 89, 65, 80, 115, 81, 106,
121, 52, 54, 108, 99, 104, 65, 65, 65, 65, 65, 65, 83, 85, 86, 79, 82, 75, 53, 67, 89, 73, 73, 61 };
response.setContentType("image/jpeg");
response.setContentLength(img2.length);
response.getOutputStream().write(img2, 0, img2.length);
response.getOutputStream().close();
If I embed the same piece in an HTML it all works okay.
Can anybody tell me why?
<img src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAeCAYAAABqpJ3BAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2pJREFUeNrsWE1IVGEUvf6koWlEaeUYqIsYU7RNjkQhWQmZgZCgLiqUwEXYHwQucuUmkBZWGzcWEpRUGBQI/UcRaYEJaoGkkWNQKlOaSUo/c954H/f73nszUqsHc+EN8755c9895557vjcTk1V5qX9L9rqtqcmJ5KaYmftJw2NTb6j81PU/bg3UHus25mWg9lhyeUQBRAH8Z8Tj5ffCN1oMDNkjTEilFWvyLetBCzOsjCNoxeT/MmtZkyaBz+71jtHE5Ky55klLoTJfNulmsmSTysAiny0AxK+5cZof76F5f4/lorQ93ZS4fruSfP/pLiX5s/ZD1NLxnF4OTpjrA1ePmte3db2ijjsDtiTdeuyhay2Vylpt820FAGKs+5i9hGITVlNSTjWtLblCGytfU2BVuXKRDurmo3fKOTOoM8asNpzrcSweUZzvUc7RJb147nrEGYhL3kRxBa10/OkR+r640lhbDAxqjKkATlQXmUxL+TBY2RWAqj9QSCdriqiq1GucQ0YyLt+1B2sHIN7uQtz8/Y/NQRCH6UJJJ9HnF0oSmQjsZaanKEVKAFLviOb6HUbhHK2NKnDMkZ6Lo3doQvluWBcqzs+gka8bDBDoBHdBZ+fgLq95Yxk6qxyYE12CcoDbuvqUdSmvZUmIw5cX+iJAdAyXmC4FfXKAeWZEZ5o74MvLsLjLmYsPaWdDp4Vpdik5W/8MoMyXY76/MeKjj36/wZxsd1VprvneSUIooLVxtyU/Ogankd3Q89dVFFJulmqd+n0cAYBdHBznn3joft+orXxCBc3YOlAIqNewSd1tWFJctJQn7g0SIGV1Dj5FHmI5oMzQg/7p4Ou0UpQEKGfAbsNBLhyQCCTERfOGNTO3YJkjdMjqRJPLf5TYW5Tj+Jlk30k+WJeSYF1L4E7WyW6k59bnIEIHMhzlJeWgM8fywe6LApj9kAmMWja8zPRUR+u0mx0cTEJ8pB8MYFNHzRsXh+5A7Dz8PTsm5b4grROBTU66F/JgVuQ5A4j4NKoPHkBBBuGcAYzqO7NdF9ubyo1c0jqRv66iwOwaDuzcMt5+mFqehEJsbwvOQrajwzCLslhmBw9zYEs6R0pSwpK7eEyQ7U37wuZHyIc95fOas92u/VGP2qO/yKIAogDcDiCcV7shYtz+5+5fAQYAPsQjy46lchAAAAAASUVORK5CYII="/>
If the byte array is a JPEG, it should start with a standard JPEG signature, but yours doesn't. It's hard to tell what's going on since you didn't provide any information about where these bytes came from, but what you should be looking for is something like this:
255 216 255 224 0 16 74 70 73 70
for the first 9 bytes -- the last 4 of those spell "JFIF"
This can vary, but the first two bytes should definitely be FFC0 - start of image
What's a mystery is why the base64-encoded image displays correctly.
Oh I see now: it's a PNG not a JPEG. Check this answer: PHP : binary image data, checking the image type it should help.
There also seems to be something wrong with your conversion since the first bytes of your array are not the same as the first bytes of the base64 png (those are: 0x89, 0x50, 0x4e, or in decimal: 137, 80, 78)
I have just downloaded windows phone 7.1 sdk for windows phone 7.5.
I have two problems:
1. When i create a new project I doesn't see the option to choose windows phone 7 or 7.5
2. Windows phone 7.5 should be based on Silver light 4 but when I create label at my application and write hebrew words it's backwords.
Can I solve the problem at this version?
If you have installed the Mango tools, once you select to create a WP7 application you are prompted on a secondary screen to select whether to target 7.0 or 7.1.
Note that the version number of the SDK and tools is 7.1 but phones running Mango are marketed as version 7.5.
Note that WP7[.1|5] does not yet currently provide native support for RTL languages. You may find a workaround at http://www.danielmoth.com/Blog/RTL-Arabic-And-Hebrew-Support-For-Windows-Phone-7.aspx
For Windows Phone 7 i wrote a mapping function which maps the Arabic encoding[windows-1256] into default WP7 encoding.
public static string ConvertToArabic(string s) { short[] mapping = { 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, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746 };
string str = string.Empty;
for (int ix = 0; ix < s.Length; ++ix)
{
str = str + (char)mapping[s[ix]];
}
return str;
}
This worked for me well.