instruction stringlengths 71 71.9k |
|---|
I got a Parrot Mambo which comes with an SDK for creating your own app for controlling it.
I decided to use the iOS Speech Recognition library so I could use basic voice commands to control it. The majority of the iOS SDK that comes with the drone is written in pure C, so it has to be used in Objective-C (Something I ... |
I did this small program, as part of a list of coding exercises. The list proposes the coding of a small software that's supposed to manage an inventory of products. Here's what is requested:
Product Inventory Project - Create an application which manages an
inventory of products. Create a product class which has a ... |
I'm trying to solve Alphacode on SPOJ. The challenge is to count the ways to split a string of up to 5000 digits into a sequence of numbers, each ranging from 1 to 26.
It works fine for small numbers but exceeds the time limit for bigger numbers. I'm using the exhaustive recursive traversing.
Is there a way to make it... |
I'm trying to get my head around recursion in Rust. I've put together a basic implementation of cat here to play with the basics.
Here's my recursive version:
use std::env;
use std::fs::File;
use std::fmt::Display;
use std::io;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
const STDIN: &'static... |
I have researched ways to implement a simpler alternative for C++ exceptions. The problem I had with exceptions was the complex and not-portable stack unwinding process which makes it hard to implement for a multiple systems.
However, the alternatives didn't look clean enough to indicate about an error case. In other w... |
I was surprised to learn that there are not many C++ Caesar ciphers on Code Review (3 others as of this question). And none that work in this fashion.
Here's the code:
// Caesar cipher
#include <iostream>
const char chars[] = {"abcdefghijklmnopqrstuvwxyz"};
// Find position in array
int findPosition(char x){
int... |
There are 2 versions of the get_startup_folders() method below, both work as expected and are called only once.
The 1st version has several minor pieces of repeated code which are removed by the use of an inner function in the 2nd version.
I've read several times that the use of inner functions is often frowned on by P... |
Both these functions take in a sentence and generate a random string based of the length of sentence.
Mine, the first one, runs 4 times more slowly than the second one (someone else's code), but I don't know why and I'd like to understand what's happening 'under the hood' that makes it this way. If anything I would've ... |
I wrote the following F# program that takes an input txt file and create a Map that contains all possible substrings of size N and their frequency in the file.
In other words if I call the program with a text file with the following content:
James John Max Gary Jess Gilles Mary
With a length of 2, the probabilityTabl... |
I have created an algorithm that can generate all possible combinations of a string given its length, and character set (it uses a custom numeral system to do this). How could I improve its performance and readability?
using System;
using System.Text;
public class Program
{
public static void Main(string[] args)
... |
Puzzle description: input is dimensions (length, width, heigth) of various presents.
Example:
2x3x1
5x9x10
1x40x2
Part 1: determine the area of paper needed to wrap the gifts, wich is equal to 2*(l*w + w*h + l*h) + the smallest between l*w, w*h and l*h for each gift.
Part 2: determine the length of ribbon ne... |
The official problem description is here, which in my opinion is unclear and quite long. Below is my description. I recommend you still read the official description, it has details such as input and output format
Input: N cows
represented as points on a 2D graph (integer x, y pairs)
each with an integer walkie-talk... |
Suppose rectangles are parallel to x-axis/y-axis. Check if two rectangles overlap or not and if they do, output the overlap area.
Here is my code and I track min/max x-coordinate and min/max y-coordinate for each rectangle. Using Python 2.7.
Any comments on code bugs, code style and performance improvements in terms of... |
I saw a simple method to calculate Log2(N), where N is the power of 2:
unsigned int Log2(unsigned int N)
{
unsigned int n = 0;
while (N >>= 1)
{
++n;
}
return n;
}
It would be not likely very necessary, but I try to improve it in a simple way, the idea comes from binary search.
unsigned i... |
I'm looking to learn how to write efficient Haskell code. This snippet works, but the run time is slow. How can I write faster Haskell code?
Input: maxPrice = 7
Input: vendorsDelivery = [5, 4, 2, 3]
Input: vendorsProducts = [[1, 1, 1],[3, -1, 3],[-1, 2, 2],[5, -1, -1]]
Output: [1,2] (fastest delivery time for a given ... |
I have a Slack bot that takes a stream of messages and the idea is that if 3 different users repeat the same message, the bot will also mime that message.
I am just beginning with RXJS and I am trying to figure out the correct, most idiomatic way to refactor the following code. Is it even possible with what I'm trying... |
I have a function in python where I want the reverse complement of a DNA string.
This is what I have now:
def inversComplement(input):
output = ''
for letter in input:
letter = letter.upper()
if letter == 'A':
output += 'T'
elif letter == 'T':
output += 'A'
... |
I have full working code, but when I run it, it shows these warnings:
given is experimental at grocery.pl line 38.
when is experimental at grocery.pl line 40.
when is experimental at grocery.pl line 62.
when is experimental at grocery.pl line 89.
when is experimental at grocery.pl line 100.
How can I fix these?
use st... |
Because I have been writing more multithreaded C++14 code lately, I've developed some tools that help me make sure that my threads are all working as intended. In the real code, it's often difficult to detect race conditions or unintended sequence dependencies among threads, so I have found that temporarily substituti... |
I have a circular buffer (array/first in first out), a consumer and a producer. A producer puts random numbers into the array, and a consumer takes the first number and checks if it is relative prime.
My code works, and I think it works correct, but I want to improve it.
I am not really sure about my "void run" methods... |
I wrote an entab program which needs to replace every \$n\$ spaces with 1 tab. I picked \$n\$ to be 4, so every 4 spaces should be 1 tab. I have a feeling that my code is far too complicated than it should be, and the logic I made it with could be much simpler.
The logic of the code:
Note: \$n\$ = 4
Get line from inpu... |
I wrote this method in order to generate a sequence number based on a specific pattern:
public string LatestNumber(Guid id = default(Guid))
{
var number = "";
if (id == Guid.Empty)
{
var items = myList.ToList();
var lastNumber = items.Any() ? items[items.Count - 1].Number : "";
var ... |
I'm working with some math-heavy code in JavaScript. I just realized that there's a render that currently takes about 30 minutes. 95% of that time is spent in a single ~40 line function that I've pasted below. I am not extremely well-versed in JavaScript math optimization, so my first attempts to optimize this code hav... |
I'm currently creating a class that will have a bunch of my most common database functions. This is the first method I've made, I would appreciate any feedback, thanks!
public static function insert($table, $params) {
// Define initial query
$query = "INSERT INTO `{$table}` (";
// Format rows to insert
... |
(...as I still learning Kotlin) I found this "problem":
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 ->... |
I'm taking my first steps in the Scala world, though I'm not wholly unfamiliar with functional style.
Apparently one way of calculating Pi is to sum the terms of the infinite series:
$$4 * (\frac{1}{1} - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} \dots)$$
So I wrote this simple implementation in a Scala work... |
For the game that I am creating I came across the need for an Elemental-based Resistance system. By that I mean, a system which would allow the player to mitigate damage or take more damage based upon their Resistance rating towards an element of a given type. With a good Fire Resistance they would take less fire damag... |
This is a continuation of Advent of Code 2016: Day 1, Part 1.
This time, instead of the distance at the end of the instruction string, the answer is the distance of the first location which is visited twice. I implemented this by adding a terminate_on_revisited_location parameter to the blocks_away method, tracking vis... |
I have written a method in PHP which breaks up larger than the byte size of the key of the certificate used to encrypt, and a method in c# which will decrypt said chunks using the corresponding private key.
What I would like to be reviewed is the C# decrypt() function to improve the performance of decrypting each chunk... |
Problem is straightforward, reverse a double linkedlist, any advice on functional bug, performance in terms of algorithm time complexity and code style are highly appreciated.
Code written in Python 2.7.
class DoubleLinkedListNode:
def __init__(self, value, next_node):
self.value = value
self.pre_no... |
So basically I am building an app that helps to download some documents via a rest api.
Here is the SearchViewController
import UIKit
class SearchViewController: UIViewController, UISearchResultsUpdating, UISearchBarDelegate {
let searchController = UISearchController(searchResultsController: nil)
@IBOutlet ... |
Here's the current structure of my directory.
.
├── Show 1
│ ├── Season 1
│ └── Season 2
├── Show 2
├── Season 1
└── Season 2
I want to rename the Season folders to include the name of the Show. The desired structure looks like this :
.
├── Show 1
│ ├── Show 1 - Season 1
│ └── Show 1 - Season 2
├── Sho... |
The task for Project Euler #1 is to find the sum of all the multiples of 3 or 5 below 1000.
Here's what I coded:
#include <stdio.h>
main()
{
int size=1000, i=0, sum=0;
for (i=0; i<size; i++)
{
if (i%3==0 || i%5==0)
{
sum+=i;
}
}
printf("%d", sum);
return 0;... |
I've implemented a command line todo list in Haskell. I've run hlint and build with -Wall, but is there anything else I can improve?
module Main where
import Control.Applicative ((<$>))
import Prelude.Unicode
import System.IO (IOMode(ReadMode, WriteMode), utf8, hClose, hGetContents, hPutStr, hSetEncoding, openFile)
im... |
I'm using this code to compute a cartesian product:
def cartesianProduct[T](in: Seq[Seq[T]]): Seq[Seq[T]] = {
def loop(acc: Seq[T], rest: Seq[Seq[T]]): Seq[Seq[T]] = {
rest match {
case seq :: Nil => seq.map(acc :+ _)
case seq :: remainingSeqs => seq.flatMap(i => loop(acc :+ i, remainingSeqs))
}
... |
I've built a C decoder program. The length of an encoded message will be given and the message itself in the following line. All the characters of the message will be in uppercase letters. The task is to print out the decoded message.
Encoding: A->B, B->C...Y->Z, Z->A (well, you get the idea)
#include<stdio.h>
main()
... |
Background
The gear selector on a car allows the driver to select which state the transmission should be in.
In the example picture, one of the five letters (P, R, N, D & S) lights up to indicate which state the transmission is presently in.
The position of the rotary dial is sufficient to determine which state the ge... |
An Atbash cipher is a simple substitution cipher wherein a key is used to determine what letters to swap, for example:
Original alphabet: abcdefghijklmnopqrstuvwxyz
Substitute (key): zyxwvutsrqponmlkjihgfedcba
Original message: hello world
Altered message: svool dliow
In my program, I get the key by printing the o... |
I wrote a program to show graphically the solution of the problem of the Tower of Hanoi. Here is a video of an example run.
The logic of the solving is taken from StackOverflow (see links in docstring), I wrote the part dealing with the graphics, so review is most welcome on the graphical part that I wrote.
The code is... |
I'm in the process of designing my own programming language and I have absolutely no experience in computer science other than the code I look at.
I created my first lexer, I've improved it enough that the lexer can actually lex its own source code.
What I'm asking here is how can I improve this lexer?
GitHub
#ifndef _... |
I would like to do POS tagging on around 8,000 tweets. I have a function and am using data.table to call it on every row. The problem I'm having is that it takes over 1.5hours to run this chunk of code.
Code:
options(java.parameters = "- Xmx3000m")
library(rJava)
library(NLP)
library(openNLP)
library(data.table,quietly... |
I have been working on some code for a basic inventory management system and I have all the features that I believe are need like adding parts displaying parts list and the such as you can see. I believe I have worked out all the bugs I can find. I'm looking to see if I got all the bugs out and maybe some optimizations... |
Problem statement
Let us first describe a SimpleFunction:
SimpleFunction( string A,string B ){
int answer = 0;
for( int dig = 1; dig <= 9; dig++ ){
if(string A contains digit dig and string B contains digit dig){
answer = answer * 10 + dig;
}
return answer;
}
So b... |
I wrote a log parser in Python and Julia. The Python version takes about 8 seconds to process 350 files, while the Julia version takes about 8 seconds to compile, after which it takes over 20 seconds to process 350 log files.
I wrote the original parser in Python several months ago, with regex, a custom class, and lots... |
I am using this basic extension for a Swift project. It works well, but I want to make sure it is the absolute fastest way to get a substring.
extension String {
func substring(start: Int, end: Int) -> String {
if (start == end || self.strlen() == 0) {
return ""
}
let startIndex ... |
I have a method which does URL decoding on the string value passed along with using Charset:
public String decodeValue(String value, Charset charset) {
if (!Strings.isNullOrEmpty(value)) {
try {
value = URLDecoder.decode(value, charset.name());
} catch (UnsupportedEncodingException ex) {
... |
Mostly robocop and hound give "line is too long" for such code statements. I just wanted to know which one is better and preferable way.
This one is a way to avoid making the message long so just do multiple string interpolation:
timeGet = "<span class='message'>after #{getTime2(online, offline)}</span>"
logs[index].e... |
I haven't done much Python programming, but I really like the language so I've been using it for side projects that I work on. The problem with this is that I don't have the opportunity to have my peers review my code and give suggestions.
I've been working on a project that will be scraping GitHub looking for secur... |
Problem statement
Consider a matrix with \$n\$ rows and \$m\$ columns, where each cell contains either a \$0\$ or a \$1\$ and any cell containing a is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally; in other words, cell \$[i][j]\$ is ... |
Online coding challenge Hacker Rank.
Given a list of unsorted integers, find the pair of elements that have the smallest absolute difference between them? If there are multiple pairs, find them all.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Sol... |
I want to be sure that in terms of auto-layout or just following the proper methods of doing the following is acceptable. I am not sure if there will be an constraint issues or efficiency problems that could slow down my app. It is working so far, I am in the process of trying to animate it as it resizes.
import UIKit
... |
public class ProgressDialogUtils {
private static ProgressDialog progressDialog;
/*
* Create an progaress dialog instance
* @param Context contex
* @Title title of String
*
* */
public static ProgressDialog createProgressDialoge(Context context, String title) {
progressDialo... |
My code:
import subprocess
import os
import platform
class Speaker:
"""
Speaker class for differentiating different speech properties.
"""
def setVoice(self, voice):
self.voice = voice
def setWPM(self, wpm):
self.wpm = wpm
def setPitch(self, pitch):
self.pitch = pitch... |
Here I'm merging a list to end of another list after sorting it according to another list.This should sort processdetails list according to the order in routeplans list if any item not present in processdetails list is found it should keep the order and add it to processdetails list. Simply saying it just merging two l... |
This is a simple implementation of Conway's Game of Life in Java. The algorithm I use is inefficient however. Every Cell's neighbors (alive or dead) are checked on every iteration.
import java.util.Scanner;
public class GameOfLife {
public final static int BOARD_HEIGHT = 20;
public static Cell[][] board = new... |
I am using ButterKnife in my project, and as we know we have to write ButterKnife.bind(this); in all the activities, so I have just created BaseActivity like this:
public class BaseActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState, int layout) {
super.onCreate(savedInst... |
I am currently programming a game in java, and I recently implemented a centralized event dispatcher system in order to decrease coupling between different parts of my game.
My system consists of three classes : GameEventDispatcher, which contains the actual dispatching functionality, GameEventListener, a simple listen... |
I track the hours that I have worked on something in an Excel sheet (actually Google Spreadsheet, but semantics). This is tracked in the following format:
Date | Start (time) | End (time) | Description
I can download this as a CSV and my program will run through it and tell me how many hours I've worked in total and pe... |
I'm working on a project where user adds many products and compare their prices, average price, minimal and many other statistics.
There are two currencies for now, EUR and CZK.
I'm here to ask you for advices - either about performance or a better structuring of my code.
There are for example 10 prices of one produ... |
I've written some Python-code to generate the Norwegian National Identification Numbers.
Being fairly new to Python, I'd really appreciate a review on this code in regards to best practices and style.
import calendar
def is_valid_date(d):
dd,mm,yyyy = [int(i) for i in [d[:2],d[2:4],d[4:]]]
days = {
1:... |
I have created a double-ended container, but I have doubts about its efficiency in terms of performance. Can you please criticize the code? What can be done extra, such as shortening it?
#ifndef EXERCISE_H_
#define EXERCISE_H_
#include <iostream>
typedef unsigned short ushort;
template <typename type_t>
class list{
... |
A quick description on the problem I solved on codewars.com but remember I just want a small part of my solution refactored (just the for-loop):
Description
Vasya wants to climb up a stair of certain amount of steps (Input
parameter 1). There are 2 simple rules that he has to stick to.
Vasya can climb 1 or 2 steps a... |
The code ive written takes the user entered numbers and sorts them into a list and finds the two biggest numbers, im looking to make the code less verbose. any help/advice is greatly appreciated.
def printTwoLargest():
numList = []
num = 'holder'
x=0
y=0
while num != '':
num = input('Please... |
I've finished an implementation of what I believe the Publish-Subscribe pattern is for practice and possible use in personal projects even though this implementation is fairly similar to the Observer/Observable classes of the Java API.
I'm looking for a review of my code-style, JavaDoc usage, API usage, implementation ... |
I've got some code that plots some displays from a weather URL and locations in a CSV file. I'd like to see if anyone can make the code more efficient, the code runs fine without any errors and I'm aware you won't be able to test it, but if anyone could take a look at making a class function or breaking up the function... |
Code directory structure:
./Computing$ ls -LR
.:
fileIO list record file.txt mergeSort.c mergeSort.exe type.h
./record:
record.c record.h
./fileIO:
file.h fileReading.c
./list:
arrayImpl.c linkedListImpl.c list.h
Compilation procedure:
./Computing$
./Computing$ gcc -Wall -Werror -I. -DARRAY ./list/*.c ./reco... |
This code is meant to download images from an image board to create a local backup. Images are grouped by tags selected by the user and then downloaded using multiprocessing. Normal use of this program would be daily or weekly, resulting in a typical download queue of no more than 100. However, if the user opts to down... |
Could someone tell me if this is a bad idea for coding my validation for a password and it is bad? This is for registration for my site. Could you please tell me why and how you would go about it (I am a beginner and at PHP)?
$username = $_POST['username'];
$password = $_POST['password'];
$confirm_password = $_POST['co... |
After having showed a previous implementation of my "Resistance System", I decided that I was completely wrong about how I had been going about things. The system, as it had been presented, was completely erroneous in both theory and execution. I can admit that. Realizing this, I took a step back and realized that I co... |
I wanted to learn about pointers and someone suggested that I give C a try, so I went through Linked List Basics from Stanford CS library, implemented some of the code (and tried to improve the code a bit as I went), as well as wrote "unit tests" (to the extent you can call them such in C).
I'm using "Microsoft (R) C/C... |
Recently, just for fun, I've created a clone of the arcade game Tron. Since I am still a novice when it comes to C++, I would really appreciate all the feedback I can get from those with more experience.
Cleanup.h
#ifndef TRON_CLEANUP_H
#define TRON_CLEANUP_H
#include <utility>
#include <SDL2/SDL.h>
/*
* Recurse thr... |
I am looking for feedback on:
any inputs on unforeseen use-cases where the code would be incorrect.
(floating-point errors, etc).
my method of using a "static class" acceptable
is using the default of 10 decimal places a good default or should I
not round/truncate to decimal places if possible
Acceptable suggestions ... |
I just started to use Python and Pandas. My current solution to a problem looks ugly and inefficient. I would like to know how to improve it. Data file is Census 2010 can be viewed here
Question:
Only looking at the three most populous counties for each state, what are the three most populous states (in order of highe... |
Below is the implementation of a comparer that compares objects of type Region first by index and then by it's type. The sort order of the type is defined within the comparer.
I know, it's a trivial piece of code, however I am happy about any comments about the realization. :)
public class Region
{
public RegionTyp... |
I've been doing lately CodeWars and here's my working code for this challenge.
The challenge :
Take 2 strings s1 and s2 including only letters from a to z. Return a new sorted string, the longest possible, containing distinct letters, - each taken only once - coming from s1 or s2.
My code :
public static String long... |
I have following input range (slider), values allowed are from 0 to 100.
I need to map values from the slider to a input text, with the following rules:
range => text
0 => 2000
100 => 200
With the value in between accordingly.
Currently I am using the following script, which works, but I would... |
For some reason or another, I want to have available unsigned integers of sizes other than 1, 2, 4 and 8 (e.g. an unsigned integer with 3 bytes). For most platforms, compilers don't make those available; so - I rolled my own.
Other than asking for a general review, I will also pose a few specific questions / requests f... |
So uhm, this program allows you to vote to 3 person and has 20 voters. However my teacher want's this reduced by using loops. So here's the program:
import java.util.Scanner;
public class Vote
{
String a, b, c, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20;
int va, ... |
I have three conditions like the following:
if (IsAllTriggersRequired && meterFlag && workFlag && timeFlag)
{
result.Add(new TodayTaskTest { Code = item1.Code, Id = item1.Id, Title = item1.Title });
}
else if (!IsAllTriggersRequired && (meterFlag || workFlag || timeFlag))
{
result.Add(new TodayTaskTest { Code =... |
I have this code that is working as intended I would just like to speed it up.
#include <windows.h>
void pressW();
int main(int argc, char** argv) {
DWORD x = 566;
DWORD y = 967;
DWORD red = 2039797;
DWORD gold = 43963;
DWORD blue = 15715270;
while (true) {
if (GetAsyncKeyState(0x31)... |
Here is my code . I am not sure is it best practice or not? Please help me to clean my code. I initial all value. Should O put all in optional ?. Is there any alternative option? I can do that for sweeter and clean code.
:
class Shop {
var shopId : NSNumber = 0
var imgUrl: String?
var rating : Float = 0... |
I have a very hard time figuring out how to proceed. I built an Access DataBase which I use to process data in order to build several weekly and monthly reports. I wrote VBA codes in Excel and in Access.
Basically, for now, Access VBA processes data, exports tables on temporary workbooks then runs macros on Excel to co... |
I'm searching a way to literally shorten my code.
For the moment my code is this;
if(getDashConfig().getBoolean("enchantments.multifirearrow.enabled")){
MultiFireArrow fire = new MultiFireArrow();
DashEnchant.getEnchants().put(1, fire);
DashEnchant.getStringEnchants().put("multifirearrow", f... |
Occasionally I need to implement periodic checks in a loop in a background thread, a typical example being asynchronous processing using a message queue. While it’s not terribly complicated, I wonder what simpler, more elegant solutions exist.
I post my solution, and I’m eager to hear any constructive criticism!
The r... |
I have solved Project Euler's problem number 47, which reads:
The first two consecutive numbers to have two distinct prime factors
are:
14 = 2 × 7
15 = 3 × 5
The first three consecutive numbers to have three distinct prime
factors are:
644 = 22 × 7 × 23
645 = 3 × 5 × 43
646 = 2 × 17 × 19.
Find the first fou... |
I am doing this Codility problem
You are given N counters, initially set to 0, and you have two possible operations on them:
increase(X) − counter X is increased by 1,
max counter − all counters are set to the maximum value of any counter.
A non-empty zero-indexed array A of M integers is given. This array represent... |
I've got 20'000+ court documents I want to pull specific data points out of: date, document number, verdict. I am using Python and Regex to perform this.
The verdicts are in three languages (German, French and Italian) and some of them have slightly different formatting. I am trying to develop functions for the various... |
I try to avoid keeping passwords etc. in memory or in plain text anywhere. But I am on a huge time crunch and this will only be used internally this week then probably won't get touched again. I just want to make sure this is secure and if not, what the risk is.
I'm mostly concerned about the password sitting in memory... |
I am solving the UVA 11340 problem:
Problem Description
News agency pays money for articles according to some rules. Each
character has its own value (some characters may have value equals to
zero). Author gets his payment as a sum of all character’s values in
the article. You have to determine the amount of money tha... |
I have made a Query Builder, (not the full version of it yet) but I wanna ask if there is someone out there, there can improve this code even more. Will be nice to know so I can code the rest in the better way :)
<?php
class DB {
private static $instance = NULL;
public static function sql(){
self::$in... |
I have a few Flask projects that I want to install, each in their own virtual environment. The approach is derived from this tutorial. The steps to create the VE's are very similar, so they're easy to automate. So I wrote this, as a first step. It seems to work OK:
#! /bin/bash
if [ $# -lt 2 ]
then
echo ... |
Below is the unsorted array and sorted array implementation of priority queue.
Code directory structure:
./code$ ls -LR
.:
pqClient.exe pqClient.c list PriorityQueue type.h
./list:
arrayImpl.c linkedListImpl.c list.h
./PriorityQueue:
arrayImpl.c heapImpl.c PQ.h sortedArrayImpl.c
type.h
/********* type.h *****... |
Count duplicate List<int> in List<List<int>>.
A duplicate is not order-dependent. { 1, 2, 3 } is a duplicate of { 2, 1, 3 }
Looking for speed without getting silly.
public static void CountListTest()
{
List<List<int>> testData = new List<List<int>>
{
new List<int> { 7, 3, 4 },
new List... |
I get an id via Get request to fetch an object from the database.
I have used mysqli prepared statements to avoid any security problems. As I am new to these stuff I would like a confirmation that implemented the logic correctly and safe.
User goes to
website.com/post.php?post=130
In post.php i do the following:
Chec... |
I've been reading the Rust versions of this, and just because I'm kinda tired, I thought I'd just throw together something in C.
Here's my 15 minute effort to solve the 2016 Advent of Code Day 1, Part 1 problem. The task is to follow some directions (90° turns and steps on a rectilinear grid), then state the rectiline... |
I am working with two web applications, one is webform-based Site1 and other is an MVC application Site2.
TODO:
Pass a complex object from Site1 to Site2. In response get View from Site2 to Site1 and display it:
function test()
{
$.ajax(
{
type: 'POST',
... |
I've started my first "job" like 2 weeks ago, and to be honest I've received a quite hard task to do, since I'm beginner with Android, and quite fresh at programming. The thing I needed was to find the way to rotate the buttons while changing orientation of the phone, after some research I've found a solution on the we... |
I've just finished my first program written in Java. It's a simple, boring, yet well-known FizzBuzz challenge where you have to:
Write a program that prints the numbers from 1 to 100. But for
multiples of three print “Fizz” instead of the number and for the
multiples of five print “Buzz”. For numbers which are mul... |
Please check out my code below. I know I might be asking a lot, but this is newbie code which I feel can be improved quite a lot. So far I haven't been able to get it "better", or "simpler".
What does the code do?
The code first grabs all goals from the database. A goal is a simple table:
CREATE TABLE `goals` (
`id` ... |
The gist of the code is that there's an assembly line of products, in this case Toy and Book, that get inspected by workers who then add them to a box. The box is then sent to someone who knows what to do when they receive a box for a given product. I made the fields of Product, Toy, and Book public to shorten the code... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.