1import{_ as $}from"./DEWBa1i1.js";import{v as b,r as x,y as g,Y as v,e as A,c as o,o as l,j as a,m as q,F as E,q as F,t as m,s as N,u as _,x as j,a as c,w as B}from"#entry";import{u as D}from"./Bv_fBYKe.js";import{_ as L}from"./Dx4pvTsb.js";import{_ as S,a as T}from"./CMrDpeqn.js";import{u as V}from"./DnOhZ8Zh.js";import"./Bd_6KxB9.js";const z={class:"max-w-2xl mx-auto"},I={__name:"TestChallenges",async setup(w){let e,r;const d=b(),u=x([]),{data:p}=([e,r]=g(()=>D("challenges",()=>v("/challenges").where({_partial:!1}).find())),e=await e,r(),e),i=x("");function f(){const s=/FAILED .+\.py::(.*?) -/g,n=i.value.matchAll(s),t=Array.from(n,R=>R[1]),k=/ERROR .+\.py/g,C=t.length===0&&!i.value.match(k);u.value.push({path:"All tests",pass:C})}return A(async()=>{await d.kernel.initialize();{let s="";p.value.filter((t=>!t.tags.includes("syntax"))).forEach(t=>{s=s+` 2${t.solution??""} 3 4${t.tests??""} 5`});const n=` 6import js 7import os 8import pytest 9from io import StringIO 10import sys 11import pyodide 12filename = "all.py" 13 14with open(filename, "w+") as f: 15 f.write(r'''${s}''') 16 17 18# Run the tests 19pytest.main(["-qq", filename]) 20`;await d.kernel.runCode(n,f,i)}}),(s,n)=>(l(),o("div",z,[n[0]||(n[0]=a("textarea",{id:"pytest-output",type:"text",class:"hidden"},null,-1)),(l(!0),o(E,null,F(_(u),t=>(l(),o("div",{key:t.path,class:"flex flex-col space-y-2 my-8"},[a("div",{class:N(["px-3 py-1 rounded flex justify-between text-default-text-dark",{"bg-emerald-600":t.pass,"bg-red-600":!t.pass}])},[a("div",null,m(t.path),1),a("div",null,m(t.pass),1)],2)]))),128)),q(" "+m(_(i)),1)]))}},M={key:0},O={key:1,class:"py-8"},H={class:"mx-auto max-w-3xl px-6 lg:px-8"},h="Python Coding Challenges",y="Write code online and get instant feedback on your progress with automated tests",U={__name:"index",async setup(w){let e,r;const u="test"in j().query,p=([e,r]=g(()=>v("challenges").sort({level:2}).find()),e=await e,r(),e);return V(h,y),(i,f)=>{const s=$;return l(),o("div",null,[c(s,null,{default:B(()=>[u?(l(),o("div",M,[c(I)])):(l(),o("div",O,[a("div",H,[a("div",{class:"mb-8"},[a("h1",{class:"text-3xl sm:text-4xl font-bold tracking-tight text-default-text-dark"},m(h)),a("p",{class:"mt-2 text-base text-default-text-lighter"},m(y))]),c(L),c(S),c(T,{challenges:_(p)},null,8,["challenges"])])]))]),_:1})])}}};export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.