4 kyu

Challenge Fun #20: Edge Detection

28 of 49myjinxin2015
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    If even ZED needed dozens of lines of code to solve this one, you know this is a tough kata ;)

  • 4500zenja1 Avatar

    And Ruby fork, too =P

  • 4500zenja1 Avatar

    JS fork with the same upgrades listed below (or more :) )

  • 4500zenja1 Avatar

    Python fork:

    • fixing the image issue;
    • fully going to new framework;
    • making 3 degrees of random tests which are going to 10^9, as it was issued here
  • Just4FunCoder Avatar

    Image in the description is not loaded.

    http://media.openjudge.cn/images/1009_1.jpg

  • Loerpal Avatar

    I have some issues with this kata, while all other katas seem to be working fine this already almost times out from just using "pass" and I have no idea why.

  • FArekkusu Avatar

    Ruby 3.0 should be enabled.

  • Voile Avatar

    Images contain 2 to 1,000,000,000 (10^9) pixels

    But only 1 fixed test case covers the whole range; the random tests rarely goes above 10^6 pixels, making this input range misleading and not enforced.

  • tranquility-base Avatar

    Difficult, but definitely learned a lot doing this one. Not sure the effort unrolling loops and list comprehensions in order to squeeze out the last milliseconds of efficiency was time well spent, though.

  • user8436785 Avatar

    Python 3.6 needs to be enabled.

  • GrachevNikolay79 Avatar

    the implementation has simple code, but during the optimization process a monster was born :) Cool kata!

  • cocoderrr Avatar

    Cool kata! I find it unfair that it's been apparently sitting for a year forgotten by the world.

  • ZED.CWT Avatar
  • kontic Avatar

    Hi, I have some problems with this kata. Here is test:

    image = "9 133 45 205 1 230 2453 65 35 235 36 138 20 143 20 60 2759 28 14 242 45 173 4227 160 19 249 23 151 9 110 21 151 2460 139 8 40 36 170 9 26 16 73 36 251 32 19 26 232 23 15 28 94 32 108 45 241 3510 192 32 248 39 72 4537 79 46 166 23 85 47 84 1873 226 48 125 50 158 7 236 39 135 6003 205 27 204 6 90 46 86 8 176 3321 182 36 173 4602 27 16 102 33 250 11 95 957 121 40 188 7462 4 1 77 40 175 15 120 3 144 10 147 41 167 5757 97 29 88 4 117 21 63 48 131 3837 62 3307 13 20 123 530 124 10 154 32 114 44 102 5 209 21 52 9575 92 3 4 47 96 29 14 5077 1 9504 37 27 115 1617 8 34 86 8 179 19 100 41 246 40 252 4580 57 8469 4 49 125 34 75 25 16 42 172 32 137 4436 221 35 87 34 163 35 28 19 211 45 163 26 69 758 29 31 107 33 154 35 30 2 240 39 225 12 211 27 27 37 226 21 210 43 190 3 29 31 10 41 124 20 70 47 30 23 14 28 22 1928 197 21 76 6408 179 50 7 38 130 14 103 23 193 28 127 43 220 38 217 38 183 3 130 32 145 40 114 1062 187 36 232 1 132 9405 97 1627 114 1 164 9553 69 47 169 15 244 47 68 8624 9 11 51 4308 37 25 80 20 232 46 197 16 94 3571 36 6 99 44 154 13 8 31 225 22 250 20 185 26 17 1443 172 50 135 8809 210 5100 186 33 227 19 78 4018 137 27 196 14 108 6072 153 29 137 8651 182 29 232 39 79 9853 125 40 143 45 244 12 59 39 7 35 5 16 177 44 142 6644 170 42 29 44 109 5891 206 5381 45 29 213 517 159 6674 164 11 32 49 203 45 156 39 236 4 48 7238 107 361 115 9886 238 36 158 47 157 5 69 29 131 4961 236 5467 67 1734 1 4061 131 20 24 8 24 22 233 8277 174 20 157 46 149 21 127 43 192 3967 38 1 192 4228 119 20 11 20 98 5307 15 15 162 1266 172 44 162 3621 116 3490 157 30 116 26 185 1 142 36 91 2 78 6",
    result= "9 0 18 97 9 0 9 97 9 72 1 97 8 25 2 0 2433 165 20 0 15 170 20 0 16 97 20 5 20 0 1 83 18 0 2740 32 14 214 20 0 25 69 20 0 4207 13 19 89 20 0 3 98 9 139 1 98 9 139 1 41 9 0 1 41 20 0 2440 12 9 111 1 99 8 111 2 99 7 0 18 130 9 144 18 47 17 0 16 178 20 0 12 232 20 0 6 213 20 0 3 217 20 0 8 79 20 0 12 14 20 0 25 133 20 0 3490 49 20 0 13 56 18 0 20 176 20 0 4517 7 20 0 26 87 20 0 3 81 20 0 27 1 20 0 1853 142 20 0 28 101 20 0 30 33 7 111 3 78 7 111 3 78 7 0 19 101 20 0 5983 70 20 0 7 1 6 115 4 114 6 115 4 114 6 0 26 4 8 86 2 90 18 0 3301 6 20 0 16 9 20 0 4582 146 20 75 16 0 13 148 11 155 20 0 937 26 20 0 20 67 20 0 7443 184 2 111 7 184 1 111 8 73 2 0 20 98 20 31 4 55 4 31 7 24 3 3 10 0 21 20 20 0 5737 70 20 0 9 9 4 20 6 29 5 20 3 29 6 0 1 54 20 0 28 68 20 0 3817 69 20 0 3288 49 18 0 1 110 20 0 510 1 10 30 20 0 12 40 20 0 24 12 5 95 5 107 6 95 2 107 7 0 1 157 20 0 9555 40 3 48 7 88 4 48 4 88 5 0 28 92 18 0 10 82 20 0 5057 13 20 0 9484 36 20 0 7 78 20 0 1598 107 18 0 15 78 8 171 2 93 8 171 2 93 8 79 19 0 21 146 20 0 20 6 20 0 4560 195 20 0 8449 53 20 0 29 121 20 0 14 50 20 0 5 59 20 0 22 156 20 0 12 35 20 0 4416 84 20 0 15 134 20 0 14 76 20 0 15 135 19 183 20 0 25 48 20 0 6 94 20 0 738 40 20 0 12 78 18 0 14 47 20 0 15 124 4 86 5 124 1 210 3 86 5 210 4 0 19 15 20 14 12 0 7 184 20 0 17 199 20 0 1 16 20 0 23 20 4 181 6 161 3 181 7 161 2 0 12 19 20 0 22 114 18 0 1 54 20 0 27 40 20 0 4 16 18 0 9 8 20 0 1908 175 20 0 1 121 20 0 6388 103 20 0 30 172 20 0 18 123 20 27 13 0 4 90 20 0 8 66 20 0 23 93 20 0 18 3 20 0 18 34 3 87 7 53 3 87 7 53 3 0 12 15 20 0 20 31 20 0 1042 73 20 0 16 45 1 55 9 100 2 55 6 100 3 0 9385 35 20 0 1607 17 1 67 9 50 1 67 9 50 1 0 9533 95 20 0 27 100 20 75 15 0 27 176 20 0 8605 59 18 42 12 0 4288 14 20 0 5 43 20 152 20 0 27 35 15 103 20 0 3551 58 8 5 1 58 1 63 7 5 1 63 8 0 24 55 13 146 20 0 12 217 18 0 3 25 20 65 20 0 6 168 20 0 1423 155 20 0 30 37 20 0 8789 75 20 0 5080 24 20 0 13 41 19 149 20 0 3998 59 20 0 7 59 14 88 20 0 6052 45 20 0 9 16 20 0 8631 45 20 0 10 50 18 0 20 153 20 0 9833 46 20 0 20 18 20 0 25 101 12 185 20 0 19 52 20 0 15 2 16 172 20 0 24 35 20 0 6625 28 18 0 23 141 20 0 24 80 20 0 5871 97 20 0 5362 161 18 0 10 168 20 0 497 54 20 0 6654 5 11 132 20 0 29 171 20 0 25 47 20 0 19 80 4 108 6 188 5 108 3 188 6 0 7218 59 20 0 342 8 18 0 9867 123 20 0 16 80 20 0 27 1 5 89 5 88 5 89 5 88 5 0 9 62 20 0 4941 105 20 0 5447 169 20 0 1714 66 20 0 4042 130 18 0 1 107 20 0 10 209 20 0 8257 59 20 17 20 0 26 8 20 0 1 22 20 0 23 65 20 0 3947 154 3 0 6 154 3 0 6 154 3 0 4208 73 20 108 20 87 20 0 5287 83 15 147 20 0 1246 10 20 0 24 10 20 0 3602 46 18 0 3471 41 20 0 10 41 20 0 7 69 2 26 7 69 1 43 1 26 7 43 2 0 16 51 2 64 7 51 3 64 6"
    Test.assertEquals(edgeDetection(image),result)
    

    For this test we have width = 9, then we have 45 times value 133... From this, I'm sure that first 4 rows on output must be zeros. So it should be 9 0 36... . Am I wrong?

    Thanks!