instruction stringlengths 71 71.9k |
|---|
I have JSON data that I bind to a table:
Now I would like to export this data to Excel, so I have written this code that involves data formatting of an Excel spreadsheet.
private static MemoryStream JsonToStream<T>(string data, string html, string movieReportName)
{
IEnumerable<T> serializedData = data.Jso... |
I have an implementation to add 2 extremely large numbers, greater than the ceiling provided by long, e.g. 1238913893838383813813813813838... I created a LinkedList of my own as this is the homework requirement:
LinkedList.java
public class LinkedList {
private Node header;
private Node tail;
private int size;
priv... |
I asked this first on stackoverflow and someone told me it was more appropriate to ask here, so I've copied it over. I had some trouble trying to decide the best way to phrase this question so I apologize if it's a duplicate and I just missed it.
I'm trying to optimize code meant to test if a collection of points
... |
I solved this leetcode problem.
The question is.
Implement pow(x, n).
This is my solution.
class Solution {
public:
double doPow(double x, unsigned int n)
{
double result = 1;
while(n > 0)
{
if(n & 1) // if bit is set
{
result = result * x;
... |
I have tried to implement the observer pattern. The code should be able to handle a variable number of observables (set compile time) and notify any number of observers/registerables. Any observable is suitable because of the use of templates. The observers/registerers (?) must be derived from CRegisterableBase. Hence,... |
Lately, I'm using domain model pattern, and my controllers methods often looks like (yii2 example, verify user in loyalty system with Ajax response).
if (LoyaltyDomModel::loyaltyVerification($post_data)) {
if (LoyaltyDomModel::setVerify(Yii::$app->user->identity, $post_data)) {
return ['body'=>'successfu... |
I want to force my compiler (C++ or perhaps CUDA) to unroll certain loops that it would rather not unroll. So, I've written the following:
template <size_t N> struct unroller {
template <typename ForwardIterator, typename Function>
static void unroll(const Function& f, ForwardIterator& it) {
unroll<N/2,... |
This is my first game, I need to know how I could improve this code:
main.cpp
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <sstream>
#include <math.h>
#include "Menu.h"
int main()
{
const int screenX = 600;
const int screenY = 400;
sf::Vector2f paddleSize(10, 60);
const int ba... |
The program reads a file containing a list of numbers, and then writes the ones divisible by 3 to another file, and prints the remaining ones (non-divisible) to a third file.
Declaring, opening, and closing the files is alone over 50% of the code, is there anyway to make it more compact?
#include <stdio.h>
#include <s... |
I have the follow matcher method that should do:
obj = {eins: 'one', zwei: 'two'}
queryA = {eins: 'one'}
queryB = {eins: 'one', zwei: 'deux'}
matcher(obj, queryA) // true
matcher(obj, queryB) // false
const matcher = curryRight(
(state, query) =>
flowRight([
every(Boolean),
map(
(val, key) ... |
I'm looking for advice / best practice to avoid doing a deeply nested set of IF/THEN statements in Rails. The intention is to seed a database.
Short version - without specific examples
My basic pattern is 1 .. n
IF(1st_object_exists) THEN
2nd_object = 1st_object.relationship.create!(args)
IF (2nd_object) THEN
3r... |
This is a program with an 'AI' that plays Bulls and cows.
Bulls and cows is a code-breaking game where you think of 4 digit number and the other layer tries to guess it:
https://en.wikipedia.org/wiki/Bulls_and_Cows
There are two classes:
BandC - where all the logic is.
BcCount - which is a pair of bull and cow co... |
Is there a better way to format the cells with borders than what you get when you record a macro? For example, I want to add borders to a cell range. The recorded code is:
Range("A1:C19").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Bord... |
With thanks to @Mat'sMug and @Comintern for their encouragement, here is a program I wrote to help my team fix medical claim files.
The goal of this program is to make the process of emergency changes to medical claim files as human-proof and rapid as possible, and deliver all the corrected files the analysts need with... |
I wrote a simple Google Crawler in PHP, and my GoogleProxy interface does not seem to follow the Single Responsibility Principle.
Here's my Interface code:
<?php
/**
* Interface that represents an online proxy service.
* Every class that implement it must know how to return the apropriate ResponseInterface to an url ... |
I wrote an adaptive color thresholding function in Python (because OpenCV's cv2.adaptiveThreshold didn't fit my needs) and it is way too slow. I've made it as efficient as I can, but it still takes almost 500 ms on a 1280x720 image. I would greatly appreciate any suggestions that will make this function more efficient!... |
For example, given a string "abcdefghijk", I want my function to print out:
a, b, c, d, e, f, g, h, i, j, k.
ab, bc, cd, de, ef, fg, gh, hi, ij, jk
abc, bcd, cde, def, efg, fgh, ghi, hij, ijk
abcd, bcde
I'm sure there's a better way to do this than what I currently have. What are some optimizations I could do? Mo... |
I implemented a merge sort in Java. Is there any way to improve it? I suspect that in particular the merging part could be improved.
Note: I deliberately removed all the comments.
private static void mergeSort(int[] values) {
if (values.length < 2) {
return;
}
int middle = values.length / 2;
int left... |
I wrote a simple quadratic equation solver with Ruby to help me solve quadratic equations. Please tell me what I did right or wrong, and what I can do to improve it.
#!/usr/bin/ruby
if ARGV.length != 3
STDERR << "Usage: #{$0} <a> <b> <c>\n"
exit 1
end
a = ARGV[0].to_i
b = ARGV[1].to_i
c = ARGV[2].to_i... |
This question is related to my previous question on the brute-force search
for a solution to an unsolved mathematical inequality:
$$3^{k}-2^{k}\left\lfloor \left({\tfrac {3}{2}}\right)^{k}\right\rfloor >2^{k}-\left\lfloor \left({\tfrac {3}{2}}\right)^{k}\right\rfloor -2$$
The following code, tested on Ubuntu 16.04, co... |
I pulled this out of my code bucket and dusted it off earlier today in response to a post over on SO that made me cringe. This was originally written to highlight changes in Excel cells in real time via Worksheet_Change, so it is designed with an eye toward raw speed to avoid blocking the UI. Benchmarks on current har... |
I've been working on a project (link) to download a spreadsheet of known ransomware and properties and turn it into json so I can better consume the information within early detection projects.
I'm new to python - what can I be doing better? The destination json I'm converting can be found here.
update_json.py (entry p... |
I want to make a nav that look like this:
<nav class="socialmediaicons">
<ul>
<li>
<a>
<img>
</a>
</li>
</ul>
</nav>
Using the appendChild() method, and this is what I've done:
The myNode is the nav tag which has already been created via HTML.
var myNode = document.querySelector('.so... |
Here are two implementations I wrote to randomly shuffle cards.
The first method (shuffle) selects a random card, then swaps it to the front.
The second method (shuffle_v2) assumes that if i-1 cards are shuffled well, try to randomly swap card i with any card from 0 to i-1.
Are both methods are good to randomly (unif... |
I'm trying to use shuffle to improve worse case scenario of quick select (e.g. every time, selected pivot value is the largest, so each iteration, only one elements could be removed from judgement).
My solution to this problem is to use shuffle, but I am not sure if using shuffle still have small chance (during every s... |
Consider these functions that allow to convert std::chrono::time_point to/from std::string with a predefined date-time format.
constexpr size_t log10(size_t xx) { return xx == 1 ? 0 : 1 + log10(xx/10); }
template < typename Double, size_t Precision = std::numeric_limits<Double>::digits10, typename TimePoint >
requires... |
I made an object oriented fractal tree in javascript using the p5 library, it consists of three files:
Fraternal Tree.js
branch.js
flower.js
Here is the github repo with the source code. All the main work is done in Fraternal Tree.js
I want to know if I am following good coding practices and naming conventions or no... |
I'm designing an app that will process a set of social media messages which are posted by users. Each message is then scored and there is a reporting layer that will spit out a set of reports. The app is implemented with spring-boot and has to use a Redis DB.
I'm more familiar with RDBM databases and perhaps I'm being ... |
I want to use libusb library in my C++ application. I have created classes which wraps libusb functions. You can see that libusb API is split into 8 sections:
http://libusb.sourceforge.net/api-1.0/modules.html
For me the most necessary sections are:
Device handling and enumeration
Synchronous device I/O
Library initia... |
I would like to ask about your opinion about my code. The idea is simple: I designed my own protocol, where client asks the server about the image, and the server sends the image, following the below steps (this is the actual protocol I wanted to implement):
CLIENT SERVER
... |
I use a circular linked list to implement a queue, and it only holds one last (note that last.next links to the first, not null).
public class Queue<T> {
private Node last;
private int n;
private class Node {
T value;
Node next;
Node(T t, Node n) {
value = t;
... |
Since I have a function which can be done in few ways as usual, I was wondering which way is the best to achieve the form validation where I have only one input field, and I am showing a warning on keyup if the number of characters are in between 1 and 3 as well as enabling disabling submit button based on number of ch... |
Aim of the code is to print all of the strings from one file that match strings from another file. Names of both of the files are provided by command line arguments.
Code:
int main(int argc, char *argv[]){
ifstream answers(argv[1]);
ifstream candidates(argv[2]);
for (string s; getline(answers,s);){
... |
I have recently refactored a REST client library and was hoping to get review for both the class itself and the unit tests that cover it.
This code is developed against PHP 7.1, but tested against PHP 5.6, 7.0 7.1, HipHop VM, and PHP nightly builds.
The full library can be seen on GitHub
RestClient.php
<?php
namespace... |
I have implemented a solution to flatten an array of multiple levels in Javascript. I am just a newbie so forgive any mistakes. Could someone give me any tips to improve the code?
function streamrollArray(arr) {
var copyArr = arr;
var to_return = [];
while (true) {
if (copyArr.length <= 0) { return... |
I have 2 groovy sql resultset, I need to combine the result set so that project_no should be unique and case_no can have multiple elements if there is a duplicate project_no
Below are the 2 groovy sql resultset
[[project_no:0-10001,case_no:00492268],[project_no:0-10160,case_no:01957580],[project_no:1-10014,case_no:0202... |
I implemented the Haversine formula to calculate the distance between two (latitude, longitude) coordinates.
I was wondering if it looks natural to Clojure programmers. What could be improved?
(ns br.com.reactive-poc.calc)
(def raio 6372.795477598)
(defn calculate-distance
"Calcula distância entre duas coordenadas g... |
I’ve solved UVA Problem 100: The 3n + 1 problem . In short, the task was to write a program that calculates a maximum of Collatz sequence lengths for any given range of starting values.
My program:
#ifdef ONLINE_JUDGE
#define NODEBUG
#endif
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <io... |
At work there is an input-system where customers are able to specify weekdays and a starting time for an event. The weekdays are integers in the range from 1 (Monday) to 7 (Sunday).
After the customer has given the needed input, I need to calculate the next possible DateTime for the event. If the event is on the same d... |
I have a list of dictionaries, which I want to make round robin mixing.
sample = [
{'source': 'G', '"serial"': '0'},
{'source': 'G', '"serial"': '1'},
{'source': 'G', '"serial"': '2'},
{'source': 'P', '"serial"': '30'},
{'source': 'P', '"serial"': '0'},
{'source': 'P', '"serial"': '1'},
{'so... |
In the Startup.cs of my ASP.NET Core application I want to configure the LoggingFactory so that it logs into the database. Therefore I create following DBLoggerExtensions class to add a context:
public static class DBLoggerExtensions
{
public static ILoggerFactory AddContext(this ILoggerFactory factory,Func<string,... |
I would like to ask about your opinion about my code. The idea is simple: I designed my own protocol, where client asks server about the image, and the server sends the image, following the below steps (this is the actual protocol I wanted to implement):
CLIENT SERVER
... |
I am using the below code for cropping faces from images in a directory
import cv2
import glob
import os
def facechop(image,imgname):
facedata = "haarcascade_frontalface_default.xml"
cascade = cv2.CascadeClassifier(facedata)
img = cv2.imread(image)
minisize = (img.shape[1],img.shape[0])
miniframe... |
I've created a a function that will move a tile that a user specifies within the game board.
The game board can be from 3*3 up to 9*9 and is filled with values 1 to d - 1.
This function is called within another function that keeps track of "space" array and the 2d "board"array.
This function works however, I feel that ... |
I've made a C++ program that calculates a missing variable in an equation for one of the five following laws of gas:
Boyle's Law
Charles' Law
Gay-Lussac's Law
Avogadro's Principle
Ideal Gas Law
The way I made it includes a lot of repetitive if statement checking and different functions with small variations. I feel l... |
Information
I have a Multiscreen Application written for a Client that basically is displaying Video content with MediaElements bind to a ContentControl on 5 Screens horizontally(5 splittet Videos). Depending on wich view the User is im playing different 5 Videos and Stopping the Other Videos.
I've put the MediaElement... |
I have this simple piece of code from my django project. I feel that it isn't very well written.
Maybe it possible to write this simple function in a better way? Maybe could you give me any advices how to improve this code? I'm trying to learn how to write good quality code.
Or maybe this code is good enough?
import da... |
I have been a Python developer for a few years and I'm going through some simple exercises to learn C++.
Please consider the following Python snippet
# Find the most frequent integer in an array
lst = [1,2,4,3,1,3,1,4,5,15,5,2,3,5,4]
mydict = {}
cnt, itm = 0, ''
for item in lst:
mydict[item] = mydict.get(item,... |
To give some background on this particular code, there is a controller which recieves an object, hashes parts of it and looks into a database to see if there is a similar hash in the db, if there is, it returns a stored result back to the caller.
If a stored hash match isnt found, the current environment is resolved an... |
I am currently working on optimizing my code. In order to do that, I have to make sure that my sequential BFS works perfectly. Then, I should I apply threads or executor service to run it in parallel. Will my BFS break if the graph is too big?
public void bfs(int rootNode, isvisited visitor)
{
// BFS uses Queue data st... |
I am implementing a parent-child relationship, represented by hashes that look like this:
parent = { 'parent' => nil, 'id' => 3 }
child = { 'parent' => parent, 'id' => 7 }
These hashes are data given to me, for example, through a JSON API.
(As per a question in the comments, the JSON for the child would look like:)
{
... |
I'm attempting to solve the "Missing Numbers" challenge on HackerRank where I'm tasked with finding missing elements comparing two arrays.
Foundation's NSCountedSet is a little pokey on large data sets, I rolled my counted set with a Swift Dictionary. I'm able to pass all the test cases with the exception of the last c... |
So, I am either a glutton for punishment, or I have no life, but I wrote a script to answer a question over on Ask Ubuntu as a solution for selecting a random MP3 file in a given directory, and playing it in the specified player of choice. I am half-embarrassed to share this because I know it's not my best work and re... |
I am writing a small program that is supposed to act as a shell of some sorts. It operates off of a few basic structures, one of them being a command, a command_list, and a command_history.
typedef struct command command;
typedef struct
{
char** list;
int len;
} command_history;
typedef struct
{
command*... |
I've written code that solves a problem from codewars.com. My code passes all the tests on the codewars site. It's a simple enough problem to solve naïvely, but I would love to improve the structure.
The prompt for the problem is as follows:
Write a function, persistence, that takes in a positive parameter num
and r... |
I have some code which generates the coordinates of a cylindrically-symmetric surface, with coordinates given as \$(r, \theta, \phi)\$. At the moment, I generate the coordinates of one \$\phi\$ slice, and store that in a \$2 \times N\$ array (for \$N\$ bins), and then in a for loop I copy this array for each value of ... |
When I read this answer, which has code:
linqObject.Where((obj, index) => {
DoWork(obj, index);
return true;
}).ToArray(); //MUST CALL ToArray() or ToList() or something to execute the lazy query, or the loop won't actually execute
My initial reaction was similar to Mark Sowul's comment:
"Wastes memory (allocatin... |
i have some issues dealing with a simple case in my redux-react app: i want to reset an input text after an asynchronous operation ignited by a button.
Let’s say we have an input text in which you put a text and this is passed through a onClick event to a dispatch action.
This action contacts a server and after the ser... |
What I have is a simple weblog consisting of HTML and CSS. I'd like you to pinpoint mistakes (smelly code and so on) and how to improve my code. Opinionated responses are welcomed, given that you can provide solid arguments backing them. I have validated both HTML and CSS, so there are no syntactic mistakes.
* {
ma... |
I have a legacy method toHex(byte[]) used in my application since the beginning of time to store a hexadecimal representation of a byte[] into the database. The byte[] buffer is a SHA256 checksum of a file, which is computed consistently.
Since this method is embodied as private method in a class, in order to compare t... |
I came across this trivial dilemma (a oxymoron for you).
1.
if(condition1) {
for(int i = 0;condition2 ;i++){...}
}
2.
for(int i = 0; condition1 && condition2; i++){...}
Which is more good taste programming?
I would say 1 is more efficient and 2 more elegant.
What you think?
Edit: People downvoting can you please po... |
Using Chris Adamson's book Learning Core Audio I'm getting familiar with Core Audio for Mac/iOS. The code examples are 100% Objective-C. I'm trying to follow along using Swift 3.
This small piece of software is used to find usable AudioStreamBasicDescriptions for a given file type and format.
import Foundation
import ... |
I don't want to use the if-statement chain. Can I write the code in a different way? I want to use the smallest amount of if-statements.
#include <stdio.h>
#include <stdlib.h>
main()
{
int temp;
printf("type a number: "),
scanf("%d", &temp);
printf("\n\n");
if (temp == 18)
{
printf("Th... |
I have implemented a solution to this Cracking the Coding Interview question:
Write a method to replace all spaces in a string with %20.
You may assume that the string has sufficient space at the end of the string to hold the additional characters,
and that you are given the true length of the string.
USE character ar... |
I am a beginner to JavaScript and I know about jQuery Validations however I do not want to use a foundation like jQuery just yet.
I am wondering if what I have done its good or if there is another way to do it other then jQuery?
I won't post the html just the JS. It does work by the way! Just wondering if there is a be... |
I need to sort a large array (5 columns x ~500,000 rows) of string variables by two columns. I have code that works, but it takes an unacceptably long time, particularly because I have to do this on five sheets with different data.
I have been doing research, but the code I found tend to be for either a single column, ... |
I'm returning to Web Development after a number of years working in other areas.
The below image shows what what I have so far looks like. I'm not 100% satisfied with the styling yet, but that's a separate question - I include it here mostly to show what this does. (There will eventually be more fields on the table).
... |
I'm trying to figure out the best way to manage user authentication.
At the moment I'm using this way
include("Conection.php");
$usuario = $_POST["Nick"];
$contra = $_POST["Pass"];
$sql = "SELECT * FROM usuario WHERE Nick = '$usuario' AND Password = '$contra'";
$result = $conn->query($sql);
$row = $result->fetch_asso... |
Last time I worked on a DHT11 sensor and got a lot of feedback, this time I have added another sensor (the BMP180), stored both of them in MySQL, and am now displaying them to the web.
The Raspberry Pi now has an HTTP server running on port 80, and I've built a small little UI to display all my sensor data.
So this is... |
I'm using the WinAPI GetLogicalDriveStrings() function that requires a LPWSTR and am wondering if there is a safer way to do this to ensure there is no memory leak.
Currently I construct an initial pointer to a buffer buf using:
auto buf = GetLogicalDriveStrings(0, nullptr);
Then I create the LPWSTR to be used in lieu... |
I recently implemented the Sieve of Atkin prime generating algorithm in Python. Though I know the term "pythonic" isn't exactly set in stone, I can tell that my program doesn't quite take advantage of python's inherent traits; my program looks like it was written with "C" in mind.
My question is two fold; (1) how can I... |
I have a class called Task which I cannot touch because it's a legacy code and I have two ArrayList made up of Task class which I need to compare. Items can be in any order or there can be duplicates as well in the ArrayList.
What is the best way to compare two ArrayList which has object in it and print out the missing... |
I made a program today that solves the following problem on a programming competition site (open.kattis.com): Check if all statements with the following format X is Y or X not Y are consistent. X and Y are words of the length 1-20 and a-z.
The catch is that every word that rhymes with X in any provided statement is sai... |
Background
I'm about to build a LOB application that resembles an e-commerce solution (without paying and being open to the public). It will be used to receive orders for fulfillment purposes based on fulfillment contracts with one or more companies. The UI will be MVC, and it's a going to be a pretty simple site.
Chal... |
I'm a notetaker for my college, and as part of my duties I have to upload my notes daily. As I type them, this is something I can do from my computer, without needing a scanner. Generally, this involves:
Find the .pdf with the "highest number" (The .pdf's are named <word>XY.pdf where XY is a number. I number them st... |
After I played the game "The Mesh" for a while I figured that I wanted to make a solver in Python. See the video on the website for a quick intro, I also explain the rules below.
The Mesh rules
We start with a number of tiles with integers on them. The target is to combine the integers by addition or subtraction to get... |
I wrote this little program to... I don't know. But it connects to IRC servers using OpenSSL and can login via SASL. The code needs refactoring, of that I'm certain, but I need some advice in that regard, so please roast my code.
tallis.h:
#ifndef TALLIS_H
#define TALLIS_H
#include <openssl/ssl.h>
#include <openssl/bio... |
Based on Node.js in Action (Manning Publications) chapter 2 "Building a Multi-room Chat Application", I've taken the model they presented (which is all typical ES5 and jQuery) and completely rewrote it using ES6 and adding a bit of functionality, as well as JSDoc throughout.
While the functionality is mostly identical ... |
With help from the codereview community, I've written a function to flatten a generic nested array. I have it written several ways but want to focus on the following implementation:
func flatten (input: [Any]) -> [Any] {
var outputArray = [Any] ()
for i in 0..<input.count {
let data = input[i];
... |
I've built a web crawler that starts at an origin URL and crawls the web using a BFS or DFS method. Everything is working fine, but the performance is horrendous. I think the major cause of this is my use of synchronous requests. I've used BeautifulSoup and the Requests library to implement this, so nothing is happen... |
This is an assembler for the Hack assembly language as described in "The Elements of Computing Systems" by Nisan and Schocken, MIT Press. The details of the Hack computer and its assembly language can be found at http://www.nand2tetris.org/ if anybody is interested.
I am aware that I am not doing any sort of error che... |
Maybe this is a little large for a simple code review, but I think it included a lot of different needs and how I tried to meet them. Pick a section or function and let me know where I might improve.
The code is for a nand gate simulator and takes an input file with wiring pairs. Like variable to gate or gate to other ... |
I am learning TDD and I want to test my AutoLoader class, what needs to do the next job:
do a check is the namespace is string
do a check, is the path to directory parameter is a string
do a check is the path to directory what I want to load is exists, directory and readable.
There will be more jobs, but I am newbee,... |
I know it's not that bad, but I can't help but wonder if there is a way to make this DRY-er.
s = self.start
e = self.end
if s.x > e.x:
s.x, e.x = e.x, s.x
if s.y > e.y:
s.y, e.y = e.y, s.y
|
I am fairly new to Python and programming. I created this simple calculator inspired by my physics class. However, I feel this code could have been done more efficiently. Is there any advice for efficiency?
import math
#calculates vector x component
#x = side length y = angle
def fxcomponent(x, y):
number = x
y =... |
As a simple programming exercise, I wrote a piece of Node.JS code which generates random poems. It is based on a list of articles (kind of), nouns, linking verbs, and adjectives. It then combines them into lines, and eventually stanzas.
var articles = "The,All of the,Most of the,Some of the,My,Your,His,Her,Their,Our,Ev... |
NOTE: I am not familiar with a lot of terminology. If I am naming things incorrectly, please correct me!
Making small game engine for learning. Mostly using inheritance, but the more my project grows, the more I feel like objects are inheriting to much.
Example of inheriting classes:
Body // Base for x/y and width/hei... |
I'm using the haversine formula to count distance from selected post-code to desired destination.
I have the following scope in App\Models\Business.php:
public function scopeDistance($query, $latitude, $longitude, $radius)
{
$query->getQuery()->orders = [];
return $query->select('*')
->selectRa... |
I wrote a review for Check consistency of a list of statements, with fuzzy rhyme matching, which basically required me to try writing my own solution to fully understand the challenge. So, I thought that I should put my solution up for review.
I'll paraphrase the "Mårten's Theorem" challenge on Kattis:
Given up to 10... |
Problem statement
KnightL is a chess piece that moves in an L shape. We define the possible moves of KnightL(a,b) as any movement from some position (x1, y1) to some (x2, y2) satisfying either of the following:
• x2 = x1 ± a and y2 = y1 ± b or
• x2 = x1 ± b and y2 = y1 ± a or
Note that (a, b) and (b, a) allow for the ... |
Wanted to make a schedule for myself that was (hopefully) light-weight. Right now it just has the bare essential function of saving text for a certain day.
Looking for advice on literally anything that could improve the code ie. more efficient/better style/adhering to standards/etc.
Here is a link to the github reposi... |
I am following the book Programming from the Ground Up and as an answer to a question in the Use the Concepts section of chapter 4:
Convert the maximum program given in the Section called Finding a Maximum
Value in Chapter 3 so that it is a function which takes a pointer to several values
and returns their maximu... |
Problem statement
The city of Gridland is represented as an n X m matrix where the rows are numbered from 1 to n and the columns are numbered from 1 to m.
Gridland has a network of train tracks that always run in straight horizontal lines along a row. In other words, the start and end points of a train track are (r, ... |
I wrote a program in c what looks for integer solutions of different formulas. The program asks the user for a dimension which defines the formula. For example, the formula of the third dimension has three variables, the formula of the second dimension has two variables. The formulas look similar to the following:
dim ... |
The following function determines the amount of indentation of a string. It returns two values. The first is an effective indentation where tabs are expanded such that their end aligns with 4 spaces steps. The second is just the amount of spaces and tabs before the first non-tab/space character.
roundup is a method tha... |
I am just getting started with python. I wanted to make a folder transfer tool to get familiar with python sockets.
import socket, os, sys
print"[*]Enter the IP[*]"
ip = sys.stdin.readline().rstrip()
port = 9999
# A file sender first
def file_sender(location, client_socket):
f = open(location, 'r')
data = f.r... |
I am writing a program to count only the partitions of a number with distinct parts.
I am using a bottom-up approach to dynamic programming to generate partition lists from previously obtained partition lists. I think my program runs correctly, as I have tested for some inputs and verified from OEIS. But it's extremely... |
So I've made a snake game with object-oriented approach. I would be glad if you could take a look at the code and give me any advices/tips/point out errors/etc. :)
main.cpp:
#include "SnakeGame.hpp"
int main(int argc, char **argv)
{
srand(time(0));
int borderSize = 15;
CSnakeGame game(borderSize);
w... |
I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail of the list.
I don't have much experience writing C (I'm more of a Python guy) so please let me know what can be improved!
I am already aware of the followin... |
This is a basic name generator I just wrote and want some feedback.
It basically chooses between a vowel or a consonant and appends it to a string. Note that it never puts two vowels or two consonants directly together, as it checks for that.
import random
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = ['b', 'c', 'd'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.