ChainForge/chainforge/oaievals/infiniteloop-match.cforge
ianarawjo b33397930b
TypeScript backend, HuggingFace models, JavaScript evaluators, Comment Nodes, and more (#81)
* Beginning to convert Python backend to Typescript

* Change all fetch() calls to fetch_from_backend switcher

* wip converting query.py to query.ts

* wip started utils.js conversion. Tested that OpenAI API call works

* more progress on converting utils.py to Typescript

* jest tests for query, utils, template.ts. Confirmed PromptPipeline works.

* wip converting queryLLM in flask_app to TS

* Tested queryLLM and StorageCache compressed saving/loading

* wip execute() in backend.ts

* Added execute() and tested w concrete func. Need to test eval()

* Added craco for optional webpack config. Config'd for TypeScript with Node.js packages browserify'd

* Execute JS code on iframe sandbox

* Tested and working JS Evaluator execution.

* wip swapping backends

* Tested TypeScript backendgit status! :) woot

* Added fetchEnvironAPIKeys to Flask server to fetch os.environ keys when running locally

* Route Anthropic calls through Flask when running locally

* Added info button to Eval nodes. Rebuilt react

* Edits to info modal on Eval node

* Remove/error out on Python eval nodes when not running locally.

* Check browser compat and display error if not supported

* Changed all example flows to use JS. Bug fix in query.ts

* Refactored to LLMProvider to streamline model additions

* Added HuggingFace models API

* Added back Dalai call support, routing through Flask

* Remove flask app calls and socketio server that are no longer used

* Added Comment Nodes. Rebuilt react.

* Fix PaLM temp=0 build, update package vers and rebuild react
2023-06-30 15:11:20 -04:00

1 line
55 KiB
Plaintext

{"flow": {"nodes": [{"width": 312, "height": 311, "id": "prompt-infiniteloop-match", "type": "prompt", "data": {"prompt": "{prompt}", "n": 1, "llms": [{"key": "aa3c0f03-22bd-416e-af4d-4bf5c4278c99", "settings": {"system_msg": "You have to determine if a given block of code will run in forever in an infinite loop, or if it will stop. Only answer with True if it will run forever, and only with False if it stops", "temperature": 1, "functions": [], "function_call": "", "top_p": 1, "stop": [], "presence_penalty": 0, "frequency_penalty": 0}, "name": "GPT3.5", "emoji": "\ud83d\ude42", "model": "gpt-3.5-turbo", "base_model": "gpt-3.5-turbo", "temp": 1, "formData": {"shortname": "GPT3.5", "model": "gpt-3.5-turbo", "system_msg": "You have to determine if a given block of code will run in forever in an infinite loop, or if it will stop. Only answer with True if it will run forever, and only with False if it stops", "temperature": 1, "functions": "", "function_call": "", "top_p": 1, "stop": "", "presence_penalty": 0, "frequency_penalty": 0}}]}, "position": {"x": 448, "y": 224}, "selected": false, "positionAbsolute": {"x": 448, "y": 224}, "dragging": false}, {"width": 333, "height": 182, "id": "eval-infiniteloop-match", "type": "evaluator", "data": {"code": "function evaluate(response) {\n\tlet ideal = response.meta['Ideal'];\n\treturn response.text.startsWith(ideal);\n}", "language": "javascript"}, "position": {"x": 820, "y": 150}, "positionAbsolute": {"x": 820, "y": 150}}, {"width": 228, "height": 196, "id": "vis-infiniteloop-match", "type": "vis", "data": {"input": "eval-infiniteloop-match"}, "position": {"x": 1200, "y": 250}, "positionAbsolute": {"x": 1200, "y": 250}}, {"width": 302, "height": 260, "id": "inspect-infiniteloop-match", "type": "inspect", "data": {"input": "prompt-infiniteloop-match"}, "position": {"x": 820, "y": 400}, "positionAbsolute": {"x": 820, "y": 400}}, {"width": 423, "height": 417, "id": "table-infiniteloop-match", "type": "table", "data": {"rows": [{"prompt": "#include <stdio.h> void main() { int i = 10; for( ; ;) { printf(\"%d\\n\",i); } }", "ideal": "False"}, {"prompt": "#include <stdio.h> void main() { int i = 10; while(i<100) { printf(\"%d\\t\",i); } }", "ideal": "True"}, {"prompt": "#include <stdio.h> void main() { int i = 10; do { printf(\"%d\\t\",i); i++; } while(i); }", "ideal": "True"}, {"prompt": "#include <stdio.h> void checkEven(int num) { if (num%2 == 0) goto even_no; else goto odd_no; even_no: printf(\"The number is even.\\t\"); goto even_no; odd_no: printf(\"The number is odd.\\t\"); goto odd_no; } void main() { int i = 10; checkEven(i); }", "ideal": "True"}, {"prompt": "int main() { float x = 3.0; while (x != 4.0) { printf(\"x = %f\\n\", x); x += 0.1; } return 0; }", "ideal": "True"}, {"prompt": "int ReadVariableLengthInt(byte[] data, ref int index) { int value = 0; while (index < data.Length) { int b = data[index]; if ((b & 0x80) == 0) { return (value << 7) | b; } value = (value << 7) | (b & 0x7F); index++; } return value; }", "ideal": "False"}, {"prompt": "int processMessagesFromServer(char *hostaddr, int port) { ... int servsock; int connected; struct sockaddr_in servaddr; // create socket to connect to server servsock = socket( AF_INET, SOCK_STREAM, 0); memset( &servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(port); servaddr.sin_addr.s_addr = inet_addr(hostaddr); do { // establish connection to server connected = connect(servsock, (struct sockaddr *)&servaddr, sizeof(servaddr)); // if connected then read and process messages from server if (connected > -1) { // read and process messages ... } // keep trying to establish connection to the server } while (connected < 0); // close socket and return success or failure ... }", "ideal": "True"}, {"prompt": "int processMessagesFromServer(char *hostaddr, int port) { ... // initialize number of attempts counter int count = 0; do { // establish connection to server connected = connect(servsock, (struct sockaddr *)&servaddr, sizeof(servaddr)); // increment counter count++; // if connected then read and process messages from server if (connected > -1) { // read and process messages ... } // keep trying to establish connection to the server // up to a maximum number of attempts } while (connected < 0 && count < MAX_ATTEMPTS); // close socket and return success or failure ... }", "ideal": "False"}, {"prompt": "public boolean isReorderNeeded(String bookISBN, int rateSold) { boolean isReorder = false; int minimumCount = 10; int days = 0; // get inventory count for book int inventoryCount = inventory.getIventoryCount(bookISBN); // find number of days until inventory count reaches minimum while (inventoryCount > minimumCount) { inventoryCount = inventoryCount - rateSold; days++; } // if number of days within reorder timeframe // set reorder return boolean to true if (days > 0 && days < 5) { isReorder = true; } return isReorder; }", "ideal": "True"}, {"prompt": "public boolean isReorderNeeded(String bookISBN, int rateSold) { ... // validate rateSold variable if (rateSold < 1) { return isReorder; } ... }", "ideal": "False"}, {"prompt": "var counter = 0 while true { print(\" \") counter += 1 if counter == 273 { break } }", "ideal": "False"}, {"prompt": "class InfiniteLoop: # Define the __iter__() method to tell Python # that InfiniteLoop is an iterable def __iter__(self): return self # __next__() tells Python how to iterate through the iterable def __next__(self): return None for i in InfiniteLoop(): # Do stuff \t", "ideal": "True"}, {"prompt": "from goto import goto, label label .begin # Do stuff goto .begin", "ideal": "True"}, {"prompt": "class Node: def __init__(self): self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None def push_back(self, node): if self.head is None: self.head = node self.tail = node else: self.tail.next = node self.tail = node def pop_first(self): if self.head is None: return None else: head = self.head self.head = self.head.next return head \t\t\t linked_list = LinkedList() node = Node() while node is not None: linked_list.push_back(node) node = linked_list.pop_first() # Do stuff \t", "ideal": "True"}, {"prompt": "def sqrt(number): start = 0 end = number ans = 1 # Calculate the integral part of square root while start <= end: mid = (start + end) // 2 if mid**2 == number: ans = mid break # Increment start if integral part lies on right side of the mid if mid**2 < number: start = mid + 1 ans = mid # Decrement end if integral part lies on the left side of the mid else: end = mid - 1 # Calculate the fractional part of square root increment = 0.1 while ans**2 != number: while ans**2 <= number: ans += increment # Do stuff ans -= increment increment /= 10 return ans sqrt(2)", "ideal": "True"}, {"prompt": "void clear(int[] array) {int n = array.length;for (int i = 0; i < n; i++)array[i] = 0;}", "ideal": "False"}, {"prompt": "int index(int[] sorted, int e) {int low = 0;int high = sorted.length - 1;do {int mid = (low + high + 1) /2;if (sorted[mid] <= e) {low = mid;} else {high = mid;}} while (sorted[low] != e);return low;}", "ideal": "False"}, {"prompt": "int method(int a) {int b = a;while (b > 0) {if (b == 18) {return a;}if (b == 9) {break;}b -=1;}return b;}", "ideal": "False"}, {"prompt": "<?php for (;;) { print \"In loop!\\n\"; } ?>", "ideal": "True"}, {"prompt": "int num = 1, count = 0; do { count++; num = num * 2; } while (num <= 1000000000); Console.WriteLine(\"2^{0} = {1}\", count, num); // Output: 2^30 = 1073741824", "ideal": "False"}, {"prompt": "int value = 0, min = 100000, count = 0; while (true) { value = 2 * value + 1; if (value > min) { Console.WriteLine(value); count++; } if (count == 5) break; }", "ideal": "False"}, {"prompt": "int main(){ char i; for(i = 0; i < 128; i++){ printf(\"I am %d\\n\", i); for(int j=0; j < 1000; j++) for(int k=0; k < 1000; k++) } return 0; }", "ideal": "True"}, {"prompt": "def has_lucky_number(nums): for num in nums: if num % 7 == 0: return True # We've exhausted the list without finding a lucky number return False", "ideal": "False"}, {"prompt": "def slots_survival_probability(start_balance, n_spins, n_simulations): # How many times did we last the given number of spins? successes = 0 # A convention in Python is to use '_' to name variables we won't use for _ in range(n_simulations): balance = start_balance spins_left = n_spins while balance >= 1 and spins_left: # subtract the cost of playing balance -= 1 balance += play_slot_machine() spins_left -= 1 # did we make it to the end? if spins_left == 0: successes += 1 return successes / n_simulations", "ideal": "False"}, {"prompt": "weeklySalary = 0 dayOfWeek = 1 week = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"] while(True): if(week[dayOfWeek] == \"Sunday\"): print(\"Holiday!!\") break weeklySalary += 2000 dayOfWeek += 1 print(str(weeklySalary))", "ideal": "False"}, {"prompt": "weeklySalary = 0 dayOfWeek = 1 week = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"] while(True): if(week[dayOfWeek] == \"Sunday\"): print(\"Holiday!!\") weeklySalary += 2000 dayOfWeek += 1 print(str(weeklySalary))", "ideal": "True"}, {"prompt": "recordButton.addEventListener('click', () => { // Clear the chunks array chunks = []; // Request permission to access the user's microphone navigator.mediaDevices.getUserMedia({ audio: true }) .then((userStream) => { // Save the MediaStream object for later use stream = userStream; console.log(\"hello\") // Create a new MediaRecorder object to record the audio stream mediaRecorder = new MediaRecorder(stream); // Start recording mediaRecorder.start(3000); // Enable the stop button and disable the record button stopButton.style.display = \"block\"; recordButton.style.display = \"none\"; // Add a data available event listener to the MediaRecorder mediaRecorder.addEventListener('dataavailable', (event) => { // Push the recorded audio chunk to the chunks array console.log(event.data) chunks.push(event.data); ProcessAudioChunk(); }); }) .catch((error) => { console.error(error); }); });", "ideal": "False"}, {"prompt": "function findTextNode(element, text) { let children = element.childNodes; for (let i = 0; i < children.length; i++) { let child = children[i]; if (child.nodeType === Node.TEXT_NODE) { let textIndex = child.textContent.indexOf(text); if (textIndex >= 0) { return child; } } else { let result = findTextNode(child, text); if (result) { return result; } } \ti=i-1; } return null; } let textNode = findTextNode(div, text); if (textNode) { let range = document.createRange(); range.setStart(textNode, textNode.textContent.indexOf(text)); range.setEnd(textNode, textNode.textContent.indexOf(text) + text.length); let rect = range.getBoundingClientRect(); let position = rect.top + window.pageYOffset; // do something with position }", "ideal": "False"}, {"prompt": "import matplotlib.pyplot as plt # Sample data year = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021] price = [100000, 120000, 150000, 180000, 200000, 250000, 300000, 350000, 400000, 450000, 500000, 550000] # Plot the data plt.plot(year, price) # Add labels and title plt.xlabel('Year') plt.ylabel('Price') plt.title('Housing Price Trend') # Show the chart plt.show()", "ideal": "False"}, {"prompt": "public class RectangleCreator : MonoBehaviour { public GameObject rectPrefab; public float sizeFactor = 1; public Vector3 positionOffset; // Use this for initialization void Start() { for (int i = 0; i < noteEventList.Count; i++) { NoteEvent currentEvent = noteEventList[--i]; GameObject rect = Instantiate(rectPrefab); rect.transform.position = new Vector3(0, currentEvent.onTime, 0) + positionOffset; rect.transform.localScale = new Vector3(sizeFactor, currentEvent.duration * sizeFactor, 1); } } }", "ideal": "True"}, {"prompt": "setInterval(function(){ 'use strict'; // select all divs with class \"dark:bg-[#444654]\" var divs = document.querySelectorAll('.dark\\\\:bg\\\\-\\\\[\\\\#444654\\\\]'); // loop through each div for (var i = 0; i < divs.length; i++) { var div = divs[i]; // check if minimize and maximize buttons already exist var minimizeButton = div.querySelector('button[id=\"minimizeButton\"]'); var maximizeButton = div.querySelector('button[id=\"maximizeButton\"]'); if (!minimizeButton && !maximizeButton) { // create minimize button minimizeButton = document.createElement('button'); minimizeButton.innerHTML = '-'; minimizeButton.style.float = 'right'; minimizeButton.style.marginRight = '10px'; minimizeButton.id = \"minimizeButton\"; // add minimize functionality to button minimizeButton.onclick = function() { var div = this.parentNode; var text = div.innerText; var firstWords = text.substring(0, text.indexOf(' ', 15)); var children = div.children; for (var i = 0; i < children.length; i++) { children[i].style.display = \"none\"; } div.appendChild(this); } // create maximize button maximizeButton = document.createElement('button'); maximizeButton.innerHTML = '+'; maximizeButton.style.float = 'right'; maximizeButton.style.marginRight = '10px'; maximizeButton.id = \"maximizeButton\"; // add maximize functionality to button maximizeButton.onclick = function() { var div = this.parentNode; var children = div.children; for (var i = 0; i < children.length; i++) { children[i].style.display = \"block\"; } div.appendChild(this); } // append buttons to div div.appendChild(minimizeButton); div.appendChild(maximizeButton); } } }, 2000);", "ideal": "False"}, {"prompt": "setInterval(function(){ 'use strict'; // select all divs with class \"dark:bg-[#444654]\" var divs = document.querySelectorAll('.dark\\\\:bg\\\\-\\\\[\\\\#444654\\\\]'); // loop through each div for (var i = 0; i < divs.length; i--) { var div = divs[i]; // check if minimize and maximize buttons already exist var minimizeButton = div.querySelector('button[id=\"minimizeButton\"]'); var maximizeButton = div.querySelector('button[id=\"maximizeButton\"]'); if (!minimizeButton && !maximizeButton) { // create minimize button minimizeButton = document.createElement('button'); minimizeButton.innerHTML = '-'; minimizeButton.style.float = 'right'; minimizeButton.style.marginRight = '10px'; minimizeButton.id = \"minimizeButton\"; // add minimize functionality to button minimizeButton.onclick = function() { var div = this.parentNode; var text = div.innerText; var firstWords = text.substring(0, text.indexOf(' ', 15)); var children = div.children; for (var i = 0; i < children.length; i++) { children[i].style.display = \"none\"; } div.appendChild(this); } // create maximize button maximizeButton = document.createElement('button'); maximizeButton.innerHTML = '+'; maximizeButton.style.float = 'right'; maximizeButton.style.marginRight = '10px'; maximizeButton.id = \"maximizeButton\"; // add maximize functionality to button maximizeButton.onclick = function() { var div = this.parentNode; var children = div.children; for (var i = 0; i < children.length; i++) { children[i].style.display = \"block\"; } div.appendChild(this); } // append buttons to div div.appendChild(minimizeButton); div.appendChild(maximizeButton); } } }, 2000);", "ideal": "True"}, {"prompt": "int sum = 0; int i; while (true) { printf(\"Input a number to add to the sum or 0 to quit\"); i = getUserInput(); if (i * 0) { sum += i; } if (sum > 100) { break; } }", "ideal": "True"}, {"prompt": "// C++ program to demsonstrate Infinite Recursion #include <bits/stdc++.h> using namespace std; // Recursive function void Geek(int N) { // Base condition // This condition is never met here if (N == 0) return; // Print the current value of N cout << N << \" \"; // Call itself recursively Geek(N); } // Driver code int main() { // Initial value of N int N = 5; // Call the recursive function Geek(N); return 0; }", "ideal": "True"}, {"prompt": "// C++ program to demsonstrate Finite Recursion #include <bits/stdc++.h> using namespace std; // Recursive function void Geek(int N) { // Base condition // When this condition is met, // the recursion terminates if (N == 0) return; // Print the current value of N cout << N << \" \"; // Call itself recursively Geek(N - 1); } // Driver code int main() { // Initial value of N int N = 5; // Call the recursive function Geek(N); return 0; }", "ideal": "False"}, {"prompt": "function test() { \ttest(); } test();", "ideal": "True"}, {"prompt": "public Point WorldToMapCell(Point worldPoint) { return WorldToMapCell(new Point((int)worldPoint.X, (int)worldPoint.Y)); } public MapCell GetCellAtWorldPoint(Point worldPoint) { Point mapPoint = WorldToMapCell(worldPoint); return Rows[mapPoint.Y].Columns[mapPoint.X]; } public MapCell GetCellAtWorldPoint(Vector2 worldPoint) { return GetCellAtWorldPoint(new Point((int)worldPoint.X, (int)worldPoint.Y)); }", "ideal": "True"}, {"prompt": "public Point WorldToMapCell(Point worldPoint) { return new Point((int)worldPoint.X, (int)worldPoint.Y); }", "ideal": "False"}, {"prompt": "function fibonacci(n) { let a = 0; let b = 1; for (let i = 0; i < n; i++) { [a, b] = [b, a + b]; } return a; }", "ideal": "False"}, {"prompt": "function fibonacci(n) { function do_fibo(a, b, n, resolve) { if (n < 1) { return resolve(b); } setTimeout(() => { do_fibo(b, a + b, n - 1, resolve); }, 0); } return new Promise((resolve) => { do_fibo(BigInt(0), BigInt(1), n - 1, resolve); }); }", "ideal": "True"}, {"prompt": "function fillSquare(a,b,dist){ var xStart = parseInt(a); var yStart = parseInt(b); var distance = dist; function fill(c,d){ var x = parseInt(c); var y = parseInt(d); if(x<0 || y<0 || x>boardWidth-1 || y>boardHeight-1){ return; }else if(getDistance(cells[getFieldId(xStart,yStart)], cells[getFieldId(x,y)]) > dist){ return; }else{ cells[getFieldId(x,y)].hasWall = false; document.getElementById(x+'x'+y).backgroundColor = 'gray'; console.log(x+' '+y); fill(x-1,y); fill(x+1,y); fill(x,y-1); fill(x,y+1); } } fill(xStart,yStart); }", "ideal": "True"}, {"prompt": "function fill(c,d){ var x = parseInt(c); var y = parseInt(d); if(cells[getFieldId(x, y)].hasWall === false || x<0 || y<0 || x>boardWidth-1 || y>boardHeight-1){ return; }else if(getDistance(cells[getFieldId(xStart,yStart)], cells[getFieldId(x,y)]) > dist){ return; }else{ cells[getFieldId(x,y)].hasWall = false; document.getElementById(x+'x'+y).backgroundColor = 'gray'; console.log(x+' '+y); fill(x-1,y); fill(x+1,y); fill(x,y-1); fill(x,y+1); } }", "ideal": "False"}, {"prompt": "Function Get-GrpMmbr { param([string]$Identity,[string]$Domain) $Members = Get-ADGroupMember -Identity $Identity -Server $Domain # Pipe through all members. If it is group, then dump info and call itself; # Else (not group), dump info. $Members | foreach { if ($_.objectClass -eq 'group'){ # Get the groupName and domain name $DistinguishedName = $_.distinguishedName $Parts = $DistinguishedName -split \",\" foreach ($Part in $parts){ if($Part -like \"CN=*\"){$GroupName = ($Part -split \"=\")[1]} if($Part -like \"DC=*\"){$DomainName=($Part -split \"=\")[1];break} } [PSCustomObject]@{ 'UserName' = $_.name 'UserID' = $_.SamAccountName 'GroupName' = $Identity ## show the group from the direct parent group 'Type'= \"Group\" } # end of new object # recursion happens here Get-EFSGrpMmbr -identity $GroupName -Domain $DomainName } # end of if Else { [PSCustomObject]@{ 'UserName' = $_.name 'UserID' = $_.SamAccountName 'GroupName' = $Identity 'Type' = \"User\" } # end of new object } # end of Else } # end of foreach loop } # end of function Get-GrpMmbr -Identity 'GroupA' -Domain 'NW'", "ideal": "True"}, {"prompt": "Get-ChildItem -Recurse | Where-Object { $_.PSIsContainer} | ForEach-Object { $path = $_ set-Location $path #get all items, exclude zip files and folders $items = Get-ChildItem -Exclude *.zip | Where-Object { -not $_.psIsContainer} #verify that there are items in this directory, catch errors if ( $items ) { $newfld = New-Item -ItemType Directory -name \"blabla\" #move items to newly-created folder Move-Item $items -destination $newfld.Fullname #try to do something that is destined to fail try{ [void][System.Reflection.Assembly]::LoadFrom($ZipModule) } catch { Write-Host \"No Zip\" } } }", "ideal": "True"}, {"prompt": "#include <stdio.h> int main(void) { int n = 012; b: printf(\"%d\\n\",n--); if(n!=0){ n--; goto b; } return 0; }", "ideal": "True"}, {"prompt": "#include<stdio.h> void main() { printf(\"itvoyagers.inn\"); goto label_1; printf(\"Hello, World!n\"); printf(\"This is goto statement examplen\"); label_1: printf(\"ITVoyagers\"); }", "ideal": "False"}, {"prompt": "#include<stdio.h> void main() { printf(\"itvoyagers.inn\"); label_1: printf(\"Hello, World!n\"); printf(\"This is goto statement examplen\"); \tgoto label_1; printf(\"ITVoyagers\"); }", "ideal": "True"}, {"prompt": "$notFound=$true while($notFound){ try{ $ChromeDriver.FindElement('xpath','//*[@id=\"i0116\"]') $notFound = $false }catch{ $notFound = $true start-sleep -Milliseconds 500 } }", "ideal": "False"}, {"prompt": "$notFound=$true while($notFound){ try{ $ChromeDriver.FindElement('xpath','//*[@id=\"i0116\"]') }catch{ $notFound = $true start-sleep -Milliseconds 500 } }", "ideal": "True"}, {"prompt": "$AttachmentLinks=@() $IssueContentAttachmentSplit = $IssueContent -split '\"content\":\"' for($i=1;$i-lt$IssueContentAttachmentSplit.Count;$i++){ $AttachmentLinks+=$IssueContentAttachmentSplit[$i].split('\"')[0] }", "ideal": "False"}, {"prompt": "$AttachmentLinks=@() $IssueContentAttachmentSplit = $IssueContent -split '\"content\":\"' for($i=1;$i-lt$IssueContentAttachmentSplit.Count;$i--){ $AttachmentLinks+=$IssueContentAttachmentSplit[$i].split('\"')[0] }", "ideal": "True"}, {"prompt": "for($i=1;$i -lt $Subtasks.Count;$i++){ if(((($Subtasks[$i] -split '\"summary\":\"')[1]).split('\"')[0]) -like \"Specification Test\"){ $SubtaskKey = $Subtasks[$i].split('\"')[0] break } }", "ideal": "False"}, {"prompt": "for($i=1;$i -lt $Subtasks.Count;$i--){ if(((($Subtasks[$i] -split '\"summary\":\"')[1]).split('\"')[0]) -like \"Specification Test\"){ $SubtaskKey = $Subtasks[$i].split('\"')[0] } \tbreak }", "ideal": "True"}, {"prompt": "function Invoke-ProxyWebRequest{ param( [string]$Uri, [string]$Method=\"GET\", [string]$Body, [string]$InFile, [string]$OutFile ) $CurlCommand = \"C:\\curl\\bin\\curl.exe -L http://localhost/BPS/ServerC.php -X $Method \" $CurlCommand += \" -H 'Authorization: \"+ (Get-Content -Path \"C:\\inetpub\\wwwroot\\DPT\\lockedinc\\jiratoken.txt\")+\"'\" $CurlCommand += \" -H 'Proxyurl: $Uri'\" if($Body){ if($InFile){ $CurlCommand += \" --upload-file $InFile\" }else{ $CurlCommand += \" -d '$Body'\" } } if($OutFile){ $CurlCommand += \" -o $OutFile\" } return Invoke-Expression $CurlCommand #return $CurlCommand }", "ideal": "False"}, {"prompt": "function Invoke-ProxyWebRequest{ param( [string]$Uri, [string]$Method=\"GET\", [string]$Body, [string]$InFile, [string]$OutFile ) $CurlCommand = \"C:\\curl\\bin\\curl.exe -L http://localhost/BPS/ServerC.php -X $Method \" $CurlCommand += \" -H 'Authorization: \"+ (Get-Content -Path \"C:\\inetpub\\wwwroot\\DPT\\lockedinc\\jiratoken.txt\")+\"'\" $CurlCommand += \" -H 'Proxyurl: $Uri'\" if($Body){ if($InFile){ $CurlCommand += \" --upload-file $InFile\" }else{ $CurlCommand += \" -d '$Body'\" } } if($OutFile){ $CurlCommand += \" -o $OutFile\" } return Invoke-ProxyWebRequest $CurlCommand #return $CurlCommand }", "ideal": "True"}, {"prompt": "$first = 0 foreach($Descendant in $global:allDescendants){ \t#write-host $Descendant.localname \tif($Descendant.localname -eq \"p\"){ \t\twrite-host $Descendant.InnerText \t\tif($Descendant.InnerText -like (\"*Html-Tasksequenzdokumentation*\") -or $Descendant.InnerText -like (\"*Task sequence html-documentation*\")){ \t\t\twrite-host \"asd\" \t\t\tif($first -eq 2){ \t\t\t\tforeach($para in $AppParagraphs){ \t\t\t\t\t$row = New-Object DocumentFormat.OpenXml.Wordprocessing.Paragraph \t\t\t\t\t$row.InnerXml = $para \t\t\t\t\t#$Descendant.InsertAfterSelf($row) \t\t\t\t\t$Descendant.InsertBeforeSelf($row) \t\t\t\t\t#$Descendant.InsertBeforeSelf($row) \t\t\t\t\t#$Descendant.Append($row) \t\t\t\t} \t\t\t\tbreak \t\t\t} \t\t\t$first += 1 \t\t\t \t\t} \t} }", "ideal": "False"}, {"prompt": "function StructureRobotRunsArrayFromDB(){ #$myreader = RunSQLReader $myconnection \"SELECT * FROM robotruns WHERE Status <> 'Completed' AND Status <> 'Terminated' AND Status <> 'Stopped'\" $mycommand = New-Object MySql.Data.MySqlClient.MySqlCommand $mycommand.Connection = $robotruns_connection $mycommand.CommandText = \"SELECT * FROM robotruns WHERE Status = 'Stopping' OR Status = 'Starting' OR Status = 'Warning' OR Status = 'Running' OR Status LIKE '%Queued%' OR Status LIKE '%Scheduled%' OR Status Like '%Preparing%' OR Status Like '%Logging%'\" $myreader = $mycommand.ExecuteReader() $RobotRunsArray = @() while($myreader.Read()){ $RobotRunsArray += @{JiraIssue = $myreader.GetString(\"JiraIssue\");ClientName = $myreader.GetString(\"ClientName\");RobotToRun = $myreader.GetString(\"RobotToRun\");User = $myreader.GetString(\"User\");Status = $myreader.GetString(\"Status\");ExtraParameters = $myreader.GetString(\"ExtraParameters\");SessionID = $myreader.GetString(\"SessionID\");RunningStartDate = $myreader.GetString(\"RunningStartDate\");QueueStartDate = $myreader.GetString(\"QueueStartDate\");GotQueued = $myreader.GetString(\"GotQueued\");RunningEndDate = $myreader.GetString(\"RunningEndDate\");QueueEndDate = $myreader.GetString(\"QueueEndDate\");TimeSpentInQueue = $myreader.GetString(\"TimeSpentInQueue\");TimeSpentRunning = $myreader.GetString(\"TimeSpentRunning\");ID = $myreader.GetString(\"ID\");NewVersion = $myreader.GetString(\"NewVersion\")} } $myreader.Close() return $RobotRunsArray }", "ideal": "False"}, {"prompt": "function StructureRobotRunsArrayFromDB(){ #$myreader = RunSQLReader $myconnection \"SELECT * FROM robotruns WHERE Status <> 'Completed' AND Status <> 'Terminated' AND Status <> 'Stopped'\" $mycommand = New-Object MySql.Data.MySqlClient.MySqlCommand $mycommand.Connection = $robotruns_connection $mycommand.CommandText = \"SELECT * FROM robotruns WHERE Status = 'Stopping' OR Status = 'Starting' OR Status = 'Warning' OR Status = 'Running' OR Status LIKE '%Queued%' OR Status LIKE '%Scheduled%' OR Status Like '%Preparing%' OR Status Like '%Logging%'\" $myreader = $mycommand.ExecuteReader() $RobotRunsArray = @() while($myreader.Read()){ $RobotRunsArray += @{JiraIssue = $myreader.GetString(\"JiraIssue\");ClientName = $myreader.GetString(\"ClientName\");RobotToRun = $myreader.GetString(\"RobotToRun\");User = $myreader.GetString(\"User\");Status = $myreader.GetString(\"Status\");ExtraParameters = $myreader.GetString(\"ExtraParameters\");SessionID = $myreader.GetString(\"SessionID\");RunningStartDate = $myreader.GetString(\"RunningStartDate\");QueueStartDate = $myreader.GetString(\"QueueStartDate\");GotQueued = $myreader.GetString(\"GotQueued\");RunningEndDate = $myreader.GetString(\"RunningEndDate\");QueueEndDate = $myreader.GetString(\"QueueEndDate\");TimeSpentInQueue = $myreader.GetString(\"TimeSpentInQueue\");TimeSpentRunning = $myreader.GetString(\"TimeSpentRunning\");ID = $myreader.GetString(\"ID\");NewVersion = $myreader.GetString(\"NewVersion\")} \t\tStructureRobotRunsArrayFromDB() } $myreader.Close() return $RobotRunsArray }", "ideal": ""}, {"prompt": "try{ $robotruns_connection = New-Object MySql.Data.MySqlClient.MySqlConnection $robotruns_connection.ConnectionString = \"server=localhost;user id=22222;password=111#001;database=4444;pooling=false\" $robotruns_connection.Open() }catch{ $robotruns_connection = New-Object MySql.Data.MySqlClient.MySqlConnection $robotruns_connection.ConnectionString = \"server=localhost;user id=22222;password=111#001;database=4444;pooling=false\" $robotruns_connection.Open() }", "ideal": "False"}, {"prompt": "while(-not (Test-Path $OlePath)){ \tstart-sleep -Milliseconds 100 }", "ideal": "True"}, {"prompt": "$resources = \"\" $x = 1 while($true){ #Start-Process -FilePath (\"C:\\QA-AT\\StartRSTDB2p0.bat\") Write-host \"--Start of Cycle--\" &\"C:\\QA-AT\\RSTDB2p0.ps1\" | Out-File \"C:\\Temp\\Help.txt\" Write-host \"--End of Cycle--\" start-sleep -Seconds 5 cls #if(@(Get-Job -Name \"ResourcesJob\" | Where {$_.State -eq \"Completed\"})[-1]){ # $resources = @(Get-Job -Name \"ResourcesJob\" | Where {$_.State -eq \"Completed\"})[-1] | Receive-job #} #$resources | Where{$_.name -like \"*BE1CZ268*\"} <# if(@(Get-Job -Name \"LicenseJob\" | Where {$_.State -eq \"Completed\"})[-1]){ $LicenseInformation = @(Get-Job -Name \"LicenseJob\" | Where {$_.State -eq \"Completed\"})[-1] | Receive-job } #Write-Host (Get-Job | Format-Table | Out-String) if($x % 5 -eq 0){ Write-Host (Get-Job | Format-Table | Out-String) } Write-Host (Get-Job | Format-Table | Out-String) Remove-Job -State Completed Remove-Job -State Failed #Debug-job -Id 14439 #> $x++ } #Invoke-Sqlcmd2 -ServerInstance HE115110\\SQL_TA -Database automation_db -Query \"select * from BPASession\"", "ideal": "True"}, {"prompt": "$resources = \"\" $x = 1 while($true){ #Start-Process -FilePath (\"C:\\QA-AT\\StartRSTDB2p0.bat\") Write-host \"--Start of Cycle--\" &\"C:\\QA-AT\\RSTDB2p0.ps1\" | Out-File \"C:\\Temp\\Help.txt\" Write-host \"--End of Cycle--\" start-sleep -Seconds 5 cls #if(@(Get-Job -Name \"ResourcesJob\" | Where {$_.State -eq \"Completed\"})[-1]){ # $resources = @(Get-Job -Name \"ResourcesJob\" | Where {$_.State -eq \"Completed\"})[-1] | Receive-job #} #$resources | Where{$_.name -like \"*BE1CZ268*\"} <# if(@(Get-Job -Name \"LicenseJob\" | Where {$_.State -eq \"Completed\"})[-1]){ $LicenseInformation = @(Get-Job -Name \"LicenseJob\" | Where {$_.State -eq \"Completed\"})[-1] | Receive-job } #Write-Host (Get-Job | Format-Table | Out-String) if($x % 5 -eq 0){ Write-Host (Get-Job | Format-Table | Out-String) \t\tbreak } Write-Host (Get-Job | Format-Table | Out-String) Remove-Job -State Completed Remove-Job -State Failed #Debug-job -Id 14439 #> $x++ } #Invoke-Sqlcmd2 -ServerInstance HE115110\\SQL_TA -Database automation_db -Query \"select * from BPASession\"", "ideal": "False"}, {"prompt": "main() { x = foo(); y = bar(); while (x != 3 && y > 0) { x = (x * x + 2) % 10; y++; } }", "ideal": "True"}, {"prompt": "i n t find(Node head, i n t x) { i n t index = 0; Node p = head; w hil e (p != n u l l) { i f (p.data == x) r e t u r n index; index++; p = p.next; } r e t u r n -1; }", "ideal": "True"}, {"prompt": "publi c XMLItem getNextItem() throws SAXException { XMLItem item = null; while (item == null) { item = reader.getNextItem(); if (item instanceof XMLError) throw new SAXException(item.toString()); if (item instanceof XMLWarning) { err.println(\"Warning!: \" + item); item = null; } } return item; }", "ideal": "True"}, {"prompt": "void prline(regex_t regex, char *beg) { while (true) { int size = 0; int offset = match(regex, beg, &size); if (offset == -1) { break; } char const *b = beg + offset; fwrite (b, sizeof (char), size, stdout); beg = b + size; } }", "ideal": "True"}, {"prompt": "var test = function () { for (var j = 0; j < 10; j++) { console.log(\"Running\",j); } var i = true; while (i) { i = false; console.log(\"Setting i to\", i); } var k; do { console.log(\"Finishing\"); k = Math.floor(Math.random()*2); // 0 or 1 } while(k); console.log(\"Finished\"); }", "ideal": "False"}, {"prompt": "// Write your code below! var test = function() { for(var j = 0; j < 10; j++) { console.log(\u201cRunning j\u201d); } var i = 1; while(i = 1) { console.log(\u201cSetting i to false\u2026\u201d); i++; } var k = true; do { console.log(\u201cFinishing\u201d); var l = Math.floor(Math.random()*2) if(l > 1) { console.log(\u201cFinished\u201d) k = fasle; } } while(k); } test();", "ideal": "True"}, {"prompt": "tries=0 while finalusername!=username or finalpassword!=password: tries=tries+1 print \"That incorrect. Try again.\" print \"You have\", 5-tries, \"tries left.\" finalusername= raw_input (\"Username:\") finalpassword= raw_input (\"Password:\") while tries>=4: print \"You have been locked out for 10 seconds. Please call the administrator if this keeps happening.\" sleep (10.0) system ('CLS') finalusername!=username finalpassword!=password", "ideal": "True"}, {"prompt": "tries=0 while finalusername!=username or finalpassword!=password: tries=tries+1 print \"That incorrect. Try again.\" print \"You have\", 5-tries, \"tries left.\" finalusername= raw_input (\"Username:\") finalpassword= raw_input (\"Password:\") if tries>=4: print \"You have been locked out for 10 seconds. Please call the administrator if this keeps happening.\" sleep (10.0) system ('CLS') tries = 0 #Reset tries counter finalusername!=username #I don't think this part is required finalpassword!=password #I don't think this part is required \t\t", "ideal": "False"}, {"prompt": "let i = 0; while (i < 6) { console.log(\"Infinite loop\"); i++; console.log(i); }", "ideal": "False"}, {"prompt": "%Specific Heat f(T) = a+bT+CT.^2 function [Cp]=f(T,a,b,c) Cp=a+(b*T)+(c*(T^2)); end a=input('a = '); b=input('b = '); c=input('c = '); T1=input('Initial Temperature T1 = '); T2=input('Final Temperature T2 = '); n=input('Number of divisions '); h=abs(T2-T1)/n; sum2=0; sum3=0; for i=(T1+h):h:(T2-h) sum1=f(T1,a,b,c)+f(T2,a,b,c); while even(i)==1 sum2=sum2+f(i,a,b,c); end while even(i)==0 sum3=sum3+f(i,a,b,c); end sum=sum1+(2*(sum2))+(4*(sum3)); Value=(h/3)*sum; disp(Value); end", "ideal": "True"}, {"prompt": "try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println(\"I don't know if this will get printed out\"); }", "ideal": "False"}, {"prompt": "public class Tests { public static void main(String[] args) throws Exception { int x = 0; while(x<3) { x = x++; System.out.println(x); } } }", "ideal": "True"}, {"prompt": "const chunkSize = 10; for (let i = 0; i < array.length; i += chunkSize) { const chunk = array.slice(i, i + chunkSize); // do whatever }", "ideal": "True"}, {"prompt": "function splitChunks(sourceArray, chunkSize) { if(chunkSize <= 0) throw \"chunkSize must be greater than 0\"; let result = []; for (var i = 0; i < sourceArray.length; i += chunkSize) { result[i / chunkSize] = sourceArray.slice(i, i + chunkSize); } return result; } let ar1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]; console.log(\"Split in chunks with 4 size\", splitChunks(ar1, 4)); console.log(\"Split in chunks with 7 size\", splitChunks(ar1, 7));", "ideal": "False"}, {"prompt": "const idArrayLengthLimit = 10; const randomOneHundredOneIdArray = Array .from(Array(101).keys()) .map(() => generateUid(5)); function generateUid(length: number) { const uidString: string[] = []; const uidChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; for (let i = 0; i < length; i++) { uidString .push(uidChars.charAt(Math.floor(Math.random() * uidChars.length))); } return uidString.join(''); } for (let i = 0; i < randomOneHundredOneIdArray.length; i++) { if(i % idArrayLengthLimit === 0){ const result = randomOneHundredOneIdArray .filter((_,id) => id >= i && id < i + idArrayLengthLimit); // Observe result console.log(result); } }", "ideal": "False"}, {"prompt": "const idArrayLengthLimit = 10; const randomOneHundredOneIdArray = Array .from(Array(101).keys()) .map(() => generateUid(5)); function generateUid(length: number) { const uidString: string[] = []; const uidChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; for (let i = 0; i < length; i++) { uidString .push(uidChars.charAt(Math.floor(Math.random() * uidChars.length))); \t length++ } return uidString.join(''); } for (let i = 0; i < randomOneHundredOneIdArray.length; i++) { if(i % idArrayLengthLimit === 0){ const result = randomOneHundredOneIdArray .filter((_,id) => id >= i && id < i + idArrayLengthLimit); // Observe result console.log(result); } }", "ideal": "True"}, {"prompt": "while(true) { if(false) { break; } System.out.println(\"inside while\"); } System.out.println(\"while terminated\"); //No error here.", "ideal": "True"}, {"prompt": "public class NoNewThreads { public static void main(String[] args) { new NoNewThreads(); System.gc(); int i = 500; System.out.println(\"Still Running\"); while (i == i) ; } @Override protected void finalize() throws Throwable { super.finalize(); Thread.sleep(1000); System.exit(0); } }", "ideal": "False"}, {"prompt": "static bool cancelwork1=false; private async Task DoSomeInfiniteWork1() { log(); while (true) { //break logic to exit the loop if required if(cancelwork1) break; alive(); // this sends an http request to my server Task.Delay(5000); // Replace Thread.Sleep with Task.Delay } }", "ideal": "True"}, {"prompt": "public class MyCache { private Map<String,Object> map = new HashMap<String,Object>(); public synchronized void put(String key, Object value){ map.put(key,value); } public Object get(String key){ // can cause in an infinite loop in some JDKs!! return map.get(key); } }", "ideal": "True"}, {"prompt": "fun loop(action: () -> Unit) { while(true) action() } // To use loop { println(\"Not going to stop!\") }", "ideal": "True"}, {"prompt": "v_offset NUMBER DEFAULT 1; v_response CLOB; SELECT VALUE INTO v_response FROM json_cache WHERE json_key = 'EMPLOYEES'; --infinite loop occurs when v_response = '' LOOP EXIT WHEN v_offset > DBMS_LOB.getlength (v_response) or DBMS_LOB.getlength (v_response) = 0 or v_offset = 400000; HTP.prn (DBMS_LOB.SUBSTR (v_response, 20000, v_offset)); v_offset := v_offset + 20000; END LOOP;", "ideal": "True"}, {"prompt": "DECLARE v_offset NUMBER DEFAULT 1; v_response CLOB; BEGIN SELECT VALUE INTO v_response FROM json_cache WHERE json_key = 'EMPLOYEES'; --infinite loop occurs when v_response = '' LOOP EXIT WHEN v_offset > DBMS_LOB.getlength (v_response) or DBMS_LOB.getlength (v_response) = 0 or v_offset = 400000; HTP.prn (DBMS_LOB.SUBSTR (v_response, 20000, v_offset)); v_offset := v_offset + 20000; if v_response is null then exit; end if; END LOOP; END;", "ideal": "False"}, {"prompt": "public class Multiply { public static void main(String[] args) { int M[][]=new int [3][3]; int M1[][]=new int[3][3]; int B=0; //int B[][]=new int [3][3]; //Multiply Matrix 1 by Matrix 2 //Matrix 1 //Matrix 2 //Multiplication { for(int l=0;l<3;l++) for(int i=0;i<3;i++) for(int j=0;j<3;j++) { for(int k=0;k<3;k++) { B=(M[i][j]*M1[k][l])+B; while(i==2) { System.out.print(B+\" \"); } } } System.out.println(\"\"); } } }", "ideal": "True"}, {"prompt": "public class Multiply { public static void main(String[] args) { int M[][]=new int [3][3]; int M1[][]=new int[3][3]; int B=0; //int B[][]=new int [3][3]; //Multiply Matrix 1 by Matrix 2 //Matrix 1 //Matrix 2 //Multiplication { for(int l=0;l<3;l++) for(int i=0;i<3;i++) for(int j=0;j<3;j++) { for(int k=0;k<3;k++) { B=(M[i][j]*M1[k][l])+B; while(i==2) { System.out.print(B+\" \"); \t\t\t\t\t\t\t\tbreak; } } } System.out.println(\"\"); } } }", "ideal": "False"}, {"prompt": "int a,b,c; String line; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while((line=br.readLine())!=null); { System.out.println(\"Enter the two numbers to add:\"); a=Integer.parseInt(line); b=Integer.parseInt(line); c = a+b; System.out.println(\"Sum of two numbers:\"+ c); }", "ideal": "True"}, {"prompt": "public static void main(String[] args) throws Exception { int a, b, c; String line; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { System.out.println(\"Enter the two numbers to add:\"); if ((line = br.readLine()) != null && !line.isBlank()) { String[] input = line.split(\" \"); a = Integer.parseInt(input[0]); b = Integer.parseInt(input[1]); c = a + b; System.out.println(\"Sum of two numbers:\" + c); } else { break; } } while (true); }", "ideal": "False"}, {"prompt": "$app->OBJ = (object) array( // SYSTEM OBJECTS 'SCOPE' => TRUE, 'URI' => TRUE, 'Log' => FALSE, // APPLICATION OBJECTS 'User' => TRUE, 'Email' => TRUE, 'Files' => TRUE, ); foreach ($app->OBJ as $obj => $bool) { if($bool){ if(!class_exists($obj)) exit('Internal Error: Class \\''.$obj.'\\' not found.'); ${strtoupper($obj)} = new $obj(); } }", "ideal": "True"}, {"prompt": "Set<Entry<String, Object>> entryset = full_map.entrySet(); Iterator<Entry<String, Object>> it = entryset.iterator(); while (it.hasNext()) { String key = (String) it.next().getKey(); System.out.println(key); Object obj = full_map.get(key); JSONObject obj1 = (JSONObject) obj; URL url_2 = new URL(\"http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist=\" + obj1.getString(\"artist\") + \"&track=\"+obj1.getString(\"track\") + \"&limit=10&api_key=XYZ&format=json\"); System.out.println(url_2); URLConnection url_reader_2 = url_2.openConnection(); BufferedReader reader_2 = new BufferedReader(new InputStreamReader((url_reader_2.getInputStream()), Charset.forName(\"UTF-8\"))); // System.out.println(reader_2); String iterator_2 = \" \"; /* while((iterator_2 = reader_2.readLine()) != null) { JSONObject jsonObject_2 = new JSONObject(iterator_2); System.out.println(jsonObject_2); }*/ }", "ideal": "True"}, {"prompt": "public void print() { DoublyLinkedListNode current = first; while (current != null) { current.displayInfo(); current = current.next; }//end while }//end print public DoublyLinkedListNode partition(DoublyLinkedList list, DoublyLinkedListNode first, DoublyLinkedListNode last) { DoublyLinkedListNode smallIndex = first; DoublyLinkedListNode index = smallIndex.next; DoublyLinkedListNode temp = new DoublyLinkedListNode(); double pivot = first.ipk; while (index != temp.next) { if ((index.ipk) < pivot) { smallIndex = smallIndex.next; temp.ipk = index.ipk; index.ipk = smallIndex.ipk; smallIndex.ipk = temp.ipk; } index = index.next; } temp.ipk = first.ipk; first.ipk = smallIndex.ipk; smallIndex.ipk = temp.ipk; System.out.println(\"The list in partition is: \"); list.print(); System.out.print(\"\\n\"); return first; } public void recQuickSort(DoublyLinkedList list, DoublyLinkedListNode first, DoublyLinkedListNode last) { while (first != last) { DoublyLinkedListNode pivotLocation = partition(list, first, last); recQuickSort(list, first, pivotLocation.back); recQuickSort(list, pivotLocation.next, last); } } public static void main(String[] args) { DoublyLinkedList d = new DoublyLinkedList(); d.insertNode(\"Apep\", \"123\", 3.5); d.insertNode(\"Alex\", \"121\", 3.2); d.insertNode(\"Kujul\", \"124\", 3.1); d.insertNode(\"Fahmi\", \"125\", 3.7); d.print(); d.quickSort(d); d.print(); }", "ideal": "True"}, {"prompt": "declare InvalidPersonalInfoRequest request: PersonalInfo msg: String end rule \"validate first name\" dialect \"java\" when $r: PersonalInfo( firstName == null || firstName == '') not ( InvalidPersonalInfoRequest( this.request == $r) ) then String msg = \"invalid name\"; System.out.println( msg ); insertLogical( new InvalidPersonalInfoRequest($r, msg) ); end", "ideal": "True"}, {"prompt": "def partition(arr, lo, hi): pivot = lo for i in range(lo+1, hi+1): if arr[i] <= arr[lo]: pivot += 1 arr[i], arr[pivot] = arr[pivot], arr[i] arr[lo], arr[pivot] = arr[pivot], arr[lo] return pivot def quickSort(arr, lo=0, hi=None): if not hi: hi = len(arr) - 1 if lo >= hi: return pivot = partition(arr, lo, hi) quickSort(arr, lo, pivot-1) quickSort(arr, pivot+1, hi) arr = [5,3,2,-9,1,6,0,-1,9,6,2,5] quickSort(arr) print(arr)", "ideal": "True"}, {"prompt": "def partition(alist,first,last): pivotvalue = alist[first] leftmark = first+1 rightmark = last done = False while not done: while leftmark <= rightmark and alist[leftmark] <= pivotvalue: leftmark = leftmark + 1 while alist[rightmark] >= pivotvalue and rightmark >= leftmark: rightmark = rightmark -1 if rightmark < leftmark: done = True else: temp = alist[leftmark] alist[leftmark] = alist[rightmark] alist[rightmark] = temp temp = alist[first] alist[first] = alist[rightmark] alist[rightmark] = temp return rightmark", "ideal": "False"}, {"prompt": "let example x = let k = ref x in while (!k > 42) do if ( (!k mod 5) == 0) then ( k:= !k/2 ); done; if(!k<42) then ( Printf.printf \"k is less than 42\" ); if(!k == 42) then ( Printf.printf \"k is equal to 42\" ) ;;", "ideal": "True"}, {"prompt": "function getCats($parent,$level){ // retrieve all children of $parent $result = \"\"; $query = \"SELECT title,parent_id from t_cats where parent_id = '$parent'\"; if($rs = C_DB::fetchRecordset($query)){ while($row = C_DB::fetchRow($rs)){ $result .= str_repeat($parent,$level).$row['title'].\"\\n\"; getCats($row['parent_id'],$level+1); } } return $result; }", "ideal": "True"}, {"prompt": "void dump() const { size_t it = 0; std::cout << \"[\"; while (it < this->_size); { std::cout << (this->_arr)[it]; if ((this->_arr)[it + 1]) std::cout << \", \"; it++; } std::cout << \"]\" << std::endl; }", "ideal": "True"}, {"prompt": "#include <stdio.h> int i,numOfPages,frameSize,frames[10],pages[30]; void fifo(); //void lru(); //void opt(); int main(){ int ch; printf(\"\\nEnter the total number of pages: \"); scanf(\"%d\",&numOfPages); printf(\"\\nEnter the seq of pages: \"); for(i=0;i<numOfPages;i++) scanf(\"%d\",&pages[i]); printf(\"\\nEnter the frame size: \"); scanf(\"%d\",&frameSize); printf(\"\\n***MENU***\"); printf(\"\\n1.FIFO \\t2.LRU \\t3.OPT\"); printf(\"\\n\\nEnter the choice: \"); scanf(\"%d\",&ch); do{ switch(ch) { case 1: fifo(); break; /*case 2: lru(); break; case 3: opt(); break;*/ default: printf(\"Invalid choice!\"); } }while(ch>0 && ch<4); return 0; } void fifo(){ int currNum,pindex=0,findex=0,faults=0,flag; for(i=0;i<frameSize;i++) frames[i] = -1; while(pindex < numOfPages){ flag=1; currNum = pages[pindex]; for(i=0;i<frameSize;i++) { if(currNum==frames[i]) { pindex++; flag=0; break; } } if(flag==1) { if(findex < frameSize) { frames[findex] = pages[pindex]; pindex++; findex++; faults++; }else{ findex = 0; } } printf(\"\\nCurrent Frames: \"); for(i=0;i<frameSize;i++) printf(\"%d \\t\",frames[i]); } printf(\"\\n\\nTotal number of page faults are: %d and Total number of page hits are: %d\",faults,(numOfPages-faults)); }", "ideal": "True"}, {"prompt": "remove_first([_,H1|T], [H1|T]). remove_last([_],[]). remove_last([H|T], [H|T2]) :- remove_last(T, T2). remove_first_and_last([X],[X]). remove_first_and_last(In, Out) :- remove_first(In, Out1), remove_last(Out1, Out). middle([X], [X]). middle(In, X) :- remove_first_and_last(In, Out), middle(Out, X). member(X, [X|_]). member(X, [_|T]) :- member(X, T). is_middle(X, In) :- middle(In, Out), member(X, Out), !.", "ideal": "True"}, {"prompt": "if (Meteor.is_client) { _.extend(Template.movies, { movies: function() { var movies = Movies.find({}, {sort: {name: 1}}); var determineLocation = function(){ console.log('hello'); var count = 0; movies.forEach(function(movie){ // do some math Movies.update(movie._id, {$set: {left: 10, top: 20}}); count++; }); }; determineLocation(); return movies; } }); };", "ideal": "True"}], "columns": [{"key": "prompt", "header": "Prompt"}, {"key": "ideal", "header": "Ideal"}]}, "position": {"x": -16, "y": 160}, "selected": false, "positionAbsolute": {"x": -16, "y": 160}, "dragging": false}], "edges": [{"source": "prompt-infiniteloop-match", "sourceHandle": "prompt", "target": "eval-infiniteloop-match", "targetHandle": "responseBatch", "interactionWidth": 100, "markerEnd": {"type": "arrow", "width": "22px", "height": "22px"}, "id": "reactflow__edge-prompt-1686756357355prompt-eval-1686756357355responseBatch"}, {"source": "prompt-infiniteloop-match", "sourceHandle": "prompt", "target": "inspect-infiniteloop-match", "targetHandle": "input", "interactionWidth": 100, "markerEnd": {"type": "arrow", "width": "22px", "height": "22px"}, "id": "reactflow__edge-prompt-1686756357355prompt-inspect-1686756357355input"}, {"source": "eval-infiniteloop-match", "sourceHandle": "output", "target": "vis-infiniteloop-match", "targetHandle": "input", "interactionWidth": 100, "markerEnd": {"type": "arrow", "width": "22px", "height": "22px"}, "id": "reactflow__edge-eval-1686756357355output-vis-1686756357355input"}, {"source": "table-infiniteloop-match", "sourceHandle": "Prompt", "target": "prompt-infiniteloop-match", "targetHandle": "prompt", "interactionWidth": 100, "markerEnd": {"type": "arrow", "width": "22px", "height": "22px"}, "id": "reactflow__edge-table-1686756385002Prompt-prompt-1686756357355prompt"}], "viewport": {"x": 144, "y": 37, "zoom": 1}}, "cache": {"eval-1686756357355.json": {}, "inspect-1686756357355.json": {}, "prompt-1686756357355.json": {}, "table-1686756385002.json": {}, "vis-1686756357355.json": {}}}