instruction stringlengths 71 71.9k |
|---|
A message can contain an user name or group name, the user name has to be 2 character long and should contain uppercase ASCII characters only, similarly group name can be 3-10 characters long. There can be any number of these entities with the optional comment at the end.
The message would have the following format:
am... |
I wrote a smooth function that returns a list of all smooth numbers below a certain limit from a list of prime:
repeatMul init limit = takeWhile (<=limit) . scanl (*) init . repeat
smooth limit = (`inner` 1)
where inner [] init = [init]
inner (x:xs) init = repeatMul init limit x >>= inner xs
For instanc... |
I have a login screen on my iOS app. When I click login button I want to make sure that user should be displayed a loading image in center of the screen.
I found lots of different methods online but I am after a simplest method. I found a way to display activity Indicator with minimum code:
First of all, import your UI... |
I've created a simple logging system that I'm planning to use and I've tried out some modern C++ features to make it generic. First I've made a log class that represents a single log message:
struct log : std::stringstream
{
private:
template <typename Level, size_t I = 0, typename... Stamps>
static inline type... |
This simulator visualizes Conway's Game of Life and other lifelike cellular automata rule-sets.
Features:
You can choose from any of the preselected birth/survival thresholds or specify custom thresholds ad hoc.
You can click on cells to toggle them from alive to dead and vice versa.
You can manually step through t... |
I needed to make a point class for a term project that involved arbitrary dimensional points. I came up with this, and I know that it works fine, but I'm looking to improve it so I can reuse it in the future. Any criticisms or suggestions are very much appreciated.
#ifndef POINT_HPP
#define POINT_HPP
#include <array... |
I have written code to get all the MAC addresses in from systems having multiple MAC addresses and I think there's something which needs to be corrected albeit the code runs fine.
Note: I have just tested it on Android.
import re
def getMacs():
macs = []
file = os.popen("getmac").read()
file = file.split("... |
A friend of mine told me he had the following exercises at his interview :
You need to determine when a task will be completed if you are given :
A date when the task is started
The duration of the task in hours (how much hours it should take in total)
The starting time and end time of a working day
Weekends are not... |
This is my code for the implementation of a singly linked list in Python:
class SList:
def __init__(self):
self.root = None
self.size = 0
def insert(self, item):
try:
if not item:
raise ValueError
self.size += 1
if self.root is None:
... |
Recently I have been using more macros in my C++ code. I wrote a class with a private static const float because it is useful to prevent making mistakes. Then I thought, why use a private static const if a macro could solve the same problem, without taking up 4 bytes of memory?
#pragma once
#include "VehicleType.h"
#... |
Here's my implementation of doubly linked list in Python:
class DList:
def __init__(self):
self.head = None
self.size = 0
def insert(self, data):
self.size += 1
if self.head is None:
self.head = Node(data)
else:
p = Node(data)
p.next... |
I am scraping the names of the directors from a website using Python / ScraPy. I am very new to coding (under a year and after work) - any views would be appreciated.
The reason I have a for loop with count from 0 to 100 is that not all the names on the website have a date of birth, and hence where there are blanks I ... |
I made this simple event system:
template<typename Func, typename Args>
class Event
{
public:
static void dispatch(Args args) noexcept
{
for (auto listener : listeners)
listener.second(args);
}
static void attach(const std::string& id, Func func) noexcept
{
listeners.ins... |
I wrote this interpreter for a code challenge. Can this be written any cleaner/smaller? Could I reduce the amount of nested conditional/loops?
def brain_luck(code, input)
output = ''
cp = 0 # code pointer
dp = 0 # data pointer
ip = 0 # input pointer
data = Array.new(10, 0)
while cp < code.length
case co... |
I would be really thankful for review of this homework. I'm trying to write better code in terms of readability and design patterns.
This program solves the classic 15 slider puzzle with A* search.
The 15-puzzle (also called Gem Puzzle, Boss Puzzle, Game of Fifteen, Mystic Square and many others) is a sliding puzzle th... |
I'm trying to find out why my web-scraping code with BeautifulSoup (BS) is slower than my code without BS. I would think that BS code would be faster than the other code - so, maybe I'm doing something wrong?
With BS
from bs4 import BeautifulSoup
import requests
import pandas as pd
import time
# start timer
start = ti... |
The locker problem for 100 lockers is simple:
A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. St... |
This is a jQuery time update events for a video player with multiple ids. I feel the code is too long and I need to add more ids to fire events.
$(document).ready(function() {
var i = 0;
var a = 0;
var b = 0;
var c = 0;
var j = 0;
$("#r-news-week1,... |
Recently, I got challenged to code with following bullet points:
Extensible code to support different annual leave rules for HR departments
Maintainable code to add/change the existing rules without any impact on the other clients
Customizable and configurable code for different clients
Exception handling and logg... |
I'm trying to write a program that has a for loop, inside of which I have lambda expression to get a certain value. The loop has about 20,000 iterations. Including this lambda expression increases the execution time significantly. If I include it, it takes about 20 mins for the loop to finish; without it, it takes just... |
I have a list of segment lengths and I want to convert it into array slices:
segment_lens = [2, 5, 5]
last_end = 0
start = 0
end = 0
for s_i in range(len(segment_lens)):
start = last_end
end += segment_lens[s_i]
print("Slice: [%s,%s]" %(start, end,))
last_end = end
Here is the intended output, which ... |
Below is my try.
//DAL
//This is my interface
namespace iPublisher.DAL.Interfaces
{
public interface IReportHandler
{
IEnumerable<DocumentMapper> FetchDocuments(int clientId, int pager);
}
}
//my concrete class
public class ReportHandler : IReportHandler
{
public IEnumerable<DocumentMapper> ... |
I've got a long-running process. Once it finishes I need the output. But the user should be informed while it's running. With the logging module I get timestamps and whatnot preceding. So let's combine all 3:
Prelude:
import os
import logging
import subprocess
from io import IOBase
from sys import stdout
from select i... |
I am trying to get acquainted with C++11/14, so please tell me if the code below could be written in a more "modern" way. Or, of course, if it could be improved in any way.
The function buildInput reads the content of a file and builds a matrix with it.
std::vector<std::vector<int>> buildInput(std::string fileName) {
... |
I would like to get some helpful thoughts on this and if there is a way to break it. Is there any point to not use fgets in that form?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GETNAME_SIZE 100
char *getPhrase() {
int size;
char phrase[GETNAME_SIZE];
char *phraseHolder;
print... |
I'm currently having a bit of code, which I just know can be improved a lot. I am just blind to it. All of my code looks quite neat to me, except these parts... The login + authentication process is taken just way too long because too many calls are being made to the database.
Code is written in Kotlin but syntax is al... |
I'm looking for a way to have an logarithmic incremental counter. The counter goal is related to a numeric value than goes from 1 to Infinity. The counter maximum value should be 1000.
The sequence looks like this:
number is below 10, increment by 1:
1,2,3...7,8,9,10
number is above 10, increment by ^10 when the numb... |
Is the class optimized enough to accept 1 million items in the stack?
class Stack
attr_accessor :stacks
def initialize()
@stacks = []
end
def max ()
#first we could Think by
#sort the stack
#then take the last element
#but I think it is not efficent
if @stacks.size == 0
return pu... |
I have a program that has one job: to determine how many unique numbers there are in a text file. The text file contains a string of numbers created by this other program named Randomizer.py:
# Import random module
import random
# Variables for holding and transporting data
values = []
val_str = ""
def randomize():
... |
This is a follow-up to my question about epidemic simulation. The accepted answer works, but also mentions that I should look at modifying the external_function_call. Here's the complete working code, but it still takes quite a long time to run - in fact, it's slower than what I originally posted.
Here are the first fe... |
I've made the Game of Fifteen in Unity this is how it looks :
The code is rather short there's one class for the pieces and one for the game logic :
MovablePiece : MonoBehaviour
public class MovablePiece : MonoBehaviour
{
public PuzzleGrid.SlotPosition CurrentSlotPosition { get; set; }
private void Start()
... |
The question is this one on UVa, and it basically gives us n, the number of dominoes and (a,b) relations such that pushing a will cause b to fall down too. First t, the test cases is inputted and then number of vertices and edges, and the (a,b) relations.
My approach
My approach was I first run a dfs on the graph (til... |
I'm new in JS and my daily job is PHP, so I decided to do simple MUD Telnet game to practice my JS skills.
The idea was to use async/await to do Telnet server code that seems synchronous at first glance. I run this code with "babel-node app.js".
'use strict';
let Promise = require('bluebird');
let net = Promise.promis... |
I have created a bootstrap toolbar(navbar) which is working.
my question is, since this is my first time on this topic if there is a place for improvement ?
we are using some mock to enter some dummy data and its working
HTML
<!DOCTYPE html>
<html>
<head>
<title>toolbar</title>
<meta charset="utf-8">
<meta name="... |
The goal is to print the highest version and second highest version of the list of files. The version is based on the first three digit places of the version. For example, version 2.3.0.1 version is just 2.3.0 (ignoring the last digit).
Once it can print the highest version and the second highest version of the list, i... |
I'm new to Clojure, and would appreciate feedback on this short program. The problem I set out to solve was selected at random from Project Euler, and is described in the comments. The part that I'm least happy about is the repeated series for the product, which I think could be replaced with a reduce call somehow.
; ... |
I called my template OrderedList, but I don't like the name. Is there a better one?
It stores a vector of values of type T, and a map from each value to its index in the vector.
Just for information, the code should be pure C++03, so please don't suggest how it could be improved with C++11/14/17 extensions, or with Boo... |
I want to create a generic log file which I can easily reuse in multiple files. Also, I want to be able to use the versatile std::cout so I can easily write formatted text (as oppose to create my own write function which may write only strings and which can probably never be that versatile).
Definition
#include <fstrea... |
I am doing interview studying and would like to have another look at my implementation of Floyd's cycle detection algorithm.
I've implemented a simple linked list which can be fluently configured and works generally for any type on stack. The cycle detection method serves:
to find if there are any cycles in list or r... |
After importing some products from a csv strange characters have shown up on the page and it would be too much work to manually go to each product and remove them so I made this script to deploy on that product page and remove them.
$(function() {
var p_desc = $(".rte").html();
var re = /\?ÕÌ_|Š|š|Ž|ž|À|Á|Â|Ã|Ä... |
I have tried to solve the following problem in C# with LINQ:
Given an integer array, find the most frequent number and it's count in the array. If multiple numbers have the same highest frequency return the smallest number.
One requirement here is also to make the code execute in O(1) space complexity.
public struct ... |
I am writing a program that computes
$$n-n \cdot \left(\prod_{i=1}^n (1-\frac{1}{p_i})\right)$$
which is rewritten in my code as:
$$\left(1-\left(\prod_{i=1}^n(1-\frac{1}{p_i})\right)\right) \cdot n$$
There are lots of primes involved here especially as \$n\$ gets larger and larger. I do not want to use Atkin's method ... |
I am an astrophysicist working on large simulations as part of the APOSTLE project. The output of the simulations I use are large (TBs) and are stored in tables spread across multiple hdf5 files. Often, I'm interested in studying a particular simulated galaxy, which is represented by a collection of particles of differ... |
I have implemented the snake game using sdl2 and c. The arrow keys are used for the movement of the snake and if the snake hits the boundary of the window, the game ends. I have not implemented score yet. How can I improve this? Also what should I use for better graphics, instead of using SDL_RenderDraw and SDL_RenderF... |
Here is the Stack abstraction:
/********* stack.h *********/
#include"../list/list.h"
typedef struct Stack Stack;
Stack *createStack();
void push(Stack *, void *item);
void*pop(Stack *);
/*********** stackImpl.c *******/
#include"../list/list.h"
typedef struct Stack{
List *stack;
}Stack;
Stack* createStack(){... |
I am currently working on a Foobar challenge, the Ion Flux Relabelling. I came up with a java solution but Google returns an OutOfMemoryError.
The prompt is, quoting the original question:
Oh no! Commander Lambda's latest experiment to improve the efficiency of her LAMBCHOP doomsday device has backfired spectacularly.... |
I'm building a tool that takes in web requests and deserializes JSON requests into a C# class. Each page calls a different controller URL that is looking for a specific request. Once the request is received, I pipe the request into a method that iterates over each property in the class using reflection looking for the ... |
I've written a Pong game in Java using the Swing library, and while the code works, the ball seems to lag across the screen. Perhaps my code is inefficient. I've included only the Board class because the majority of the code is within it and I reckon its what really needs optimizations. If more code is needed, please l... |
Description:
Huffman coding assigns variable length codewords to fixed length input
characters based on their frequencies. More frequent characters are
assigned shorter codewords and less frequent characters are assigned
longer codewords. A Huffman tree is made for the input string and
characters are decoded b... |
Here is my code for this problem. Any bugs, performance in terms of algorithm time complexity, code style advice are appreciated.
The areas which I want to improve, but do not know how to improve are:
I sort the strings by length and I'm not sure if it's a smarter idea not using sorting at all.
I used a few set operat... |
I have two consumers and each consumer has their own validation logic entirely different from one other so I am using two validator class for that, one for each other.
ConsumerA, for this consumer, I am using ValidatorA.
ConsumerA, for this consumer, I am using ValidatorB.
ConsumerA class
public class ConsumerA exten... |
The question is to find the sum of Digit XOR till \$N\$.
For eg:-
Digit XOR of a number 112
112 => 1 xor 1 xor 2 = 2
So we need to find
int digit_xor_sum=0
for(i=1;i<=N;i++){
digit_xor_sum+= digit_xor(i);
}
return digit_xor_sum
My Solution Approach was as follows,
int digit_xor(int n){
if(n<=9){
ret... |
This is an experiment to investigate how to wire up binding and inheritance in a composable, custom control complex.
Custom Control Structure
There is a custom parent (TestParent) with multiple custom child controls plugged into a ObservableCollection, DP on the parent. The Parent derives from Label and the children f... |
Can my code from this question be improved? I am thiking of validating inputs, portability issues, etc
Please note that we must declare our strings at compile time. We code embedded systems and are not allowed to malloc().
[Update]
I forgot to state that our enums are non-contiguous and have a wide range, which can ma... |
I have this code I use to connect to the database and get a thing from it secure, How can I make more secure??
class db {
// The database connection
protected static $connection;
/**
* Connect to the database
*
* @return bool false on failure / mysqli MySQLi object instance on success
... |
This is my project on inheritance and polymorphism. I have the main file from my teacher and built the project base on it. My base class is Shape. Polygon and Circle inherit from Shape. Triangle and Rectangle inherit from Polygon. All of the class use the class Point. The project is running and working I am not sure t... |
I'm building this menu builder with JS. So far I have a simple version 1 implementation that does what I want but it needs improving. Couple of things that I'd like to improve:
Prevent unwanted input
Control input when there is margin for error, ie for the target field I'd like to have either a drop down or a checkbox... |
As a part of a study-group I did a very simple little JavaScript calculator. It's not made to look pretty.
Any ideas on how I can make the code prettier?
/*
* This is a simple JS calculator
* Made by Gemtastic 2016-05-08
*/
// Gather and set up DOM elements
var numberScreen = 'screen';
var numBtns = document.getE... |
Here's my implementation of Generic Factory using Function library.
It was created using Function library because I understand that the newInstance method is costly (as it uses reflections in the background[not sure about it]) and mostly because our teacher have decided :-).
I wonder about how can it be more generic ... |
My textbook (David Liang's Introduction to Java Programming) asks me to write a program which
prompts a user to specify the number of rows and columns in a matrix
prompts the user to enter each element of the matrix as it would appear in a table
checks that matrix to see if there are any four elements in a row (horizo... |
I've been rewriting parts of my own framework and eventually came back to where it all began, making traits more useful and implementing auto initializing traits and I am wondering if someone has a bright idea on how to implement it a bit cleaner.
The idea of this is simple, let traits have constructors that are called... |
I'm creating 2048 to practice React/Redux. I've got a game board that appropriately shifts, and follows the game rules (it works).
I'm more concerned with my understanding of handling Redux reducers (that seems to be a problematic area for myself, like when I misunderstood reducer purity by adding randomness).
Initiall... |
This is a code review for a set of loggers following this question.
The project is a universal windows application targeting Windows Phone.
There are concerns over the tight coupling between the loggers and App. There is way too much code in the main program that is responsible for setting up the logger just right.
The... |
I have a dataframe:
Name_ID | URL | Count | Rating
------------------------------------------------
ABC | www.example.com/ABC | 10 | 5
123 | www.example.com/123 | 9 | 4
XYZ | www.example.com/XYZ | 5 | 2
ABC111 | www.example.com/ABC111 | 5 | 2
ABC121 | www.example... |
I have some code that searches for duplicate files and then removes those files from a csv. To make the set of files I am searching over much smaller, I first group the files by size; if a file has a size that it is unique, it is safe to assume that it is unique and does not need to be included in the set of files I am... |
I'm working on HackerRank to try to improve my Haskell skills along side with reading Haskell Programming from first principles. I wrote a program that works, but it seems to time out on large input sets. The purpose of the program is
Given a list of n integers a = [a1, a2, ..., an], you have to find those integers w... |
I've written this class that downloads an images, the URLs for which are read from a local .txt file. I'm keen to make sure my code is safe and efficient.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include<cassert>
#include <algorithm>
#include <numeric>
#include <functional>
#include <... |
I have this, and I think it's working? It's been running nearly all day and still isn't finished, so I'm hoping there is a better way to code it.
Right now I have a series of loops that iterate through all my data, but it's taking entirely too long. In short, I have three large worksheets, one master with one identifie... |
I have created a connect four game between a bot and a player. It was quite a bit of a challenge since I wasn't too fond of the minmax algorithm until now. I know there's always room for improvement and I am wondering if someone can tell me if my code is up to standards, i.e. better solutions etc. Please feel free to s... |
std::string time_string;
if ( time_t_var > 0 ) {
time_string = boost::posix_time::to_iso_extended_string(boost::posix_time::from_time_t(time_t_var));
boost::replace_all(time_string , "T" , " ");
}
I have the above to get a time_t to a string in the format Y:M:D H:M:S or simply a blank string in the i... |
I'm designing and developing wizard-like app for populating the database I created with data from different sources. It's my first attempt to design and develop well-structured object-oriented software from scratch (including database, web API + web site + client desktop app and this app for working with database). Sin... |
I'm working on the problem of print a linked list reversely without destruction. I'm wondering if any other better ideas, in terms of both time complexity improvement and space complexity improvement. I also welcome for code bugs and code style advice.
class LinkedListNode:
def __init__(self, value, nextNode):
... |
Working on below problem, looking for advice on code style, functional bug and time complexity improvements.
Also looking for advice in,
If array is not sorted, any solutions available for O(n^2) time complexity?
In my loop, I always search from exclude_index + 1 to reduce duplicate, is it a safe start boundary?
Prob... |
To create a pdfDocument I am using following code which works as expected but do not want to use multiple if else.
Any patterns or any design strategies? It may be a over do for the example , but will be useful.
string fileExtension = Path.GetExtension(fileName).ToLower();
string outPutPath = Path.GetDirectoryName(fi... |
Intro:
I've written a small piece of Python program which is looking for a given sentence in multiple sub directories of a given path.
I'm looking for improvements regarding the speed of my script.
Code:
from os import walk
from os.path import join
def get_magik_files(base_path):
"""
Yields each path from al... |
I am messing with Ruby a little bit and would like to get some feedback about the Spaghettii below :)
Sides = ["X", "O"]
Msg_for_restart = " Starting all over again"
Msg_for_coordinates = "Enter coordinates in the form of x,y"
Msg_for_matrix = "This is how the matrix looks like"
Draw_msg = "The game... |
This is my first PHPUnit test with mocks, for a Symfony 3 project. Can anyone give me some advice about this code?
class CourierManager extends BaseManager
{
/**
* @param Courier $courier
*/
public function create (Courier $courier) : void
{
$this->em->persist($courier);
$this->em-... |
With the programming language skills that are available to me at the time, I've written this program to find the "taxicab numbers" (e.g. a number
expressible as the sum of two cubes in two different ways.)
While this code does work, it is definitely not scalable and it already takes about a minute to solve this for th... |
I am writing a gem for users to interact with a third party api. I want users to have easy and natural access to objects and properties delivered by the JSON payload.
The collection of entities delivered are called Entries so after making an http request I pass the json response to an Entries object like so:
class En... |
I have made a function that wraps text in pygame (i.e. it turns a long string into an array of smaller strings that are short enough so they fit within the given width when rendered in the given font).
My function is below. text is the string we want to break up, font is a pygame font object, and max_width is the numbe... |
The string I'd like to check is something like "abcSun24def". If any valid "xxxyy" (xxx = weekday and yy = day) is found, return the position inside the string. If "xxxyy" is not found, return -1.
The code works as desired, but I think it can be optimized.
/* ------------------------------------------------------------... |
Here is a code block I have:
const _ = require('lodash')
const Box = require('./models/Box')
const boxesToBePicked = await Box.find({ status: 'ready' })
const boxesOriginalIds = _(boxesToBePicked).map('original').compact().uniq().value()
const boxesOriginal = boxesOriginalIds.length ? await Box.find({ _id: { $in: boxe... |
I'm new in Android, Java and the whole object-oriented programming, I'm trying to develop an app which needs to listen on many web services (PHP scripts written by me returning a standardized JSON string) and I thought I could design a class which takes this commitment: ServiceListener.
import org.json.JSONException;
i... |
public class Alphabet {
public static void main(String[] args) {
checkAlphabetic("fdsfsfds+");
}
public static boolean checkAlphabetic(String input) {
char[] chars = input.toCharArray();
int count = 0;
for (int i = 0; i < input.length(); i++) {
if (Character.isLetter(chars[i])) {
count = 1;
} else {
count... |
This is a simple dice game that requires you to get two numbers from the user and then it generates 15 other numbers and checks if the generated numbers are the same as the numbers typed in.
Try to run it on your IDE it will look more cool.
As seen below I have used only static methods:
import java.util.Random;
imp... |
I am new to JavaScript. I've recently completed first 10 Chapters of "JavaScript: The Good Parts".
I've coded this small program to find maximum subarray of an array and would appreciate your feedback on the structure of the program (from JavaScript's point of view). I am basically looking for suggestions in following... |
I wrote a little timer middleware to append the request duration to the end of the log message returned by the excellent Gorilla Toolkit's CombinedLoggingHandler from the handlers package.
That handler accepts an io.Writer and an http.Handler, and fills the Writer with a newline-terminate string containing the Apache C... |
I'm practicing Python. Being completely new to the language I'd like to hear someone else thoughts on the way I use the language. I'm coming from (mainly) Java and C so I'd expect new ways of doing stuff offered by Python which I am surely not aware of because I'm still learning.
I came up with a very simple implementa... |
Playing around in R with a Edx CS50 homework. The job is meant to be done in C, I am using (the more familiar) R just for warmup.
I mainly wonder whether I am breaking any good practice/style norms overall or in any tiny detail.
initials <- function(full.name) {
# Returns initials of a full name
# Input will contai... |
I have written some Python code that uses Scrapy and Selenium to scrape restaurant names and addresses from a website. I needed to use Selenium because the button to show more restaurants on a page is in javascript.
The actual list of restaurants per area is two links deep (three in London) - hence the initial three:
... |
Given an array of integers, sort the array into a wave like array and return it. In other words, arrange the elements into a sequence such that a1 >= a2 <= a3 >= a4 <= a5.....
Example:
Given [1, 2, 3, 4]
One possible answer: [2, 1, 4, 3]
Another possible answer: [4, 1, 3, 2]
NOTE: If there are multiple answers possib... |
I reviewed this question that in my opinion uses a not so pretty batch-save so I tried improve it and this is what I came up with.
In this more generic solution that allows to reuse it I wanted to implement the using statement instead of manually disposing and recreating the context.
It is an extension that you can us... |
In creating this answer to a recent question, I thought I might write a fully worked example that implements a finite state machine in C.
The purpose is to implement the following function:
Given a const char *, search for a string conforming to the pattern WWWDD where WWW is one of { "Mon", "Tue", "Wed, "Thu", "Fri... |
I made a simple Python program which takes a list of unique numbers and orders them from smallest to greatest. The algorithm (which is actually quite similar to bubble sort) works like this:
Take the first number
If it is larger than the next number, switch them
If it is smaller than the next number, do nothing
Con... |
I am looking for advice on how I can improve this code. The objective is to make a vanilla Markov Chain text generator in the most concise way. I'm looking for advice on style, naming, 'elegance', and correctness.
import random, re
with open("corpus.txt") as file:
text = file.read().replace('\n', ' newline ')
tex... |
This is the third question in the series. Number 1 had most of the official two-player rules implemented, and Number 2 was the basic UI. This one has the complete two-player rules implemented, an AI using minimax with alpha-beta pruning. All suggestions welcome, especially those that help me program in a more functi... |
Is writing Java code in chain like _hud.getStage().getCamera().combined an ugly practice?
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1,0,0,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
_batch.setProjectionMatrix(_hud.getStage().getCamera().combined);
_hud.getStage().draw();
}
If ye... |
Description:
You’re given the pointer to the head node of a linked list and a
specific position. Counting backwards from the tail node of the linked
list, get the value of the node at the given position. A position of 0
corresponds to the tail, 1 corresponds to the node before the tail and
so on.
Code:
int Ge... |
I guess for some motivation: I ripped this out of a larger library I'm half-working on to parse S-expressions and cleaned it up a bit.
I'm trying to write a simple function that tests whether a string is a valid quoted string literal. Using Test::LectroTest to compare a fast version of a function using a regex against ... |
The following code works fine for inserting and removing an element from a deque using two threads.
I would appreciate any help on how to make it better, especially in terms of thread safety.
#include "stdafx.h"
#include <deque>
#include <condition_variable>
#include <iostream>
#include <thread>
#include <mutex>
#de... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.