PageSourceSearch

https://bridgespace.com/_nuxt/JjrxVb9f.js

js bridgespace.com collected 2026-10-08 11:44:13 UTC 9,808 bytes, 121 lines download raw bytes

1import{_ as R}from"./CTwFDS5i.js";import{_ as A}from"./aBDhE90d.js";import{hK as B,hj as y,o as i,h as r,i as s,hE as o,eF as e,iG as _,hM as z,hX as k,jH as L,jI as J,hD as u,j_ as $,hH as S,hI as D,hC as H,a as V,zs as G,_ as E,kU as M,hW as w}from"./blFblLTI.js";import{_ as U}from"./BndQIhyQ.js";import"./crgW-l9_.js";import"./DG3xe7Qb.js";import"./CrX6QKCC.js";import"./B0Zxaqfz.js";import"./DeOooAGU.js";import"./bX-9EBim.js";import"./DMy4rEpJ.js";import"./C1fIpoIp.js";import"./tY0tdLME.js";import"./D641HPlM.js";import"./yYFsQcMq.js";import"./V2j5bpTC.js";import"./Dl-JG4gq.js";import"./DAEHR4kn.js";import"./BozLPPC_.js";import"./Ce-IctDB.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},p=new a.Error().stack;p&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[p]="90b4f7e5-6518-4414-b00a-d5b5a8f7f30f",a._sentryDebugIdIdentifier="sentry-dbid-90b4f7e5-6518-4414-b00a-d5b5a8f7f30f")}catch{}})();const W={class:"exercise-block"},q={class:"exercise-header"},K={class:"exercise-number"},Q={class:"exercise-lang"},X={class:"exercise-title"},Y={class:"exercise-desc"},Z={class:"test-cases"},ee={class:"test-cases-label"},te={class:"test-cases-grid"},se={class:"test-case-col"},ne={class:"test-case-content"},oe={class:"test-case-col"},ie={class:"test-case-header"},re={class:"test-case-content"},ae={class:"editor-area"},ce={class:"editor-wrapper"},le={class:"editor-loading"},de={class:"actions"},ue=["disabled"],pe={key:0,class:"output"},_e={class:"output-header"},me={key:0,class:"output-stats"},fe={key:1,class:"output-metric"},he={key:2,class:"output-metric"},ge={class:"output-body"},ve={key:0,class:"output-running"},ye={key:0,class:"output-stdout"},be={key:1,class:"output-stderr"},xe={key:2,class:"output-stderr"},ze={key:1,class:"history"},ke=["onClick"],Se={class:"history-num"},Ce={key:0,class:"history-metric"},Ie={class:"history-time"},Oe=B({__name:"ExerciseBlock",props:{exercise:{},index:{}},setup(a){const p=a,b=V().public.apiBaseUrl||"https://api-dev.talentlabs.org",f=y(p.exercise.starterCode),h=y(!1),t=y(null),l=y([]),x=y(!1);async function P(){h.value=!0,t.value=null;try{const n=await $fetch(`${b}/napis/v1/code-runner/submit/`,{method:"POST",headers:{"Content-Type":"application/json"},body:{source_code:f.value,language_id:p.exercise.languageId,stdin:p.exercise.stdin||void 0,expected_output:p.exercise.expectedOutput||void 0}});t.value=n,l.value.unshift(n),n.status==="PROCESSING"&&n.id_slug&&j(n.id_slug)}catch(n){t.value={id_slug:"",status:"FAILED",source_code:f.value,stdout:"",stderr:`Failed: ${n.message||"Unknown error"}`,compile_output:"",execution_time:null,memory_used:null,judge0_status:null,language_id:p.exercise.languageId,created_date:new Date().toISOString()}}finally{h.value=!1}}async function j(n){for(let d=0;d<10;d++){await new Promise(m=>setTimeout(m,2e3));try{const m=await $fetch(`${b}/napis/v1/code-runner/submissions/${n}/`);t.value?.id_slug===n&&(t.value=m);const v=l.value.findIndex(c=>c.id_slug===n);if(v!==-1&&(l.value[v]=m),m.status!=="PROCESSING")break}catch(m){console.error("Poll error:",m),t.value?.id_slug===n&&(t.value={...t.value,status:"FAILED",stderr:G()});break}}}function F(){f.value=p.exercise.starterCode,t.value=null}function T(n){t.value=n}function g(n){return n.judge0_status?.description||n.status||""}function I(n){return n==="Accepted"?"#16a34a":n==="Wrong Answer"?"#d97706":!n||n==="PENDING"||n==="PROCESSING"?"#9ca3af":"#dc2626"}function N(n){return new Date(n).toLocaleTimeString()}return(n,d)=>{const m=A,v=J;return i(),r("div",W,[s("div",q,[s("span",K,"Question "+o(a.index+1),1),s("span",Q,o(a.exercise.language),1)]),s("h3",X,o(a.exercise.title),1),s("p",Y,o(a.exercise.description),1),s("div",Z,[s("div",ee,o(e(_).code_test_cases()),1),s("div",te,[s("div",se,[d[2]||(d[2]=s("div",{class:"test-case-header"},"Input",-1)),s("pre",ne,o(a.exercise.stdin),1)]),s("div",oe,[s("div",ie,o(e(_).code_expected_output()),1),s("pre",re,o(a.exercise.expectedOutput),1)])])]),s("div",ae,[s("div",ce,[z(v,null,{fallback:k(()=>[s("div",le,o(e(_).common_loading()),1)]),default:k(()=>
1[z(m,{modelValue:e(f),"onUpdate:modelValue":d[0]||(d[0]=c=>L(f)?f.value=c:null),lang:a.exercise.language,options:{minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:4},theme:"vs-dark",style:{height:"100%"}},null,8,["modelValue","lang"])]),_:1})])]),s("div",de,[s("button",{class:"btn btn-run",disabled:e(h),onClick:P},o(e(h)?e(_).code_editor_running():e(_).code_editor_run_code()),9,ue),s("button",{class:"btn btn-reset",onClick:F},o(e(_).form_reset()),1),e(l).length>0?(i(),r("button",{key:0,class:"btn btn-history",onClick:d[1]||(d[1]=c=>x.value=!e(x))},o(e(x)?e(_).code_editor_hide_history({count:e(l).length}):e(_).code_editor_show_history({count:e(l).length})),1)):u("",!0)]),e(t)||e(h)?(i(),r("div",pe,[s("div",_e,[d[3]||(d[3]=s("span",{class:"output-label"},"Output",-1)),e(t)?(i(),r("div",me,[g(e(t))?(i(),r("span",{key:0,class:"output-status",style:$({color:I(g(e(t)))})},o(g(e(t))),5)):u("",!0),e(t).execution_time?(i(),r("span",fe,o((e(t).execution_time*1e3).toFixed(0))+"ms ",1)):u("",!0),e(t).memory_used?(i(),r("span",he,o((e(t).memory_used/1024).toFixed(1))+"MB ",1)):u("",!0)])):u("",!0)]),s("div",ge,[e(h)?(i(),r("div",ve,"Running...")):(i(),r(S,{key:1},[e(t)?.stdout?(i(),r("pre",ye,o(e(t).stdout),1)):u("",!0),e(t)?.stderr?(i(),r("pre",be,o(e(t).stderr),1)):u("",!0),e(t)?.compile_output?(i(),r("pre",xe,o(e(t).compile_output),1)):u("",!0)],64))])])):u("",!0),e(x)&&e(l).length>0?(i(),r("div",ze,[(i(!0),r(S,null,D(e(l),(c,O)=>(i(),r("div",{key:c.id_slug||O,class:H(["history-item",{active:e(t)?.id_slug===c.id_slug}]),onClick:Pe=>T(c)},[s("span",Se,"#"+o(e(l).length-O),1),s("span",{class:"history-status",style:$({color:I(g(c))})},o(g(c)),5),c.execution_time?(i(),r("span",Ce,o((c.execution_time*1e3).toFixed(0))+"ms",1)):u("",!0),s("span",Ie,o(N(c.created_date)),1)],10,ke))),128))])):u("",!0)])}}}),$e=Object.assign(E(Oe,[["__scopeId","data-v-171bdd27"]]),{__name:"PageCodeEditorExerciseBlock"}),we=[{id:"python-calculator",title:"Python — Calculator",description:'Implement add, subtract, and multiply functions. Each takes two numbers and returns the result. Read input as "op a b" per line, print the result.',language:"python",languageId:71,starterCode:`import sys
2
3def add(a, b):
4    # TODO: implement
5    pass
6
7def subtract(a, b):
8    # TODO: implement
9    pass
10
11def multiply(a, b):
12    # TODO: implement
13    pass
14
15for line in sys.stdin:
16    parts = line.strip().split()
17    op, a, b = parts[0], float(parts[1]), float(parts[2])
18    if op == "add":
19        print(add(a, b))
20    elif op == "subtract":
21        print(subtract(a, b))
22    elif op == "multiply":
23        print(multiply(a, b))
24`,stdin:`add 2 3
25add -1 1
26subtract 5 3
27multiply 3 4
28multiply 0 100`,expectedOutput:`5.0
290.0
302.0
3112.0
320.0
33`},{id:"java-fizzbuzz",title:"Java — FizzBuzz",description:'Implement the fizzBuzz function. For each number from stdin: return "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for both, or the number as a string.',language:"java",languageId:62,starterCode:`import java.util.Scanner;
34
35public class Main {
36    public static String fizzBuzz(int n) {
37        // TODO: implement
38        return "";
39    }
40
41    public static void main(String[] args) {
42        Scanner sc = new Scanner(System.in);
43        while (sc.hasNextInt()) {
44            System.out.println(fizzBuzz(sc.nextInt()));
45        }
46    }
47}
48`,stdin:`1
492
503
514
525
536
5410
5515
5620
5730`,expectedOutput:`1
582
59Fizz
604
61Buzz
62Fizz
63Buzz
64FizzBuzz
65Buzz
66FizzBuzz
67`},{id:"js-sort-array",title:"JavaScript — Sort & Join Array",description:"Implement sortAndJoin: sort an array of numbers in ascending order and join them into a string. Read JSON arrays from stdin, print the result.",language:"javascript",languageId:63,starterCode:`function sortAndJoin(nums) {
68  // TODO: sort ascending and join into string
69  return "";
70}
71
72const readline = require('readline');
73const rl = readline.createInterface({
74  input: process.stdin,
75  terminal: false
76});
77
78rl.on('line', function (line) {
79  const nums = JSON.parse(line);
80  console.log(sortAndJoin(nums));
81});
82`,stdin:`[5,1,1,2,0,0]
83[5,2,3,1]
84[9,3,7]
85[1]`,expectedOutput:`001125
861235
87379
881
89`},{id:"php-string-reverse",title:"PHP — String Reverse & Palindrome",description:'Implement two functions: reverseString and isPalindrome (case-insensitive). Read commands from stdin as "reverse <str>" or "palindrome <str>".',language:"php",languageId:68,starterCode:`<?php
90
91function reverseString(string $s): string {
92    // TODO: return the reversed string
93    return "";
94}
95
96function isPalindrome(string $s): bool {
97    // TODO: return true if palindrome (case-insensitive)
98    return false;
99}
100
101$stdin = fopen("php://stdin", "r");
102while ($line = fgets($stdin)) {
103    $parts = explode(" ", trim($line), 2);
104    $cmd = $parts[0];
105    $arg = $parts[1] ?? "";
106    if ($cmd === "reverse") {
107        echo reverseString($arg) . "\\n";
108    } elseif ($cmd === "palindrome") {
109        echo (isPalindrome($arg) ? "true" : "false") . "\\n";
110    }
111}
112`,stdin:`reverse hello
113reverse world
114palindrome racecar
115palindrome Madam
116palindrome hello`,expectedOutput:`olleh
117dlrow
118true
119true
120false
121`}],Be={class:"page-content"},De={class:"subtitle"},Ee=B({__name:"index",setup(a){return M({meta:[{id:"robots",name:"robots",content:"noindex,nofollow"}]}),(p,C)=>{const b=R,f=$e,h=U;return i(),w(h,{title:"classroom"},{default:k(()=>[s("div",Be,[z(b,{title:e(_).code_exercises()},null,8,["title"]),s("p",De,o(e(_).code_practice_desc()),1),(i(!0),r(S,null,D(e(we),(t,l)=>(i(),w(f,{key:t.id,exercise:t,index:l},null,8,["exercise","index"]))),128))])]),_:1})}}}),et=E(Ee,[["__scopeId","data-v-6afa200f"]]);export{et 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.