PageSourceSearch

https://letsdatascience.com/_next/static/chunks/9861.f2dbb927068c2b3c.js

js letsdatascience.com collected 2026-09-24 08:53:31 UTC 13,758 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6613,9861,87432],{5917:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},6132:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},6613:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("trophy",[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]])},17666:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]])},40704:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("file-input",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]])},43184:(e,s,t)=>{t.d(s,{A:()=>n});var a=t(95155);t(12115);
1var l=t(5917);function n(e){let{challenges:s,currentIndex:t,completed:n,onSelect:i}=e;return(0,a.jsx)("div",{role:"tablist","aria-label":"Challenges",className:"lds-practice-question-nav",children:s.map((e,s)=>{let r=s===t,c=n.has(e.id);return(0,a.jsx)("button",{type:"button",role:"tab","aria-selected":r,"aria-label":"Open challenge ".concat(s+1,": ").concat(e.title),title:e.title,onClick:()=>i(s),className:"lds-practice-question-button ".concat(r?"is-current":c?"is-complete":""),children:c&&!r?(0,a.jsx)(l.A,{size:14,strokeWidth:2.4}):s+1},e.id)})})}},48314:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},50803:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]])},57828:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},75426:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},76106:(e,s,t)=>{t.d(s,{A:()=>n});var a=t(95155);t(12115);
1var l=t(17666);function n(e){let{hints:s=[]}=e;return s.length?(0,a.jsx)("div",{className:"space-y-3",children:s.map((e,s)=>{var t;return(0,a.jsxs)("div",{className:"lds-practice-hint",children:[(0,a.jsx)("span",{className:"lds-practice-hint-icon","aria-hidden":!0,children:(0,a.jsx)(l.A,{size:14})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"text-[11px] font-bold text-[var(--lds-studio-accent-strong)] uppercase mb-0.5",children:null!=(t=e.label)?t:"Hint ".concat(s+1)}),(0,a.jsx)("div",{className:"text-sm text-neutral-700 leading-relaxed",children:e.body})]})]},s)})}):null}},78874:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},84711:(e,s,t)=>{t.r(s),t.d(s,{default:()=>M});var a=t(95155),l=t(12115),n=t(26497),i=t(83126),r=t(28150),c=t(6613),d=t(61362),o=t(35299),u=t(78874),h=t(6132),p=t(17666),x=t(57828),m=t(40704),y=t(5917),j=t(75426),v=t(11987),g=t(40079),b=t(79066),k=t(47769),A=t(94407),f=t(43184),N=t(76106),w=t(7420),C=t(66371);function M(e){let s=e.challenges[e.currentIndex].id;return"python"===e.language?(0,a.jsx)(R,{...e},s):(0,a.jsx)(z,{...e},s)}function R(e){let s=(0,C.x)({pythonManager:e.pythonManager,dataset:e.dataset,setupCode:e.setupCode,pythonPackages:e.pythonPackages});return(0,a.jsx)(S,{...e,runtime:s})}function z(e){let s=(0,C.B)({dataset:e.dataset});return(0,a.jsx)(S,{...e,runtime:s})}function S(e){var s,t,C,M,R;let{language:z,challenges:S,initialCompleted:E,onChallengeComplete:P,runtime:H,currentIndex:q,setCurrentIndex:O,drafts:L}=e,V=(0,l.useId)(),{publishActivity:I,clearActivity:_}=(0,w.X)(),[F,T]=(0,l.useState)(null!=E?E:new Set),[B,Y]=(0,l.useState)(!1),[J,K]=(0,l.useState)(0),[Q,W]=(0,l.useState)(!1),[X,D]=(0,l.useState)(!1),[G,U]=(0,l.useState)(null),[Z,$]=(0,l.useState)(!1),[ee,es]=(0,l.useState)(0),[et,ea]=(0,l.useState)(null),[el,en]=(0,l.useState)(null),[ei,er]=(0,l.useState)(null),ec=S[q],[ed,eo]=(0,l.useState)(null!=(R=L.current[ec.id])?R:ec.starterCode),[eu,eh]=(0,l.useState)(null),ep=(0,l.useRef)(0),ex=H.clearOutput,em=(0,l.useCallback)(e=>{ep.current+=1,L.current[ec.id]=e,eo(e),eh(null),U(null),ex()},[ex,L,ec.id]);(0,l.useEffect)(()=>{E&&T(e=>new Set([...e,...E]))},[E]);let ey=(0,l.useCallback)(async e=>{if(!P)return void T(s=>new Set(s).add(e));ea(e),en(e),er(null);try{let s=await P(e);if(!0!==s)throw Error("The progress service did not confirm this save.");T(s=>new Set(s).add(e)),en(null)}catch(e){console.error("[PracticeRunner] Failed to save challenge progress:",e),er("Your answer is correct, but we could not save it. Keep this page open and retry saving.")}finally{ea(null)}},[P]),ej=(0,l.useCallback)(async()=>{let e=ep.current;eh(ed),es(e=>e+1),U(null);let s=await H.run(ed);if(e!==ep.current)return void H.clearOutput();if(s.error)return;$(!0);let t=!1;try{t=await H.grade(ed,s,ec.solution,ec.validation)}finally{$(!1)}e===ep.current&&(U(t),t&&!F.has(ec.id)&&await ey(ec.id))},[H,ed,ec,F,ey]),ev=(0,l.useCallback)(()=>{em(ec.starterCode),H.clearOutput(),U(null)},[ec.starterCode,H,em]),eg=(0,l.useCallback)(()=>{Y(!0),ec.hints&&K(e=>Math.min(e+1,ec.hints.length))},[ec.hints]),eb=(0,l.useCallback)(()=>{var e;ec.solution&&(null==(e=navigator.clipboard)||e.writeText(ec.solution),D(!0),setTimeout(()=>D(!1),1600))},[ec.solution]),ek=(0,l.useCallback)(()=>{ec.solution&&(em(ec.solution),U(null),H.clearOutput())},[ec.solution,H,em]),eA=(0,l.useCallback)(e=>{e!==q&&(_(V),O(e))},[V,_,q,O]),ef=(0,l.useMemo)(()=>Math.round(F.size/S.length*100),[F.size,S.length]),eN=eu===ed,ew=eN?H.lastRun:null,eC=(0,l.useMemo)(()=>{var e;return eN?H.status.isExecuting||Z?"running":0===ee?"not-run":(null==(e=H.lastRun)?void 0:e.error)||H.status.error?"error":!0===G?"correct":!1===G?"incorrect":H.lastRun?"ran":"not-run":"not-run"},[ee,Z,H.lastRun,H.status.error,H.status.isExecuting,eN,G]),eM=(0,l.useMemo)(()=>{var e,s;if(eN&&H.lastRun)return(null==(e=H.lastRun.rows)?void 0:e.length)?JSON.stringify({columns:null!=(s=H.lastRun.columns)?s:[],rows:H.lastRun.rows.slice(0,20),output:H.lastRun.output},null,2).slice(0,4e3):H.lastRun.output.slice(0,4e3)},[H.lastRun,eN]);return(0,l.useEffect)(()=>{var e,s,t,a,l,n;I(V,{kind:"coding-practice",itemId:ec.id,language:z,title:ec.title.slice(0,200),prompt:ec.description.slice(0,2400),concepts:(null!=(a=ec.concepts)?a:[]).slice(0,16).map(e=>e.slice(0,80)),code:ed.slice(0,12e3),attemptCount:ee,runState:eC,...void 0!==eM?{output:eM}:{},...eN&&((null==(e=H.lastRun)?void 0:e.error)||H.status.error)?{error:((null==(s=H.lastRun)?void 0:s.error)||H.status.error||"").slice(0,2e3)}:{},hintsAvailable:Math.min(null!=(l=null==(t=ec.hints)?void 0:t.length)?l:0,20),revealedHints:(null!=(n=ec.hints)?n:[]).slice(0,J).slice(0,8).map(e=>e.body.slice(0,1e3)),solutionRevealed:Q})},[V,ee,ed,ec,J,z,eM,eC,I,null==(s=H.lastRun)?void 0:s.error,H.status.error,Q,eN]),(0,l.useEffect)(()=>()=>_(V),[V,_]),(0,a.jsx)("div",{"data-lds-practice-runner":"true",className:"lds-practice-runner",children:(0,a.jsxs)("section",{className:"lds-practice-workbench","aria-label":"Coding practice workbench",children:[(0,a.jsxs)("header",{className:"lds-practice-toolbar",children:[(0,a.jsxs)("div",{className:"lds-practice-progress",children:[(0,a.jsxs)("div",{className:"lds-practice-progress-copy",children:[(0,a.jsx)("span",{className:"lds-practice-progress-icon","aria-hidden":!0,
1children:(0,a.jsx)(r.A,{size:16})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"lds-practice-progress-label",children:"Practice progress"}),(0,a.jsxs)("strong",{children:[F.size," of ",S.length," solved"]})]}),100===ef&&(0,a.jsxs)("span",{className:"lds-practice-complete-label",children:[(0,a.jsx)(c.A,{size:13})," Complete"]})]}),(0,a.jsx)("div",{className:"lds-practice-progress-track",role:"progressbar","aria-label":"Practice completion","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":ef,children:(0,a.jsx)("span",{style:{width:"".concat(ef,"%")}})})]}),(0,a.jsx)(f.A,{challenges:S,currentIndex:q,completed:F,onSelect:eA})]}),(0,a.jsxs)("div",{className:"lds-practice-brief",children:[(0,a.jsxs)("div",{className:"lds-practice-brief-meta",children:[(0,a.jsxs)("span",{children:["Challenge ",q+1," of ",S.length]}),(0,a.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,a.jsx)("span",{className:"capitalize",children:ec.difficulty}),ec.category&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,a.jsx)("span",{children:ec.category})]}),F.has(ec.id)&&(0,a.jsxs)("span",{className:"lds-practice-completed-status",children:[(0,a.jsx)(d.A,{size:13})," Completed"]})]}),(0,a.jsx)("h2",{children:ec.title}),(0,a.jsx)("p",{children:ec.description}),ec.concepts&&ec.concepts.length>0&&(0,a.jsxs)("div",{className:"lds-practice-concepts",children:[(0,a.jsx)("span",{children:"Focus"}),(0,a.jsx)("span",{children:ec.concepts.join(" \xb7 ")})]})]}),H.status.isLoading&&(0,a.jsxs)("div",{className:"lds-practice-runtime-loading",children:[(0,a.jsx)(o.A,{size:20,className:"animate-spin"}),(0,a.jsx)("span",{children:H.status.loadingMessage||"Booting runtime…"}),H.status.loadingProgress>0&&H.status.loadingProgress<100&&(0,a.jsx)("div",{className:"lds-practice-runtime-progress",children:(0,a.jsx)("span",{style:{width:"".concat(H.status.loadingProgress,"%")}})})]}),!H.status.isLoading&&(0,a.jsxs)("div",{className:"lds-practice-runtime",children:[(0,a.jsxs)("div",{className:"lds-practice-editor-label",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(r.A,{size:14})," ","python"===z?"Python":"SQL"," workspace"]}),(0,a.jsx)("span",{children:"Run with Command/Ctrl + Enter"})]}),H.tables.length>0&&(0,a.jsx)(b.A,{tables:H.tables}),(0,a.jsx)(g.A,{language:z,value:ed,onChange:em,onRunShortcut:ej,minHeight:320,readOnly:!H.status.isReady,flush:!0}),(0,a.jsx)(A.A,{isRunning:H.status.isExecuting,isReady:H.status.isReady,onRun:ej,onReset:ev,onHint:ec.hints&&ec.hints.length>0?eg:void 0,onSolution:ec.solution?()=>W(e=>!e):void 0,variant:"workbench"}),(0,a.jsx)(k.A,{result:ew,variant:"workbench"}),Z&&(0,a.jsxs)("div",{className:"lds-practice-verdict is-checking",children:[(0,a.jsx)(o.A,{size:14,className:"animate-spin"})," Checking your answer…"]}),!Z&&!0===G&&(0,a.jsxs)("div",{className:"lds-practice-verdict is-correct",children:[(0,a.jsx)(d.A,{size:16}),(0,a.jsxs)("span",{children:[(0,a.jsx)("strong",{children:"Correct."})," ",et===ec.id?"Saving your completion…":"Your result matches the reference output."]})]}),!Z&&!1===G&&(0,a.jsxs)("div",{className:"lds-practice-verdict is-incorrect",children:[(0,a.jsx)(u.A,{size:16}),(0,a.jsxs)("span",{children:[(0,a.jsx)("strong",{children:"Not quite yet."})," Compare your output, revise the code, or reveal the next hint."]})]}),H.status.error&&!(null==(t=H.lastRun)?void 0:t.error)&&(0,a.jsxs)("div",{className:"lds-practice-runtime-error",children:[(0,a.jsx)(h.A,{size:13})," ",H.status.error]}),ei&&el&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-2 rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-900 sm:flex-row sm:items-center sm:justify-between",role:"alert",children:[(0,a.jsx)("span",{children:ei}),(0,a.jsx)("button",{type:"button",onClick:()=>void ey(el),disabled:null!==et,className:"shrink-0 rounded-md border border-amber-300 bg-white px-3 py-1.5 font-semibold hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",children:et?"Saving…":"Retry saving"})]})]}),(0,a.jsx)(n.N,{children:(B&&(null==(C=ec.hints)?void 0:C.length)||Q&&ec.solution)&&(0,a.jsxs)(i.P.div,{initial:{opacity:0,y:-4}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.18},className:"lds-practice-assist",children:[B&&(null==(M=ec.hints)?void 0:M.length)?(0,a.jsxs)("div",{children:[(0,a.jsx)(N.A,{hints:ec.hints.slice(0,J)}),J<ec.hints.length&&(0,a.jsxs)("button",{type:"button",onClick:()=>K(e=>Math.min(e+1,ec.hints.length)),className:"lds-practice-next-hint",children:[(0,a.jsx)(p.A,{size:13}),"Reveal hint ",J+1," of ",ec.hints.length]})]}):null,Q&&ec.solution?(0,a.jsxs)("div",{className:"lds-practice-solution",children:[(0,a.jsxs)("div",{className:"lds-practice-solution-toolbar",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(x.A,{size:14})," Reference solution"]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{type:"button",onClick:ek,children:[(0,a.jsx)(m.A,{size:14})," Load into editor"]}),(0,a.jsxs)("button",{type:"button",onClick:eb,children:[X?(0,a.jsx)(y.A,{size:14}):(0,a.jsx)(j.A,{size:14}),X?"Copied":"Copy"]})]})]}),(0,a.jsx)(v.A,{language:z,children:ec.solution})]}):null]},ec.id)})]})})}},85710:(e,s,t)=>{t.d(s,{A:()=>a});let a=(0,t(71847).A)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])}}]);

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.