instruction stringlengths 71 71.9k |
|---|
I'm a beginner with C.
The below is the implementation of circular buffer using linked list. Please review my code and suggest any improvements to make it efficient or to improve in coding style.
#include<stdio.h>
#include <stdlib.h>
struct link_list
{
int item;
struct link_list *next;
};
struct link_list *re... |
I have never used std::shared_ptr before and I don't really know how this smart pointer actually works but I decided to create one to verify my knowledge. Here is my code :
namespace myStd
{
template<class T>
class shared_ptr
{
public :
shared_ptr() : refCount(nullptr), t(nullptr) {}
... |
What do you think about this way to make logging available across the application without passing log object around? Let’s say we have something which allows us to write things this way:
class Program
{
static void Main(string[] args)
{
using (new Log("c:\\a.txt"))
AsyncContext.Run(() => Ma... |
I consider myself a beginner at Java but this question was an easy one. My only concern is if there is a more efficient way to write this program. I'm very open minded. I don't care how advanced your answer is, I'm willing to learn.
public static void main(String[] args) {
long limit = 1000;
long sum = sumO... |
I've been studying data structures and have taken a stab at implementing a singly LL in JavaScript. Please review and advise on any additional improvements and optimizations:
function Node(val){
this.data = val;
this.next = null;
};
function SinglyList(){
this._length = 0;
this.head = null;
};
//Add
SinglyL... |
#!/bin/bash
#assigning variables
start="14:00"
duration="150"
title="Exper. Lab"
year="2016"
start2="17:30"
duration2="230"
title2="Calc1"
# Here I refer to dates that the event occurs on piping the variables into gcalcli (Google calendar command line interface) creating a repeated event on my Google calender
for mo... |
I needed to convert some Ascii text to binary in Hex format 0x00FF....
I've written an EncodeHex and a DecodeHex function to do the conversion.
I've avoided using concatenation in favour of performance.
I'm assuming that assigning the results of CByte("&h80") to a byte array, and then using StrConv to convert the array... |
It is a 1.5 hour coding test, started the moment when the question was sent by email. My solution was done under the strict condition. I was not told anything before the test.
The question is about counting word occurrence in natural language processing. Paraphrased, it asks:
Given an input document and a range k (wi... |
I'm trying to practice some C++ and I wrote a simple queue to solve the Producer-Consumer Problem.
class Queue
{
public:
Queue() : mutex(), cv(), queue(), process(true), consumer(&Queue::dequeue, this)
{
}
~Queue()
{
process = false;
consumer.join();
}
void enqueue(int i)
{
std::lock_guard<std::mutex> lo... |
I want to get records in batches. But mongoid doc says to avoid using skip due as it can be expensive. I wrote this method to iterate through a large number records efficiently.
module Mongoid
module Batches
def find_each(batch_size = 1000)
return to_enum(:find_each, batch_size) unless block_given?
fi... |
Here is a short python snippet to ingest train data:
x_train = []
y_train = []
for x,y in train:
x_train.append(x)
y_train.append(y)
x_train = np.asarray(x_train)
y_train = np.asarray(y_train)
The variable train is a list of 60000 (x,y) tuples.
|
I have a Makefile, which should when calling make just call make in a list of subdirectories. The subdirectories should not be automatically detected but are fine to be hard coded (Tool1, Package2, Submodule3 below). Furthermore, if I call make Tool1, Tool1 should be built (i.e. the directory names should be recognised... |
function executeQuery() {
$.ajax({
url: '../include/activity.php',
success: function(data) {
// do something with the return value here if you like
if(data.error == true){
window.location.href = "login.php";
}
}
});
setTimeout(executeQuery, 3000); // you could choose not ... |
Background:
I am currently in the process of abstracting and refactoring out EF for Dapper with Dapper.Contrib and the entity class definitions from EF are currently being generated by a T4 template. I have not swapped out the entities entirely for generic POCO base classes as yet as the EF implementation is functionin... |
Everything is working fine except timing.
it takes lot time for my file containing 1000 pages and having 100 pages of interest.
import re
from PyPDF2 import PdfFileReader, PdfFileWriter
import glob, os
# find pages
def findText(f, slist):
file = open(f, 'rb')
pdfDoc = PdfFileReader(file)
pages = []
fo... |
I am new to Spark and Scala and I have solved the following problem. I have a table in database with following structure:
id name eid color
1 John S1 green
2 Shaun S2 red
3 Shaun S2 green
4 Shaun S2 g... |
I am pretty new to coding and I wanted to know how to use header and source files to organize a C++ project. I could not yet find out how I should use header and source files to still have my project work - I first thought I could just include .cpp files but I heard it is considered bad practice. I want to learn this f... |
Here is a simple filter function I have:
function filter (attributes, data, include) {
if (include) {
let res = {}
if (typeof attributes === 'string') {
res[attributes] = data[attributes]
return res
}
if (attributes.length) {
attributes.forEach(att... |
I'm new to Python, and just started to learn the principles of Object Oriented Programming, this does not judge strictly.
This code is fully working but confused some elements:
I don't understand what the __init__ method needs to return.
I don't like self. in get_parse that much.
Initially, I did it in order to be ab... |
I use the following MY_ROUND macro for rounding:
#define MY_SIGN(inVal) (((inVal)>=0)? 1 : -1)
#define MY_ROUND(inVal,numDig) (((double)(int)((inVal)*pow((double)10,numDig)+MY_SIGN(inVal)*0.5))/pow((double)10,numDig))
Here inVal is the input double to be rounded and numDig is the number of digits (precision) to round... |
Is there a way to improve this code? Any suggestions are highly appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define DEBUG
#undef DEBUG
typedef struct Node
{
int data;
struct Node *next;
} Node;
typedef struct LinkedList {
Node *head, *tail;
int size;
} LinkedList;
LinkedL... |
This is a follow-up to the previous question located at Singly linked list implementation in pure C
Any suggestions on design and optimization are highly appreciated
LINKEDLIST.H
#ifndef NYO_LINKED_LIST
#define NYO_LINKED_LIST
#include "stdbool.h"
#include "stdio.h"
#include "stdlib.h"
typedef struct Node
{
int d... |
In a parser written with Parsec 3.1.11, I have a performance issue with parsing (or better, skipping) the unreachable branch of a if-then-else statement.
The syntax to be parsed is as follows:
_if (condition) {
# block of statements
} _else {
# block of statements
}
The _else branch is optional and only statically... |
I wrote the following function to convert List[Int] => List[List[Int]].
Its intended purpose is to extract 1, followed by its non 1 followers, into a group.
input: List(1,2,2,1,3,3)
output: List( List(1,2,2), List(1,3,3) )
Function
def leadingOnesGroup(xs: List[Int]): List[List[Int]] =
xs match {
ca... |
I have JavaScript code that activates a button and deactivates another if a select is changed.
HTML
<select name="list" id="list">
<option value="">choose</option>
<option value="1">1</option>
<option value="1">2</option>
<option value="3">3</option>
</select>
<input name="refresh" t... |
I have one writer thread and 10 reader threads of a byte array. It is important to synchronize writes and reads over a "row" (16 bytes).
There are a lot less locks than rows, e.g. in the current configuration 1024 (chunkRows) rows have one lock which makes the overall operation faster, but also consumes less memory.
He... |
I use NLog everywhere and I really don't like writing the inserts everytime. You need to write the same variable three times: two for the insert and one for the parameter for example:
<target xsi:type="Database" name="Log" dbProvider="System.Data.SqlClient" connectionString="...">
<commandText>
INSERT
... |
I am relatively new to classes. This one uses one.
I am pretty sure this is not the correct way to do this. But I also do not know the correct way.
You can use the certified_secure function when you make an instance of crawler that has the URL of hackthissite.org.
Do I have to many comments? Are they too verbose?
#! us... |
This code finds the next obstacle in the player's path, then moves it. I am trying to make it more efficient, because this code runs for each frame, and it lags a bit. It does work though.
There are 8 blockers, which are basically obstacles. We subtract from the players rotation until the rotation is equal to one of th... |
So I'm making a 2d shoot'em up game as a way of learning canvas, and larger-scale programming than what I'm accustomed to. I'm a purely front-end web dev, I can't say I'm very experienced in this.
Anyway the way I spawn my enemies is like this : at xyz gameTime, a spawner object is pushed into the game. This spawner ob... |
Unrelated to code:
I have only been programming for three weeks, and this is my first project.
About the code:
Uses a preset grid.
It was all done on a single page. This, I realise, was a mistake, and I have fixed that since.
I used an int array for the grid. I did first think maybe a Boolean array would be better, b... |
I need to calculate some dates like yesterday, this week/month, last three/ten days etc.
To make it a little bit easier and don't think about the Date weirdness all the time I created this helper:
var HumanDate = function() {
var date = new Date();
this.day = function(numOfDays) {
if (numOfDays === undefined... |
I'm trying to design an application that binds a phrase or word to some item, for example image, and saves phrase-item pair in the database. Then it receives a text, and if it contains binded substring, corresponding item should be returned.
It should return only one item (first match), and longest substrings should t... |
I wanted to use the Try helper from @DmitryNogin's General Retry Strategy #2 but each attempt to implement it revealed another thing that is missing.
In my review I mentioned that it would be useful to be able to log the exceptions but later I came to the conclusion that perhaps it would be better to implement somethin... |
I've made a simple one page site to practise using Bootstrap. Could you please look at the HTML & CSS and check for possible improvements?
Here's a page.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link... |
I wrote a little Compose function, which takes a variable number of arguments of type function and then calls each of those in order, passing in the value of the previously called function.
My function works just like I want it to, however since the function provides a way to program functionally, I figured it's applic... |
This is my first attempt at PHP PDO. I needed to get data from two tables in my MySQL database. I'm pleased to say the code works, and I was just wondering if what I've done is correct.
<?php
// MySQL Database Connection
$db = new PDO('mysql:host=localhost;dbname=database;charset=utf8mb4', 'root', '');
$db->setAttribu... |
I wrote an update() function to make an entry the first element in an array.
var arr = [
{v: 1},
{v: 2},
{v: 3},
{v: 4},
];
function update(e) {
var i = arr.findIndex(o => o.v === e.v);
if (i === 0) return;
if (i > 0) arr = [e].concat(arr.slice(0, i), arr.slice(i+1));
if (i < 0) arr = [... |
I have this little convenience method that takes an String array and returns an String where the values are separated by a provided separator (comma, pipe, etc).
For instance, if given an array with values "abc", "def" and "ghi", and a for separator we passed " | ", the end result would be "abc | def | ghi".
This is t... |
I am trying to get to grips with native JavaScript and wean myself off jQuery, so as an exercise, I wrote the following to check or uncheck checkboxes depending on which link is clicked.
Could this have been written more concisely? Does it follow what you would consider to be best practise?
<ul>
<li><a href="java... |
This question is a continuation of: Sending email using libcurl - follow-up
Does this code have any problems? Can I improve it?
#include <string>
#include <sstream>
#include <iostream>
#include <ctime>
#include <algorithm>
#include <random>
#include <curl/curl.h>
class EmailAddress
{
public:
EmailAddress(const ch... |
The code below is an attempt at a solution to an exercise from the book "Cracking the Coding Interview."
I believe that the worst case time complexity of the code below is \$O(n)\$, where n is the length of each string (they should be the same length since I am checking if there lengths are equal) and the space compl... |
I haven't done any research into how you actually write a genetic algorithm, so this is my best guess. What I'm really curious to know is two-fold:
Have I created a genetic algorithm?
If I have, how can I continue to explore the subject more?
I hope this code and docstrings are enough explanation for how the code wor... |
I just want some feedback to improve readability and structure for this implementation of Hangman. The goal was to write it in a purely functional way. However, coming from an imperative background, I found it difficult to organize functional code.
function Hangman(word, revealed = word.replace(/\w/g, '_'), errors = ... |
This is an excerpt of a part of a (very large) program that I'm writing. This particular section handles the creation and management of chat channels.
However, I think that this code is rather complicated and not as clean/easy as it should be.
package com.lolfakename.chat;
import com.lolfakename.LocalUser;
import jav... |
I need to import 2 .s19 files to Excel and then compare across 6 Columns and store the output to a txt file. I have my data from column A to F. My current program doesn't store the data using a dictionary or hashtable. It takes too long to complete as there are around 31k lines in the list 1 and 32k lines in list 2. I ... |
I've done plenty of corrections of the previous code. Dangling pointers seem a fixed problem (correct me If I'm mistaken). The swap/reverse functions are going to be changed soon due to high time complexity. Also the LinkedList_Find() function is not enough specialized for different types of data, such as Person, becau... |
Please criticize as thoroughly as possible, even the smallest thing will be very useful for me.
I'm trying to create a safe and easy system to change for future projects. I am aware that it should have a lot more functionality (check email, access attempts, notification by email, etc.), but this is what I have at the m... |
I'm trying to get hired by some company and they gave me a simple remote test to take at home so they can judge my coding skills.
It's a really simple problem based on the website HackerRank. It's a mini game where you have to keep track of the score of a tennis game (0-15-30-40-ADV).
This is really basic and I managed... |
The primary purpose of this program is to practice catching if the user enters data that does not correspond to expected input. Note if the user enters their name as "123", this is valid as it can be used as an identity, however if users enter only spaces (i.e. " ") or just a newline char then their input will be re... |
Problem statement:
Two singly linked lists join at a common node, making a Y shape. It is guaranteed that the common tail does not loop back. Find the junction node. Linear time, constant space.
It is an exercise for my students; nothing competitive.
This is what's provided:
list.h
#ifndef LIST_H
#define LIST_H
#i... |
In order to only show relevant information to my users I want to disable the whole panel when all fields inside that panel are empty.
Currently I do this hacky method to get to this result:
if resource.phone.present? or
resource.fax.present? or
resource.email.present? or
resource.website.present?
panel ... |
I'm solving this problem from codeforces. I've a solution which has complexity of O(n²). But the time limit exceeds on some of the test cases. The problem statement is:
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of th... |
The other day I stumbled upon this question on Stack Overflow about the lack of a get method on the Set and loved the suggestion of using a Map<E,E> to back the Set. I decided to try this out. Since this is quite a generic object that could serve a lot of purposes, I would like to know if there is something weird with ... |
I've written this script to practice (not necessarily memorize, but familiarize myself with) the definitions of a lot of words.
import csv
import random
WORDS = 5 # Number of words
CHOICES = ["A", "B", "C", "D", "E"] # Number and labelling of choices
with open("wordlist.csv") as csvfile:
wordreader = csv.re... |
This is the first python script I've written. It's used to create a local backup of git repos from BitBucket. It works, but I'd like to make it more pythonic if possible.
"""
Script to check BitBucket for all repos accessible by the supplied user and clone,
tar and gzip each one (skipping unmodified and those explici... |
I'm trying to implement a c program using pthreads which prints "1 2 3 4 5" in an infinite loop. I have used conditional variables and mutex to synchronize the pthreads. I'm able to print "1 2 3 4 5" without race condition using conditional variables and mutexes. But the problem occurs when I try to make it an infinite... |
I am trying to compute the surface density profile, given the spherical density profile in 3D for different parameters in order to interpolate and have it as a function of them to use later on for some gravitational lensing modelling. However, looping through all parameters and evaluating the integral over the 2D Radiu... |
Joining a project with some crazy LINQ sorting statements and after refactoring by the team using a custom comparer we found out that it is so slow for some data that you actually think it is an infinite loop.
How to fix this performance issue but still maintaining the sorting requirements?
private static IEnumerable<P... |
Purpose:
Given a target folder, and a list of target sub-strings, determine if the folder (or any of its' sub-folders) has a filename which contains any of the target substrings.
N.B. This class uses Early-Binding and requires a reference to Microsoft Scripting Runtime
Properties:
RootFolder As Folder
String... |
Currently I have a very general purpose A* algorithm, which I've submitted as open sourced at https://github.com/kd7uiy/AStar . I've been trying to speed it up for the last month or so, and while I'm making steady progress, I'm struggling to see anything major that I can do to speed things up at this time. I'm using th... |
I am trying to use Entity framework along with UOW in business class where I want to use this layer across multiple types of applications like web, webapi and Windows Services. So I cooked something from the online resources. Can some one figure out any potential performance or fallback?
Main reason I am trying to writ... |
I have a Django view that ends with this...
return render(request, 'define/see_all.html', context)
I have mocked the render function and
@patch('define.views_func.render')
def test_get_define_see_all_complete(self, mock_render):
"""Testing that the queryset returned properly"""
things = AllThings(group="Word ... |
This question refers to this problem on lintcode. I have a working solution, but it takes too long for the huge testcase. I am wondering how can it be improved? Maybe I can decrease the number of comparisons I make in the outer loop.
class Solution:
# @param strs: A list of strings
# @return: A list of strings... |
Today on Stack Overflow the following question came
https://stackoverflow.com/questions/39393112/find-out-if-string-contains-english-words-only
The question itself has following prerequisites:
A system dictionary that contains all the words of the English language
With the following requirements
The input is a text ... |
I've been studying data structures and have taken a stab at implementing a doubly LL in JavaScript. Please review and advise on any additional improvements and optimizations. I'm more interested in feedback particularly regarding the implementations of removeAt(), contains() and getItem() methods as they share similar,... |
I am managing large CSV files (files ranging from 750 Mb to 10+ Gb), parsing their data into PSObjects, then processing each of those objects based on what is required.
I wrote the following script to churn through these files line by line, filter based on one of the data fields, then close the file. The script work... |
I made this variation of a Caesar cipher. Any tips on improving, either method or underlying algorithm? Don't worry... I promise not to use it to encrypt anything of value.
#########################
# #
# caesarED By: 1 0 3 E #
# 0 ... |
Please help me to improve the JavaScript validator plugin by making it more OO and robust.
Requirement is to trigger the validation if there is an attribute data-formValidate present in the input tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SignUp</title>
<style>
.error {
... |
#include "stdafx.h"
#include <exception>
#include <string>
#include <sstream>
#include <iostream>
#include <atomic>
template <typename T>
class Singleton
{
//thread safe atomic variable to check whether client is creating more than one instance
static std::atomic_flag flag ;
public:
static T& getinstance(... |
I have read the code reviews on this website: this one and this one
So creating the pool in itself might not be that difficult, I'm more worried about the client closing the connection or the connection not being given back to the pool.
So I have tried to implement this answer.
public interface Connection {
Object ... |
I am creating a simple dungeon crawler game. My program runs and does what I want it to do so far, but I am starting to run into difficulty with adding new functionality, and I think one of the main issues is my class design.
I want to refactor my classes according to proper OOP principles, of which I am attempting to ... |
I'm trying to build an application which automatically refreshes the page with fresh stuff from the server. I was trying out the approach with something basic like printing out the time, to test out my approach. I go to the page, and it starts printing the time every 5 seconds in the console. When I switch to offline m... |
I'm developing a webapp in ASP.Net MVC. One of the requirements of the project is that users follow a "workflow". The workflow has a number of steps, and a conditional branch. The workflow is long running (week+) and most steps rely on one or more API calls to a 3rd party.
I have previously wondered about application "... |
Write a function called manipulate_data which will act as follows:
When given a list of integers, return a list, where the first element is the count of positives numbers and the second element is the sum of negative numbers.
Sample code
def manipulate_data(data):
if isinstance(data, (list, tuple, set)):
... |
Hope this is the right place. I've never developed on a team so never had any feedback on my code and I'd like to know what others think. I'm using this in a current project and it is working really well. I couldn't find anything ready made to do what I needed so I figured I'd make it.
Github repo if anyone is interest... |
I am a beginner in Java and I have a hobby project to create a tool for statistical calculations.
Users can upload csv with results of a survey. The responses stored in a Response object which has two maps: Map<Integer, String> questionMap, Map<Integer, String> answerMap, where the integer(questionID) links the questio... |
This is one of my first python projects. I decided to make a semi-complex login system in Python, using MySQL and the Twilio API.
The current features are:
Multi-account support
Two-Factor Authentication
Password Recovery
Password Change
I want some feedback on the code itself. I'm thinking of making a version 2 that... |
I've come up with a way to externalize and read in my .sql files instead of having them in-code as strings. Note that I'm keeping the .sql file in the same package as the DAO (NOT separated into a separate resources folder).
I'm curious what others think about this methodology.
The sqlStatement is inject on class ... |
I am designing a very basic file listing layout in HTML and CSS. Although its working but I would like to know if the following code could be improved upon so that its more good and follows the best practices. I am looking forward of supporting I.E 9+ too. Plus I would like to add a progress bar behind the left-wing. I... |
I have just completed my first JavaScript/jquery project. It searches customers from .JSON file and sorts them by name or ID. Everything just works fine. The thing is, I am not sure that I have understood all the functions and methods that I have written. Could anyone tell me if this is the best way to read .JSON file ... |
This is my first time trying to do anything proper in Boost::Asio, so I would love if someone could look at it and tell me if it makes sense. It's based on examples from documentation and bit of googling around, but I want to know if I've put it correctly together.
I know this code doesn't do anything useful. I want to... |
I've tried to make the code overall more PEP-8 friendly and added more comments to make it more readable. Added some new functions and methods like ranged attack and allegiance.
Play around with it. Use "a" to give characters more moves, "s" to spawn more characters, "d" to spawn Goblins that move randomly, "f" to atta... |
I've been wanting to go async with my HTTP calls but all the methods I tried have not worked, so I resolved to implement this as a task and then improve upon it.
This is what I've come up with so far. Any noticeable improvements or unused techniques to make this go even faster and still produce viable images?
Public Sh... |
First of all: Sorry for my English, that said...
I am developing an obligatory for my University, so far it has a class that provides the user with options to connect to a server (once connected it should offer other functionalities, but I only reached the connection option so far), it only shows console options, and c... |
This is a old email eraser that deletes old unwanted email from your gmail or yahoo inbox, cause guys really we all had the nightmare of selecting and deleting 50 old emails at a time when their are thousands, well this one uses simple python imaplib library to do that, and even shows the email that its deleting with s... |
I am looking to increase the speed of this Excel VBA Nested Loop. The loop compares dates from one sheet to a secondary sheet. If they match, I change the border around the cell to highlight it. It currently works fine, but takes about 30 seconds to process per sub. Is there a way to implement an array or other tact... |
I'm creating an array of dates that won't be selectable in a calendar. The following works, although the way I've gone about it is quite long-winded.
I was wondering if there is a more elegant way of getting all the dates in a month, where dates don't fall on various days a project does run on. It's probably more clea... |
I've been trying to teach myself Rust, and I decided that a simple console calculator would be a good project to learn from.
use std::io;
extern crate regex;
#[macro_use] extern crate lazy_static;
use regex::Regex;
fn main() {
loop {
println!("Enter input:");
let mut input = String::new();
... |
Is the following a good way to use the revealing module pattern?
$(document).ready(function() {
var wordsCounter = (function() {
function init() {
bindEvents();
}
// cache dom
var $textArea = $('#textArea');
var $words = $('#words'); //a span
var $chars = $('#chars'); //a span
fu... |
Could you suggest any improvements in this Lucas sequence's implementation:
from mpmath.libmp import bitcount as _bitlength
def _int_tuple(*i):
return tuple(int(_) for _ in i)
def _lucas_sequence(n, P, Q, k):
"""Return the modular Lucas sequence (U_k, V_k, Q_k).
Given a Lucas sequence defined by P, Q, re... |
As an integral part (pun intended) of my APL interpreter (previous questions: 1 2 3 4), this suite of functions converts any data into integer handles. APL operates on arrays of data cells, so with this encoding my cells are all int but may semantically contain other types. This enables me to have heterogeneous arrays ... |
I recently had quite a lot of fun answering a Stack Overflow question, and I think I've gone a bit overboard and ended up with a fairly decent way of populating a ComboBox from a Range.
Given a simple UserForm featuring some ComboBox1 control that I'd want to populate from a ListObject on Sheet1, the calling/client cod... |
I am currently writing a Java interface to a C library. It mostly just delegates calls and adds a object oriented layer on top of it to make integration into a regular Java program more natural.
The C library talks to a (local) server which in turn communicates with a real device.
My current design uses dependency inje... |
I wrote a library for card games. To demonstrate how it can be used, I also wrote an Exploding Kittens card game as an example.
I'm using CodeClimate to determine cyclomatic complexity. This method in the Exploding Kittens game has complexity too high (6):
def play_card(self, card: KittenCard, player: Player = None, t... |
Assignment:
Write a program which reads a number n from the console. Then
calculates the sum of all odd numbers between 1 and 2n + 1 (incl.).
Assignment also on GitHub, Exercise 0.0.
The functions read_hex and print_eax as well as the header and tail of the script are provided by the tutor.
format PE console
entry... |
I wrote a simple console game, with the idea taken from a Reddit post.
The basic Idea is: Player, controlled via arrow keys, has to escape the maze (reach the exit marked X). If a 2nd player is enabled, he controls a troll via WASD and has to catch the player before he reaches the exit. The 1st player can push walls ... |
I was amazed by std::variant and got inspired to write my own. For now, it supports constructor+destructor pair, assignment operator and get<>() function to retrieve the value. The object doesn't allocate any dynamic memory. All of the supported functions are type safe.
I wanted to use static_assert(), but I found that... |
I wish to get rid of using switch case with statuses twice in my code. But create_message function will be bigger in the future, so must stay and I don't want to create messages in send_user_push_notification directly.
Any ideas?
def send_user_push_notification(order, parse_events)
now = Time.zone.now
case parse_e... |
This program is one of the exercises I solved in my book. Can anyone suggest any improvements to it?
import java.util.Random;
import java.util.Scanner;
public class GuessMyNumber {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random random = new Random();
System.out.pri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.