content stringlengths 263 5.24M | pred_label stringclasses 1
value | pred_score_pos float64 0.6 1 |
|---|---|---|
package com.xuyi.blog.security;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorSe... | __label__POS | 0.779268 |
package com.xuyi.blog.repository;
import com.xuyi.blog.entity.Article;
import com.xuyi.blog.entity.Category;
import com.xuyi.blog.entity.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springfram... | __label__POS | 0.960131 |
package com.xuyi.blog.repository;
import com.xuyi.blog.entity.VisitLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.time.LocalDa... | __label__POS | 0.976574 |
package com.carmelo.library;
import android.app.Notification;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.IBinder;
/**
* Created by dml on 2018/3/3.... | __label__POS | 0.992739 |
package com.carmelo.library;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
/**
* Created by carmelo on 2018/3/17.
* 国内手机厂商白名单跳转工具类
*/
public class SettingUtils {
public static void enterWhiteListSetting(Context context){... | __label__POS | 0.977816 |
package cn.ilikexff.codepins;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 这个类用于测试标签正则表达式
*/
public class TagRegexTest {
private static final Pattern TAG_PATTERN = Pattern.compile("#([\\w\\u4e00-\\u9fa5]+)");
private static final P... | __label__POS | 0.994529 |
package cn.ilikexff.codepins;
/**
* 这个类用于测试带标签的注释指令功能
*/
public class TagAnnotationTest {
/**
* @cp 这是一个单行图钉测试 #测试 #单行
*/
public void testSingleLinePin() {
System.out.println("测试单行图钉");
}
/**
* @cpb 这是一个代码块图钉测试 #测试 #代码块
*/
public void testBlockPin() {
System.... | __label__POS | 0.998447 |
package cn.ilikexff.codepins;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 用于调试正则表达式的测试类
*/
public class RegexDebugger {
public static void main(String[] args) {
// 测试用例
String[] testComments = {
"// @cp 这是一个测试 #重要",
"// @cpb 这是一个代码块测试 #代码块",
... | __label__POS | 0.983318 |
package cn.ilikexff.codepins.ui;
import cn.ilikexff.codepins.services.GistService;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.IconLoader;
import com.intel... | __label__POS | 0.872245 |
package cn.ilikexff.codepins.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.function.Consumer;
/**
* 动画工具类
* 提供各种 UI 动画效果
*/
public class AnimationUtil {
/**
* 淡入效果
*
* @param component 要应用动画的组件
* @para... | __label__POS | 0.841462 |
package cn.ilikexff.codepins.ui;
import javax.swing.*;
import java.awt.*;
/**
* 自动换行布局
* 当容器宽度不足时,组件会自动换行显示
*/
public class WrapLayout extends FlowLayout {
private Dimension preferredLayoutSize;
/**
* 构造一个新的 WrapLayout
*/
public WrapLayout() {
super();
}
/**
* 构造一个新的 Fl... | __label__POS | 0.959739 |
package cn.ilikexff.codepins.ui;
import cn.ilikexff.codepins.i18n.CodePinsBundle;
import cn.ilikexff.codepins.utils.ImportExportUtil;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.open... | __label__POS | 0.645033 |
package cn.ilikexff.codepins.ui;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinStorage;
import cn.ilikexff.codepins.i18n.CodePinsBundle;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.IconLoader;
import com.in... | __label__POS | 0.758516 |
package cn.ilikexff.codepins.i18n;
import cn.ilikexff.codepins.settings.LanguageSettings;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NotNull;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceB... | __label__POS | 0.814671 |
package cn.ilikexff.codepins.statistics;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinStorage;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 图钉统计数据计算类
* 提供各种维度的图钉统计信息
*/
public class PinStatistics {
... | __label__POS | 0.995643 |
package cn.ilikexff.codepins.extensions;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.editor.event.EditorFactoryListener;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
* 编辑器工厂监听器
* 用... | __label__POS | 0.977611 |
package cn.ilikexff.codepins.extensions;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;
/**
* 文档监听器初始化器
* 在项目启动时初始化文档监听器
*/
pub... | __label__POS | 0.902779 |
package cn.ilikexff.codepins.extensions;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.editor.event.EditorFactoryListener;
import com.intellij.openapi.project.Project;
import com.inte... | __label__POS | 0.669839 |
package cn.ilikexff.codepins.settings;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.j... | __label__POS | 0.738507 |
package cn.ilikexff.codepins.core;
import cn.ilikexff.codepins.settings.CodePinsSettings;
import cn.ilikexff.codepins.ui.TagFilterPanel;
import cn.ilikexff.codepins.core.PinState;
import cn.ilikexff.codepins.core.PinStateService;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMark... | __label__POS | 0.670895 |
package cn.ilikexff.codepins.core;
import java.util.ArrayList;
import java.util.List;
/**
* 图钉持久化快照数据类
* 用于保存最小必要信息以持久化到 XML 文件
*/
public class PinState {
public String filePath; // 文件路径
public int line; // 图钉所在行号(静态保存)
public String note; // 图钉备注
public long timestamp;... | __label__POS | 0.959205 |
package cn.ilikexff.codepins.core;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.an... | __label__POS | 0.9653 |
package cn.ilikexff.codepins.utils;
import java.awt.Color;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 语法高亮工具类
* 用于对代码进行语法高亮分析
*/
public class SyntaxHighlighter {
// 语言关键字映射
private static final Map<String, String[]> LANGUAGE_KEYWOR... | __label__POS | 0.696794 |
package cn.ilikexff.codepins.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 敏感信息检测工具类
* 用于检测代码中的敏感信息
*/
public class SensitiveInfoDetector {
// 敏感信息类型
public enum SensitiveType {
API_KEY("API密钥", "可能包含API密钥"),
... | __label__POS | 0.723605 |
package cn.ilikexff.codepins.utils;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.scale.ScaleContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
/**
* 图标工具类
* 用于加载和管理图标
*/
public class IconUtil {
priva... | __label__POS | 0.95033 |
package cn.ilikexff.codepins.utils;
import cn.ilikexff.codepins.core.PinEntry;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.inte... | __label__POS | 0.805071 |
package cn.ilikexff.codepins.utils;
import cn.ilikexff.codepins.services.LicenseService;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import java.awt.Desktop;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net... | __label__POS | 0.731686 |
package cn.ilikexff.codepins.utils;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
imp... | __label__POS | 0.633863 |
package cn.ilikexff.codepins.utils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* 动画工具类
* 用于实现UI动画效果
*/
public class AnimationUtil {
/**
* 按钮点击效果
*
* @param button 按钮组件
*/
public static void buttonClickEffect(Ab... | __label__POS | 0.908042 |
package cn.ilikexff.codepins.utils;
import cn.ilikexff.codepins.services.LicenseService;
import com.intellij.openapi.project.Project;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
/**
* 水印管理工具类
*/
public class Watermark... | __label__POS | 0.716754 |
package cn.ilikexff.codepins.utils;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinState;
import cn.ilikexff.codepins.core.PinStorage;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.... | __label__POS | 0.743441 |
package cn.ilikexff.codepins.utils;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.ui.GithubTokenDialog;
import com.intellij.openapi.project.Project;
import javax.swing.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
impo... | __label__POS | 0.790446 |
package cn.ilikexff.codepins.utils;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
/**
* 字符串加密工具类
*
* @deprecated 此类已废弃。插件现在完全免费开源,不再需要加密功能。
* 保留此类仅用于向后兼容,解密可能存在的旧数据。
*/
@Deprecated
public class StringEncryptor {
... | __label__POS | 0.997508 |
package cn.ilikexff.codepins.utils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxi... | __label__POS | 0.99612 |
package cn.ilikexff.codepins.actions;
import cn.ilikexff.codepins.i18n.CodePinsBundle;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij... | __label__POS | 0.686135 |
package cn.ilikexff.codepins.git;
import cn.ilikexff.codepins.core.PinEntry;
import java.util.ArrayList;
import java.util.List;
/**
* 图钉版本快照
*/
public class PinSnapshot {
private final String commitHash;
private final String commitMessage;
private final String branch;
private final long timest... | __label__POS | 0.953014 |
package cn.ilikexff.codepins.git;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinStorage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;... | __label__POS | 0.967668 |
package cn.ilikexff.codepins.git;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ContentRevision;
import java.util.*;
import java.util.regex.Pattern;
/**
* Git差异分析器
* 分析代码变更并生成图钉建议
*/
public class DiffAnalyzer {
private... | __label__POS | 0.906935 |
package cn.ilikexff.codepins.git;
import java.util.ArrayList;
import java.util.List;
/**
* 基于Git分析的图钉建议
*/
public class PinSuggestion {
/**
* 建议类型
*/
public enum SuggestionType {
NEW_CODE("新增代码"),
MODIFIED_CODE("修改代码"),
COMPLEX_CHANGE("复杂变更"),
POTENTIAL_BUG("潜在... | __label__POS | 0.780323 |
package cn.ilikexff.codepins.git;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
* Git集成服务
... | __label__POS | 0.928798 |
package cn.ilikexff.codepins.git;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinStorage;
import com.intellij.openapi.project.Project;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
/**
* 图钉版本追踪器
* 负责保存和管理图钉的版... | __label__POS | 0.841622 |
package cn.ilikexff.codepins.git;
import cn.ilikexff.codepins.core.PinEntry;
import java.util.ArrayList;
import java.util.List;
/**
* 图钉版本差异
*/
public class PinDiff {
/**
* 差异类型
*/
public enum DiffType {
ADDED("新增"),
REMOVED("删除"),
MODIFIED("修改"),
MOVED("移动");... | __label__POS | 0.918418 |
package cn.ilikexff.codepins.services;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nulla... | __label__POS | 0.991378 |
package cn.ilikexff.codepins.services;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.in... | __label__POS | 0.822396 |
package cn.ilikexff.codepins.ai;
// PSI imports temporarily removed to fix compilation issues
// import com.intellij.psi.*;
// import com.intellij.psi.util.PsiTreeUtil;
import java.util.*;
import java.util.regex.Pattern;
/**
* 代码模式分析器
* 识别常见的代码模式和潜在问题
*/
public class CodePatternAnalyzer {
/**
* 代码异味... | __label__POS | 0.923274 |
package cn.ilikexff.codepins.ai;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrain... | __label__POS | 0.726661 |
package cn.ilikexff.codepins.ai;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 代码质量分析器
* 基于静态分析规则检测代码质量问题
*/
public class CodeQualityAnalyzer {
/**
* 质量规则定义
*/
private static final List<QualityRule> QUALITY_RULES = Arrays.asList(
// 命名规范
... | __label__POS | 0.889231 |
package cn.ilikexff.codepins.ai;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.pr... | __label__POS | 0.641093 |
package cn.ilikexff.codepins.template;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
... | __label__POS | 0.776608 |
package cn.ilikexff.codepins.template;
import cn.ilikexff.codepins.core.PinEntry;
import cn.ilikexff.codepins.core.PinStorage;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.fileEditor.FileDocumentManag... | __label__POS | 0.77835 |
package cn.ilikexff.codepins.template;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 模板变量处理器
* 负责处理模板中的变量替换
*/
public class TemplateVariableProcessor {
// 变量匹配模式:{变量名}
priv... | __label__POS | 0.992423 |
package service
import (
"github.com/0990/goserver/util"
"github.com/sirupsen/logrus"
"io"
"runtime/debug"
"sync/atomic"
"time"
)
type Worker interface {
Post(f func())
Run()
Close()
AfterPost(duration time.Duration, f func()) *time.Timer
NewTicker(d time.Duration, f func()) io.Closer
Len() int
}
//TODO ... | __label__POS | 0.691787 |
export const tests = []
const t = (f) => tests.push(f)
const fmt = (s) =>
s
.map((l) => l.join('.'))
.sort()
.map((l) => l.split('.').map(Number))
t(({ code }) => !code.includes('$'))
t(({ eq }) => eq(sums(0), []))
t(({ eq }) => eq(sums(1), []))
t(({ eq }) => eq(sums(2), [[1, 1]]))
t(({ eq }) => eq(fmt(s... | __label__POS | 0.973471 |
package rpc
import (
"github.com/0990/goserver/rpc/rpcmsg"
"github.com/0990/goserver/util"
"github.com/golang/protobuf/proto"
)
func MakeRequestData(msg proto.Message, seqID int32, senderID int32) []byte {
msgID, _ := util.ProtoHash(msg)
msgData, _ := proto.Marshal(msg)
rpc := &rpcmsg.Data{
Type: rpcmsg.D... | __label__POS | 0.930418 |
package main
import (
"fmt"
"github.com/0990/goserver"
"github.com/0990/goserver/example/msg"
"github.com/0990/goserver/rpc"
"github.com/0990/goserver/server"
"time"
)
func main() {
s, err := server.NewServer(101, goserver.Config{Nats: "127.0.0.1:4222"})
if err != nil {
fmt.Println(err)
return
}
//注册客... | __label__POS | 0.933734 |
## kept-promise
### Instructions
Things in your code do not always happen as fast as you would like.
Sometimes it is important to wait for a function to finish before keep going on. Other times you don't want your code to be blocking while waiting.
Create an asynchronous function `processInfo` in a file `kept-promi... | __label__POS | 0.810594 |
## listfind
### Instructions
Write a function `ListFind` that returns the address of the data interface of the first node in the list `l` that is determined to be equal to `ref` by the function `CompStr`.
- For this exercise the function `CompStr` must be used.
### Expected function and structure
```go
type NodeL ... | __label__POS | 0.658043 |
## issorted
### Instructions
Write a function `IsSorted()` that returns `true`, if the slice of `int` is sorted, otherwise returns `false`.
- The function passed as an argument `func(a, b int)` returns a positive `int` if the first argument is greater than the second argument, it returns `0` if they are equal and it... | __label__POS | 0.999285 |
## Insertion Sort Analyzer
### Instructions
Write a function `insertionSortAnalyzer(arr, comparator)` that:
- Takes an array `arr` and a comparator function `comparator`.
- Sorts the array using the **insertion sort** algorithm and returns an object with the following properties:
- `sortedArray`: The sorted array.... | __label__POS | 0.999201 |
## sortlistinsert
### Instructions
Create a function named `SortListInsert`, which accepts a pointer to the head of a _sorted_ linked list and an integer.
The function should insert a new element into the list, with its `Data` set to the value of the integer. The element should be inserted so that the linked list re... | __label__POS | 0.930873 |
## Pipeline
### Instructions
Write a function `pipeline(initialValue, pipeline)` that:
- Takes an initial value `initialValue` and an array of functions `functions`.
- Each function in `functions` takes the current value and returns a new value.
- After executing all pipeline functions in sequence, return an object ... | __label__POS | 0.980316 |
## basicatoi
### Instructions
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number defined as a `string` into a number defined as an `int`.
- `Atoi` returns `0` if the `string` is not considered as a valid number. For this exercise **only valid** `string` will be t... | __label__POS | 0.88339 |
## crossword
### Instructions
Create the function `crosswordSolver` that is able to solve an empty crossword puzzle. The function must be submitted in a file named `crosswordSolver.js`.
The function takes two arguments:
1. an empty puzzle, passed as a string and
2. a list of words to fill in the puzzle (no double w... | __label__POS | 0.806471 |
## atoibase
### Instructions
Write a function that takes two arguments:
- `s`: a numeric `string` in a given [base](https://simple.wikipedia.org/wiki/Base_(mathematics)).
- `base`: a `string` representing all the different digits that can represent a numeric value.
And return the integer value of `s` in the given `... | __label__POS | 0.99346 |
## revconcatalternate
### Instructions
Write a function `RevConcatAlternate()` that receives two slices of `int` as arguments and returns a new slice with alternated values of each slice in reverse order.
- The input slices can have different lengths.
- The new slice should start with the elements from the largest s... | __label__POS | 0.999505 |
## Can Jump
Given an array of non-negative integers representing the number of steps you can take forward from each position, implement the function `CanJump()` which takes a slice of unsigned integers `[]uint` as input and returns a `boolean` value. This function should determine if it's possible to reach and stay at... | __label__POS | 0.999363 |
## Exam Grader
### Instructions
Write a function `examGrader(timeout, exercises)` that:
- Takes two parameters:
- `timeout`: A positive integer representing the maximum allowed time for the entire exam in milliseconds.
- `exercises`: An array of Promises, where each Promise represents an exercise in the exam. Ea... | __label__POS | 0.960645 |
## cameltosnakecase
### Instructions
Write a function that converts a `string` from `camelCase` to `snake_case`.
- If the `string` is empty, return an empty `string`.
- If the `string` is not `camelCase`, return the `string` unchanged.
- If the `string` is `camelCase`, return the `snake_case` version of the `string`... | __label__POS | 0.998225 |
package main
import (
"fmt"
"piscine"
)
func main() {
root := &piscine.TreeNode{Data: "4"}
BTreeInsertData(root, "1")
BTreeInsertData(root, "7")
BTreeInsertData(root, "5")
node := BTreeSearchItem(root, "4")
fmt.Println("Before delete:")
BTreeApplyInorder(root, fmt.Println)
root = piscine.BTreeDeleteNode(roo... | __label__POS | 0.998899 |
## merge-it
### Instructions
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value o... | __label__POS | 0.997954 |
## Rectangle
### Instructions
Consider that a point is defined by its coordinates and that a rectangle is defined by the points of the upper left and lower right corners.
- Define two structures named, `point` and `rectangle`.
- The struct `point` has to have two variables, `x` and `y`, type `int`.
- The struct `r... | __label__POS | 0.957566 |
## luhn_algorithm
### Instructions
Create a function which checks if a number is valid per the Luhn formula.
The function will receive a string and return a boolean.
**Invalid inputs:** An empty string or a number with only one digit are considered invalid.
**Handling spaces:** Spaces are accepted but have to be ig... | __label__POS | 0.945006 |
## listforeachif
### Instructions
Write a function `ListForEachIf` that applies a function given as argument to the data within some of the nodes of the list `l`.
- This function receives two functions:
- `f` is a function that is applied to the node.
- `cond` is a function that returns a `boolean` and it will... | __label__POS | 0.966998 |
## Deep Clone
### Instructions
Write a function `deepClone(obj)` that takes an object and returns a **deep clone** of it. The function should recursively copy all nested objects and arrays, ensuring that modifying the original object does not affect the cloned object.
The cloning process should:
- Copy **all primit... | __label__POS | 0.976691 |
## sametree
### Instructions
Given two binary trees, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical and the nodes have the same value.
Write a function, `IsSameTree`, that returns `bool`.
### Expected function
```go
type TreeNodeL... | __label__POS | 0.999797 |
## Unzipstring
### Instructions
Write a function called `Unzipstring` that takes a string that will be a kind of code, and your function will have to decrypt it and return a new string with the output.
It works as follows:
The string will be formed by a number followed by a letter, and the purpose is to print this le... | __label__POS | 0.990891 |
## Election Mix
### Instructions
Write a function `createCurriedFilterAndMap(criteria, mapper)` that:
- Accepts a `criteria` function and a `mapper` function.
- `criteria(key, value)` returns `true` if the key-value pair should be included, `false` otherwise.
- `mapper(value)` transforms the value of each includ... | __label__POS | 0.929793 |
## maxwordcountn
### Instructions
Write a function `MaxWordCountN` that will return a `map` of the `n` words that occurs the most in a string `text`. A word is defined as separated by spaces. The `map` you should return will have the word as key and the number of occurences of this word as value.
If two words have th... | __label__POS | 0.972233 |
## Final Attempt
### Instructions
Write a function `FinalAttempt(callback, count)` that:
- Takes two parameters:
- `callback`: An asynchronous function to be invoked.
- `count`: A positive integer representing the maximum number of retries.
- Returns a function that:
- Accepts any number of arguments. These ar... | __label__POS | 0.982106 |
## notdecimal
### Instructions
Write a function called `NotDecimal()` that takes as an argument a `string` in form of a float number with the decimal point and returns a string converted to `int` without the decimal point (you will have to multiply it by 10^n to remove the `.`).
- If the number doesn't have a decima... | __label__POS | 0.994539 |
## setspace
### Instructions
Write a function that takes a PascalCase `string` and returns the same `string` with a space between each word.
- The function must return an empty `string` if the input is an empty `string`.
- The function must return `"Error"` if the input `string` is not a PascalCase `string`.
- The... | __label__POS | 0.999472 |
## basicatoi2
### Instructions
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number defined as a `string` in a number defined as an `int`.
- `Atoi` returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will b... | __label__POS | 0.886627 |
## quadrangle
### quadA
#### Instructions
Write a function `QuadA` that prints a **valid** rectangle with a given width of `x` and height of `y`.
The function must draw the rectangles as in the examples.
If `x` and `y` are positive numbers, the program should print the rectangles as seen in the examples, otherwise... | __label__POS | 0.996359 |
## sortedlistmerge
### Instructions
Write a function `SortedListMerge` that merges two lists `n1` and `n2` in ascending order.
- During the tests `n1` and `n2` will already be initially sorted.
### Expected function and structure
```go
func SortedListMerge(n1 *NodeI, n2 *NodeI) *NodeI {
}
```
> You have already ... | __label__POS | 0.940034 |
## print-range
### Instructions
Write a function called `PrintRange` that given a range between two numbers, prints all numbers in that range.
- If the starting number is greater than the ending number, print the numbers in descending order, otherwise in ascending order.
- If the number is greater than `9` print on... | __label__POS | 0.99995 |
## Deep Freeze
### Instructions
Write a function `deepFreeze(obj)` that makes an object **completely immutable**, preventing any modifications at all levels.
The function should:
- Use `Object.freeze()` to prevent modifications to the object itself.
- Recursively apply `Object.freeze()` to all nested objects and ar... | __label__POS | 0.968107 |
## slice
### Instructions
The function receives a slice of strings and one or more integers, and returns a slice of strings. The returned slice is part of the received one but cut from the position indicated in the first int, until the position indicated by the second int.
In case there only exists one int, the resu... | __label__POS | 0.842217 |
## printnbrbase
### Instructions
Write a function that prints an `int` in a `string` base passed as parameters.
If the base is not valid, the function prints `NV` (Not Valid):
Validity rules for a base :
- A base must contain at least 2 characters.
- Each character of a base must be unique.
- A base should not con... | __label__POS | 0.992022 |
## armstrong_number
### Instructions
Create a function which checks if the number is a valid Armstrong number. The function will return the number if it is a valid one and `None` otherwise.
An Armstrong number is a number where the sum of its own digits each raised to the power of the number of digits is equal to it... | __label__POS | 0.935642 |
## saveandmiss
### Instructions
Write a function called `SaveAndMiss()` that takes a `string` and an `int` as an argument. The function should move through the `string` in sets determined by the `int`, saving the first set, omitting the second, saving the third, and so on, in a 'save' and 'miss' fashion until the end... | __label__POS | 0.992868 |
## listforeach
### Instructions
Write a function `ListForEach` that applies a function given as argument to the data within each node of the list `l`.
- The function given as argument must have a pointer as argument: `l *List`
- Copy the functions `Add2_node` and `Subtract3_node` in the same file as the function `L... | __label__POS | 0.870239 |
# buzzinga
### Instructions
Write a function called `BuzZinga()` that takes a number as an argument, then loops over it and does the following for each iteration:
- If the number is divisible by 3, print `Buz` followed by a newline
- If the number is divisible by 5, print `Zinga` followed by a newline
- If the number... | __label__POS | 0.999912 |
## Swapy
Like we did with `Objects`, we can modify our arrays.
### replacing an `Array` value
Let's look at an example of code:
```js
let weekDays = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday',
]
// Let's say I don't want Monday but a Second Sunday
weekDays[0] = 'Se... | __label__POS | 0.861709 |
## fooddeliverytime
### Instructions
Given the following menu with the corresponding times that each item takes to cook (burger takes 15 min, chips takes 10 min and nuggets takes 12 min), return the time that each order item takes to be prepared and the total amount of time for the order to be ready assuming the item... | __label__POS | 0.996584 |
## Trap Object
### Instructions
Write a function `trapObject(obj, fn)` that takes an object and a function. The returned object should behave normally but **run `fn` every time a property is accessed or modified**.
The function `fn` should receive the following arguments:
- `"get"` when a property is accessed, alon... | __label__POS | 0.844533 |
## trimatoi
### Instructions
- Write a function that transforms numbers within a `string`, into an `int`.
- If the `-` sign is encountered before any number it should determine the sign of the returned `int`.
- This function should **only** return an `int`. In the case of an invalid input, the function should retur... | __label__POS | 0.998635 |
## addlinkednumbers
### Instructions
You have two numbers represented by a linked list, where each NodeAddL contains a single digit.
The digits are stored in reverse order, such that the 1’s digit is at the head of the list.
Write a function that adds the two numbers and returns the sum as a linked list
### Expected... | __label__POS | 0.999793 |
## Character Maker
### Instructions
Write a function `createCurriedCharacterCreator(initialCharacter)` that:
- Starts with an `initialCharacter` object as a base.
- Returns a curried function that can be called multiple times, each time with either:
- An object representing new character attributes to be merged in... | __label__POS | 0.875136 |
## Go to 11
### Looping with the `while` keyword
Loops are one of the last missing basic blocks of programing left to learn,
let's see it in action:
```js
while (count < 30) {
// Code to be repeated here
}
```
As you can see, it is exactly like an `if`, we have a scope `{}` and a
`(condition)` just a new keyword.... | __label__POS | 0.704585 |
## atoi
### Instructions
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number represented as a `string` in a number represented as an `int`.
- `Atoi` returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will... | __label__POS | 0.931613 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.