Aller au contenu

Dichotomie⚓︎

Compléter la fonction dichotomie :

  • prenant en paramètre un tableau de nombres triĂ©s dans l'ordre croissant nombres et une valeur cible

  • renvoyant True si cible est une valeur de nombres, False dans le cas contraire.

Exemples

Python Console Session
>>> dichotomie([1, 2, 3, 4], 2)
True
>>> dichotomie([1, 2, 3, 4], 1)
True
>>> dichotomie([1, 2, 3, 4], 4)
True
>>> dichotomie([1, 2, 3, 4], 5)
False
>>> dichotomie([1, 2, 3, 4], 0)
False
>>> dichotomie([1], 1)
True
>>> dichotomie([1], 0)
False
>>> dichotomie([], 1)
False

Remarque

Vous utiliserez obligatoirement un algorithme de recherche dichotomique.

Compléter ci-dessous

###(Dés-)Active le code après la ligne # Tests (insensible à la casse)
(Ctrl+I)
Entrer ou sortir du mode "deux colonnes"
(Alt+: ; Ctrl pour inverser les colonnes)
Entrer ou sortir du mode "plein Ă©cran"
(Esc)
Tronquer ou non le feedback dans les terminaux (sortie standard & stacktrace / relancer le code pour appliquer)
Si activé, le texte copié dans le terminal est joint sur une seule ligne avant d'être copié dans le presse-papier
Évaluations restantes : 5/5

.128013ùA_4:L2-.Sw3z/]+7ÀbpPiNqI{oFê1tl(9^ ;=vTm6u8RsèfrO}gàe[hcDé05a,nkydx)050?0$0F0.0w0G0U0K0)0G0.0U0U0M010F0w0u010406050U0R0P0P0.0X0=040k0B0G0R190B0:0K020.0P0u0L0K0T0$1j0X0y0R0$0U050o1g1i1k1m1e0u04051R1K1U0o1R1e0?0w0N11131517130:0!0R0.0!0$0i0u0=0F0(1t0K0(0w0!0(0G1}0(0F1c050|0t0G0$1%1416011|1~201~0F2628240F0X1S1^111p0U0u0.0:170h012a1)010W0~0$0:1x0$242s2u2z2c2C282F0P2H040a0K0v0X0B0u0B0U0w1s1u0`2q0X0X0$0)2$1K2J0:1S0o1^2=2m2o2n250?2L1*0w0:2E2Z241!1$122b2 310:0B35240u2+1S2:2=3i1f2t1u372A3b0X1j0G240.1{2+0W17030d0d0)3c0$203a0B0i0E3J1c0K0E1K0.3j3m1d3l2K3o2c3q3s3u3w0$3y013A3C3E3G323J0i2x040K0h3P3R2u3T2:2~013Y0.3t1S3v0(3x3z3B3D0`3,3b3.0m3M0m3@2/3S1e3{3W173~400542443(463+303-3K0e3M0e4f1L4h3U3n1(3X0B3r3 3!433$453*484u4a3K0-3M0-4A3i4i3m3|4m4K4q3)473F4Q3I3K0Q3M0Q4W4C4j4F4l4H3Z413#3%4(4t3H3.0r3M0r4;3_4Y3V4@3}4_4J4{4L4}4s4P503K0S3M0S552;574E385a4I4n4p4M4r4O4*5i0i0I3M0I5n3`4Z4k5s4`4o4|4N4)494,3J0,1c0E0,5F5p4!5b5u5M5x5O4+3.0E0E5T3O0o3Q4g564D5Y5t4$5w4~5h4v3J3:0E3?5.3^2;1V3g1K352^0?2o2}5I4)341#1S3f0$3h3S5:634)6j2K0w0?173B2:5)3!6q6s5y5P6v0K2P0$6y5%5A5+2=5/4?5r0;1c0`0W6l6o5q2A0l3M6R5=5I0:0W6O0w0)1_0F0B0P0w0$6X6L2A1b040H6/5H590:1c3b0P0t2+1J4B3_6Y596=0/6R0K745r6{040)0w276.72636:2c6=0^0f6R1e7i6S0K6x016t3m3.3:5L7u5g5z5|2x6C2G6F4 7E24610K7N797k4l6O0$0t1r787a2A0B1c0M7W7Q016,1c5V7r7q3k3{7B0d6u3K4c4{7:6G5|4c7G2Q7I5{4R0i7@3@7O7P6_7b1c2C0:7$877Y7!8c587b0t1c2O6^8h6;1c6@7r7X3X6|6+6 1I8m6T7l1c0^8g8z177Z040i8D3|7)045-4X8y7t6r7v7;7x4w6w8R7C6A8V7}6E8S7`814x6J3;7O8s176N040l1|288J6Z7S7U0F8^598G020G0F0L7#7r868n8t048a8P5I6=7o7,8P7:7=0i4T7^8X6z5(4S2y6D7 7D819k84858-7%7c6,200$0R8}5r8G943i968E016=8q7.8d989a958.018G0q9F3p8`7V8r7%7m9b8~1c0o0o9)5r8L608O9$4Z9h8U0i4.9l9s8Z9`9q7H8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_29f6e=e@28f@e{f_e}29f|0~0Kf eCg3g3dYg6f;g96-0Kf30RdU0?gfd428ghgjfJ8a0Kgngp0K0igsfI0`04gvgx0of%7qg|g~d*0g3v0n1tel292+gS0(290H0G000+0)1keCe|29f9g-30gtfJe eChmg_gl8|g^6i0^d.h8fzfoeCf66(eV1HeXeZe#1`f|fm1u8ad=dW0K0.fuezfEhn1u9092e,b!hx04e(0)00f00KeWe=ht6ifbhpg_6Ch,fXeg10g50:g7e6g)e80Re30Y1ufZ0XeC2(e=0tfn12290{0KfshVhl6nc:0 fcfJeOds7qd70_1#dHdy0:dAdC6!dF1TixdJe$dL2#dO0xbr291j0@fx3 e,eGfn0Xh}29idg#2871d)1R2V32h 0Kd^0Khghid?30dZfwiz19iRh;9930g=h$9#fdf2iRf69U1kd}1jfT0@1c090H5U0J0I09gv3ie(0He{h.fofWeC2m0V100!e!0:0?0^iri$040*gVe~0uezh710hh0Ufq0bf;fV0:h`eC2t103f0+c8f_0$fq1u0X0+3 ede6fni0106*a*iW0KiYifjS2Z2!7g0Ujy3Th1fk0cea6hd%dXj,0XjYhTi+1ui.i9e ftez1`2(j4ec1^j70$j904jb090We!0)0Ajd0I0Z0A0h0Zjg6Rh*jPf:1!f/kf7%j5kifBkljb0-0K09192Q10jd0Skz8rgwf)fMf)j~e,0RiP0Vd k3k53vi,k9hjkc2W2%hlkHkhd~kKja0Hkokq0AkNkPfxdokTkvkxkV9Jh+h-f6kEk@cHkIk`j8k|0hl1kQl40,0J0rl86kkXf(040c30e:e/hD290jlC1Kgxj}gffs19k)j(a*k,k7i-hhka0?h,k;1`kgj6k{kmk}kp0.krktl60J0A0m0,0Zkyjhamlah{lcjFd?2E0Nkd1u0Eirh0fid8lwh fpgUi*d^2920fXh7eG0}0Ge~lWkJlilZktlr3_e(efgh0u1qeelU1ul,iTj-e)i70}fY0we;hf0G0+2Qf_hXg_h?h(joebjUeBj`it6fit0{me0U04.