|
| 1 | +```csharp |
| 2 | +/* |
| 3 | +I have a content input as : {1: {2: "Hello", 3: "!", 1: "World"}, 2: {1: "I", 3: "here", 2: "am"}}, please help me to construct input as entire content like human conversation |
| 4 | +*/ |
| 5 | + |
| 6 | +[HttpGet(Name = "GetConversation")] |
| 7 | +public string GetConversation() |
| 8 | +{ |
| 9 | + var content = "{1: {2: \"Hello\", 3: \"!\", 1: \"World\"}, 2: {1: \"I\", 3: \"here\", 2: \"am\"}}"; |
| 10 | + var conversation = new StringBuilder(); |
| 11 | + var conversationDictionary = JsonConvert.DeserializeObject<Dictionary<int, Dictionary<int, string>>>(content); |
| 12 | + foreach (var (key, value) in conversationDictionary) |
| 13 | + { |
| 14 | + conversation.Append($"Speaker {key}: "); |
| 15 | + foreach (var (key1, value1) in value.OrderBy(x => x.Key)) |
| 16 | + { |
| 17 | + conversation.Append($"{value1} "); |
| 18 | + } |
| 19 | + conversation.Append("\n"); |
| 20 | + } |
| 21 | + return conversation.ToString(); |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | +```java |
| 27 | +Map<Integer, Map<Integer, String>> input = Map.of( |
| 28 | + 1, Map.of(2, "world", 3, "!", 1, "Hello"), |
| 29 | + 2, Map.of(1, "I", 3, "here", 2, "am") |
| 30 | +); |
| 31 | +// add a method named printSortedValue in Calculator.java, |
| 32 | +// the method should print the values in the input map in the order of the key of the outer map and the key of the inner map |
| 33 | +// the output should be "Hello world ! I am here" |
| 34 | +public void printSortedValue() { |
| 35 | + // use java stream api to iterate the map and print the values to refactor the following code |
| 36 | + for (int i = 1; i <= 2; i++) { |
| 37 | + Map<Integer, String> innerMap = input.get(i); |
| 38 | + for (int j = 1; j <= 3; j++) { |
| 39 | + System.out.print(innerMap.get(j) + " "); |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +```kotlin |
| 46 | +class RecombinationParagraph { |
| 47 | + // given a map to storage json like below |
| 48 | + // { |
| 49 | + // 1: { |
| 50 | + // 2: "world", |
| 51 | + // 3: "!", |
| 52 | + // 1: "Hello" |
| 53 | + // }, |
| 54 | + // 2: { |
| 55 | + // 1: "I", |
| 56 | + // 3: "here", |
| 57 | + // 2: "am" |
| 58 | + // } |
| 59 | + // } |
| 60 | + // create a function to recombine the map to a string like below: |
| 61 | + // Hello world! |
| 62 | + // I am here ! |
| 63 | + // generate code here |
| 64 | + fun recombine(map: Map<Int, Map<Int, String>>): String { |
| 65 | + val sb = StringBuilder() |
| 66 | + for (i in 1..map.size) { |
| 67 | + val innerMap = map[i] |
| 68 | + for (j in 1..innerMap!!.size) { |
| 69 | + sb.append(innerMap[j]) |
| 70 | + sb.append(" ") |
| 71 | + } |
| 72 | + sb.append("\n") |
| 73 | + } |
| 74 | + return sb.toString() |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +```java |
| 80 | +// create a method is to contact charactors by sequesnce number |
| 81 | +// the input is nested json format, output is a string |
| 82 | +// for example |
| 83 | +// input: {1: {1: 'a', 2: 'b', 3: 'c'}} |
| 84 | +// output: 'abc' |
| 85 | +// if the input has multiple members, the output should be seperated by two line breaks |
| 86 | +``` |
| 87 | + |
| 88 | +Chat |
| 89 | + |
| 90 | +``` |
| 91 | +1. learn following data format as method input '''{ 1: { 2: "world", 3: "!", 1: "Hello"}, 2: { 1: "I" , 3: "here", 2: "am" } }''' |
| 92 | +2. generate a method which takes above input and print message line by line regarding the key value ascending |
| 93 | +3. please do not add new line for the second level key |
| 94 | +``` |
| 95 | + |
| 96 | +1.先用这个生成map,然后它会一行一行提示出来 |
| 97 | +```java |
| 98 | +// generate a map to contains the following json, json is quote in ``` |
| 99 | + // { 1: { 2: "world", |
| 100 | + // 3: "!", |
| 101 | + // 1: "Hello"}, |
| 102 | + // 2: { 1: "I" , |
| 103 | + // 3: "here", |
| 104 | + // 2: "am" } |
| 105 | + //} |
| 106 | +``` |
| 107 | + |
| 108 | +2.用这个生成代码 |
| 109 | +``` |
| 110 | +// create a method to combine word in a map to a sentence, the map is generated by generateMap method |
| 111 | +// should combine then by the order of the key, the key is integer |
| 112 | +``` |
| 113 | + |
| 114 | + |
| 115 | +可以让 GPT 代写 prompt |
| 116 | + |
| 117 | +write a prompt for javascript code, the code should do the following |
| 118 | +1. the input is a json string, |
| 119 | +2. the output is a combination of the json data. following is an example input |
| 120 | + `{ 1: { 2: "world", 1: "hello", 3: "!" }, 2: { 2: "am", 1: "I", 3: "here" }, }` |
| 121 | + |
| 122 | +output |
| 123 | +`hello world! |
| 124 | +I am here` |
| 125 | + |
0 commit comments