instruction stringlengths 71 95.1k |
|---|
I am doing a Pandas project on alcohol consumption. For your information, the dataset has the following columns:
| Continent | Country | Beer | Spirit | Wine |
The following is my code:
# Separating data by continent
# ----------------------------
data_asia = data[data['Continent'] == 'Asia']
data_africa = data[data[... |
Background
I crated a CLI tool which executes an npm command (to create a react app) and modifies the contents of the generated files. It was a practice attempt at creating CLI tools for NodeJS and a chance for me to experience publishing NPM packages.
What I set out to do
My plan was to create something which follows ... |
In an interview I was asked to solve two JavaScript questions. I thought I did pretty well because I:
Covered the edge cases
Wrote comprehensive tests
Documented the code using jsdoc
The interviewer responded with this exact feedback:
Overly Complex Solution, Strange Coding Conventions, Poorly
Structured, Hard to ... |
this is my code to implement DFS with recursion but no stack. I ran few test cases which turned out to be positive but wanted to check the efficiency of the code.
graph = {'A': set(['B', 'C']),
'B': set(['A', 'D', 'E']),
'C': set(['A', 'E']),
'D': set(['B', 'F']),
'E': set(['C', 'B'... |
Just for fun and practice purpose, I have written a short program in C# console with few classes which will create 30 seats for a cinema during program initialization with these options.
Print all seats
Seed 20 random taken seats
Print all empty seats
Print all taken seats
I think my algorithm for generate 20 random ... |
I just implemented a version of A* search in JavaScript for educational purposes. I'd really love it if you could take a look and tell me how to improve my code.
The grid passed in is just a multidimensional array (2-D array) where each slot in the inner array is an object with property weight.
The point of this functi... |
I am new to Haskell and currently trying to port my solutions for the 2019 installment of the coding challenge AdventOfCode to Haskell. So, I would very much appreciate any suggestions how to make the code more readable and more idiomatic. In particular, I am interested in whether my use of the State monad is sensible ... |
I have two lists:
Users - [<UserObject1>, <UserObject2>, ...]
Contributions - [<ContributionObject1>, <ContributionObject2>, ...]
Every ContributionObject further can have single or multiple UserObject in it which are mentioned as person_links here and both the objects that are ContributionObject and UserObject has c... |
This function takes a list, deletes every occurrence of the number 13 and deletes the number present after 13 in every instance and then prints the sum of the list.
How can I shorten it?
def average(nums):
thirteen_idx = []
bad_idx = []
final_list = []
num_length = len(nums)-1
#list of indexes where 13 res... |
I have some legacy code which gets a list of Students and their corresponding School. It's LinqToSql and there is no lazy loading:
public class Student
{
public string FirstName { get; set; }
public string LastName { get; set; }
public School AttendedSchool { get; set; }
public Student(int studentId) {... |
02/02/2020 is a palindrome day because reading the date left-to-right or right-to-left still refers to the same calendar date. And because it doesn't
matter whether you use the DD/MM/YYYY format or the MM.DD.YYYY format, it's called a Universal Palindrome Day.
No one year can have more than 1 palindrome day. This is ... |
I'm trying to calculate with SUMIFS and COUNTIFS some data.
The output sheet looks like this:
I've hidden some irrelevant or sensitive data to make it easy to go to the point.
My code runs an array on this worksheet and calculates per each day and user some KPIs I need from this worksheet:
The calculation is pretty s... |
I have a simple application that reads a couple of csv files and outputs the input into catalogues for the website. However, users have a habit of opening the csv files and inserting extra columns etc and it causes obvious issues, I have tried to tell people not mess with the files with no success, so i thought i woul... |
The intention is to transcribe .docx files to have modified font and font sizes while keeping the run attributes such as bold, underline, italic etc. I'll then add some headers and graphics to the newly created target.docx files
How to reconstruct paragraphs from runs? Each one, currently, gets it's own separate line!
... |
This is not a traditional maze where you find the shortest path (like the gif on the left). In order to solve it, you need to visit every available node before reaching the end, where once a node is visited it turns into a wall (like the gif on the right).
My current solution works quickly for smaller mazes or ... |
I recently downloaded an app called "SoloLearn" to improve my coding skills as I am a beginner with Java while I am not at home. Today I solved the following challenge:
Everything worked but I have a feeling that there is a much easier way to get it done.
Here is my code:
import java.util.ArrayList;
import java.util.S... |
There is a popular game called 4 Pics 1 Word that presents to the user 4 pictures representing a common word. The word has to be typed by selecting some of the 9 random letters appearing below the images.
The German version of this app has an annoying bug. When the random letters contain a letter from the set ÄÖÜß, it ... |
I am trying to XOR two files each 1Mb which contains only 0 and 1. It works, but I think it is very slow for the C++ program - approximately 4 sec.
Could someone, please, suggest the fastest XOR method on large files or at least tell what you think about XORing 1MB files running time? May 0.5sec or 1sec? or even less..... |
I am looking to optimize one function that returns error messages to the user.
/// <summary>
/// Handles the Ouverture event of the PrescriptionVue control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance contai... |
I coded a function that takes an array with numbers and randomly chooses one of these numbers (Returns the index of the chosen one).
The value of each number works as an weight which determines the probability to that number be chosen.
E.G.: A possible input for the function could be [1.5, 3.5, 2.0, 1.3] and the respec... |
I am new to community and please pardon me if I didn't provide information as intended.
This code is supposed to be creating a custom model which will be used with lmfit for curve fitting purposes. hc(q,radius,pd) is the function. It is one of the simplest functions that I will be using but even this function is taking... |
First I'm not sure what this is called formally but whatever.
Basically I need to form "wildcard buckets". I think the best way to explain what I need to do is to take an example. For instance, say I have the three words "aaa", "aab", and "baa".
Let me use * as the wildcard. Then from aaa I can form -aa, a-a, aa-, --a,... |
From the last few days I have been studying scraping webpages and for further development I challenge myself to transform the script I have created into a class which will receive inputs from a user.
The main reason I'm posting this is because I would like advice and insights on how should I approach and manipulate ins... |
This is a simple GUI to display employee data stored in the database, with editing options that sync with the database and adjust display according to mouse clicks/ keyboard scrolling/add/delete ... and please do not mind pictures of dogs, I thought they might look cooler for the sake of demonstration. Awaiting your fe... |
As part of learning Vue and Vue Test Utils I develop some simple games. I made a simple version of craps. Because in many other games a die (or dice) is used, I decided to create a reusable component GameDie.
GameDie.vue
<template>
<span class="dice">{{ dice.icon }}</span>
</template>
<script>
export default {
nam... |
const getSelectedItemsIds = selectedItemsList => {
let keys = Object.keys(selectedItemsList);
let selectedItems = [];
keys.map(k => {
selectedItemsList[k].map(id => {
if (k.includes("projectIds")) {
return selectedItems.push({ type: "PROJECT", id });
} else if (k.includes("subjectGroupId... |
I will be inserting a new text line in a setup.py file, this new line will contain text, and is part of the REQUIRED_PACKAGES. I parsed the
file and look for REQUIRED_PACKAGES pattern (REQUIRED_PACKAGES = [ ... ]). Looking for alternatives during file insertion.
A sample setup.py file looks like this:
from __future__ ... |
Basically I have written a matrix class for addition, multiplication and scalar multiplication.
I need your review of the class implementation below in terms of efficiency, memory consumption and new C++11/14/17 features that can be used.
Here goes the code:
Matrix.hpp
// Created by prajwal.sapare on 2/18/2020.
//
#... |
if ($v->getMedical()) {
$visitorHasMedical = $v->getMedical()->getMedCon() == true; // $visitorHasMedical will be false if "falsey" i.e. empty string or NULL
} else {
$visitorHasMedical = false;
}
Where getMedical() is a OneToOne Doctrine relationship that might not exist.
Does this snippet read OK? Firstly, I... |
I created this function it is looking for the html tag and replacing it with the ^value. It seems complicated wanted to know if there is a better way to do something like this.
Will you review the syntax, structure, and logic of my code. It can be tested using the main.
Output
dsfsadfsad 5<sup>8</sup> dsfsadfsad
ds... |
I am currently coding a tool for my work that modifies a textfile by removing unneeded parts of a string at specific spots in the file.
I would like to know if there are any obvious things I am missing or doing too complicated.
I know that some of the comments are considered too long for PEP8.
class vis_file_tools:
... |
I'm looking to improve my code writing in general by peer review.
I've followed the following exercise: https://edabit.com/challenge/dLnZLi8FjaK6qKcvv.
The exercise is to create an English version Shiritori Game. You can find an explanation by following the link but I'm going to explain below anyway.
The game is a word... |
Team,
I have a working script but when we upgraded some drivers on the GPU system it’s starting to cause zombie process and system is lowing down as script runs periodically as a crib job.
so I am trying to see is there a way I can have a graceful clean up after the Scripts run what is the best procedure to clean up ... |
let date= new Date()
let day = date.getDay()
let weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
changeText = () => {
if(day === 1){
firstD... |
I have two python libraries, let's call them lib and extended_lib, that provide a very similar public API. To be more specific, extended_lib enriches the API of lib with new features and functionality; it also modifies the behavior of some functions that are also provided in lib (e.g. get_version()).
I have a pair of c... |
I made a formula retriever that works and allows importing of fractions.
This python code is meant for the fx-cg50 calculator's micropython, where there are a lot of functions that don't work including fractions, some mathematical functions such as math.gcd and math.isclose. So I really require some advice or coding t... |
I have a weather app that allows the user to save Cities (with nickname and zip) into a room database. I'm using mvvm and livedata to observe the list of cities and update the recyclerview accordingly. I then perform an API call for each item in the recyclerview, which to me seems wrong. It works but seems wrong.
I'd... |
I asked this question on Stackoverflow, but thought it might be a better fit here.
I'm playing around with the titanic dataset, and wanted to create a custom imputer to fill in missing age values with predictions from a LinearRegression model. Please find the code below:
import seaborn as sns
import pandas as pd
from... |
I want inputs on how I can square the sorted Array more efficiently in haskell. I wrote a very naive algorithm to solve the problem. What I am doing is comparing the head and the last element of list on absolute value and whichever is max I square the element and add it to accumulator.
But I think it is very slow. Is t... |
I am beginning to learn about object oriented programming in my programming class, and to make sure I had all the ideas down, I made a small palindrome checker program. It works by checking if the letter on the opposite side is the same.
from time import sleep # To add readability delays
class PalindromeFinder:
... |
I'm new to Haskell, so I wrote a program to crack Caesar Ciphered text for practice. The program calculates the frequency of each letter in the input, and then checks to see which shift minimizes the Euclidean norm of the element-wise difference between the text's frequencies and pre-measured frequencies in the English... |
I've been practicing my folds and tail-call recursive programming, and I wanted to work on unzip for the general case as opposed to just pairs. This was very easy to do with standard tail call recursion. However, I was also told that any time you can use tail call recursion on a list, you could also use a fold. I was e... |
I have a javascript function that will accept an array of objects (from a database or websocket) and then spit out HTML <ul> lists. The code works -- but I am "self-taught" and always learning. I want to be producing professional looking/behaving code. I will be graduating from university, but job prospects in my field... |
I wanted to ask this here because what I wanted to originally do felt like a really Pythonic method. I want to be able to use the syntax:
d = {'apple':{'cranberry':{'banana':{'chocolate':[1,2,3,4,5,6]}}},'b':2}
with d['apple']['cranberry']['banana']['chocolate'] as item:
for i in item:
print(i)
item.ap... |
Intrigued by the events chronicled here (also here and here), I saw the inherent utility in having a program-specific GUID available. The SO answers that were correct seemed a bit tightly-coupled and verbose. So I set out to make my own for use. Looking for a critique on the idea itself as well as maintainability, perf... |
The program was to turn an integer into exact change and uses a bunch of if statements.
Are there steps a beginner like me can do to remove some or is it just how it will be? I can't find anything on it. At least I'm not sure as I'm still in the basic course.
The program is turned in and was fine and this would be fo... |
This was part of a code challenge. I use them to help me learn c++/c# along with tutorials and guides. Basically I was taking a string...
The quick brown fox jumps over the lazy dog.
...and reversing the words in the string like this.
ehT kciuq nworb xof spmuj revo eht yzal .god
The following code works and compi... |
So I needed to represent by objects in terms in ini format and change their values from the ini as well, so I thought why don't implement a property system for this. I want it to be bit fast so I would really like if anyone can remove the std::function if possible but its not necessary. The target application is GUI so... |
id: "1"
email: "TEST@TREST.COM"
selection1: "2"
race1: "1"
selection2: "4"
race2: "1"
selection3: "3"
race3: "0"
selection4: "2"
race4: "0"
selection5: "1"
race5: "0"
selection6: "1"
race6: "0"
selection7: "1"
race7: "0"
This is 1 on the objects in the Json array. so if race1=1 the class .race1 innerhtml = the ema... |
I want to achieve different animation for many elements on scroll, so instead of using window.scroll i'm using intersection observer api, but i want to know if my approach is effective and won't cause performance drop, basically what i did is make a single function to hold the entire animation of the website and check ... |
My code as a whole works for me without issues, but what I want to improve is a small part right out of the middle of it. I hope it's ok to post a simplified snippet here that just shows the structure (it's not something you can copy paste and it works), but I'll try to explain what it is about. If this is against the ... |
I would like to show the tree-like structure contained in a multi-dimensional tuple by using the set of graphical glyphs that exist in Unicode fonts (e.g. \u2500, \u2502, \u2514 and others). Here is an example of the kind of output, I'm talking about:
>>> showtree('(01, (02, 03, 04), 05, ((06, 07), 08), (09, (10, 11),... |
I have a file that i use as database. It has the records and in the row 1 several cells used as buttons, (open folder, copy text, send mail, ecc.) At any change on any column of any record the file register the time in one column in order to have the last change of that record. It also change the color of the row if th... |
I am relatively new to C language and Linux systems I would like some feedback/review. The main function of the code is to read the dhcpcd file looking for the 3 lines and then either adding/removing to the new file. It works and the Pi can switch from AP to client without a reboot, but I feel like it is more of a hack... |
This code is to have a dictionary of names and birthdays.
It will ask who's birthday it is that you're looking for. Then if it is in the dictionary, it will print back what that birthday is. If not, it will ask if you want to add it then have you insert the birthday as the value and use the name that you input before a... |
So I made a Python program to solve some of my A-level binomial questions or just to let me check my answer overall. I need advice on how to make it more compact and simplify it.
This Python code is meant for the fx-cg50 calculator's micropython, where there are a lot of functions that don't work including fractions, s... |
I wrote a Python script to generate a video file of typing the contents of any program file. It works, but I'm really not very happy with how it works. I have several issues with it.
In order to generate the video file I had to generate an image for every character in the file. As you can imagine, this is extremely ti... |
Introduction
I'm working on a Statistics Library that can record observations and produce a Summary of the statistics when there's enough observations. Right now, it's at its early stages and is expected to change a lot as I develop it gradually.
Minimal Example
Suppose I want to record the run time of a particular pi... |
I have a class that needs to provide access to an internal List<int> member. The functions that use this class need to be able to work with that list, mutating the contents and sorting/filtering the list etc, without changing the internal list in the class object. Having a method that provides a copy of the list instea... |
The problem:
I have some text that I go through line-by-line, if I find a line containing the keyword DATA_TYPE_1 and/or DATA_TYPE_2, I know all the following values are that data type. What I do right now is keep track of if the last keyword I saw was DATA_TYPE_1 or DATA_TYPE_2 (or in the case where I see both in the ... |
I have two closely related questions:
1) I have a mixed PHP array. Not mixed in that it contains strings, floats, booleans etc. but mixed in that it is a hybrid indexed / associative array. Most of its entries look like they are from an indexed array while the very last entry looks like it's from an associative array:
... |
I prepared a method to make possible to select elements of the array except for some indexes.
def array_except(array, *indexes)
indexes =
indexes
.flat_map { |e| e.is_a?(Range) ? e.to_a : e }
.map { |e| e.negative? ? e + array.length : e }
array.values_at(*((0...array.length).to_a - indexes))
end
... |
I would appreciate feedback especially if you would be embarrassed by this code, or if I was on your team and you would expect better and/or you would mention something.
This code was derived from comments made on Function To Add DOM Nodes (it also lead to new ideas that are unique to this post).
If there are things th... |
After watching this video by Tom Scott, I decided to make a program that follows that idea. This is what I came up with:
# If a number is divisible by the key, add the value
RULES = {
3: "Fizz",
5: "Buzz"
}
def is_divisible(num: int) -> list:
output = []
for divider in RULES:
if (num % divider... |
Here is my solution for CodeAbbey - Blackjack Counting
My code passes all tests on Code Abbey but I think I have some poor implementation specifically with my handling of the Aces in the score but otherwise I think I overall used good practices and design.
def calculate_player_hand(player_hand_input):
"""Return th... |
I'm still a beginner, so I'm still learning. I'm trying to take test scores for 3 different students, enter them in an array, then display the name, test scores and the average. Trying to also have reusable code for the average. I'm not even sure I'm going about it the right way. This is what I've got so far. It works,... |
This has been done a thousand times on here already, but here's another binary heap implementation. The implementation is generic in terms of heap elements, allows for injection of any type of comparison strategy via the constructor, and has an extra internal lookup scheme to achieve element removal in O(log(n)) time.
... |
I'm in need of a simple wrapper for a fixed-size std::vector that can ensure atomic insertion.
Since my only real problem is with atomic insertion and I know beforehand the amount of entries it will have, I don't need any other parallelism related feature.
I am happy to have the initial allocation (std::vector::resize)... |
This is the function I've wrote to filter a two-dimension array.
I use it mainly on forms with user-defined filter (categories, dates, search bar, etc).
It works fine, but it's ugly.
Do you have any advice?
Function FilterArray(ByVal originalArray As Variant, _
Optional arrayOfColumnToReturn As V... |
I'm new to Python, but have experience in a variety of other languages. I've learnt that a code review early on would make sure I don't start with bad habits. Which are more difficult to get out the longer you keep them.
This is a Discord bot for one of my hobby projects.
import os
import random
import discord
from dis... |
I am trying to make the following function as fast as possible on large matrices. The matrices can have dimensions in the range of 10K-100K. The matrix values are always between 0 and 1. The function resembles matrix multiplication, but with log operations in the inner loop. These log operations appear to be a bottlene... |
I'm working with a ASP.NET Core (v2.2) Web Api project and implemented some APIs. However, I'm facing performance issues, hence trying to optimizing the code. Here is the login API code.
[ValidateModel]
[AllowAnonymous]
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody]UserLoginDto loginDto)
{
va... |
I want to create an object, that represents a progress output.
In a GUI this would be a progress bar, in a console application it may be a text output, that can only be written, but not changed anymore (e.g. the progress bar cannot rewind).
Other possible implementations could include sending a e-mail every 10% of pro... |
I am very new to Rust. I have written a conjugate gradient algorithm function for CsMatrix structure from nalgebra
fn conjugate_gradient(m: &CsMatrix<f64>, rhs: &DVector<f64>, tol: f64, max_iter: Option<u32>) -> DVector<f64> {
let n_iters = max_iter.unwrap_or(1000);
println!("Iters: {}", n_iters);
let mut ... |
function get_sql_string(dbConn,query_string,col_delim,row_delim) {
var result = dbConn.executeCachedQuery( query_string );
var result_string = '';
var column_count = result.getMetaData().getColumnCount();
if ( col_delim ){
col_delim = col_delim;
}
else {
col_delim = ',';
... |
I'm just wondering Is there any ways I could simplify the following code without making it too difficult:
Actually I want to extract specific year data from content node based on lastNumberOfYears variable.
Example: Content array has 2019,2018,2017,2016 years data and lastNumberOfYears value is 2 then output should hav... |
I need to generate random text for tests. I do that using alphanumeric characters and some special characters as well.
For some special cases, I cannot generate the random text with tags.
I have the concept of a tag as text surrounded in curly braces (e.g. {name}).
I have written a simple code to clean up the tags (e.g... |
I recently wrote a python code for matrix exponentiation.
Here's the code:
from typing import List
Matrix = List[List[int]]
MOD = 10 ** 9 + 7
def identity(n: int) -> Matrix:
matrix = [[0] * n for _ in range(n)]
for i in range(n):
matrix[i][i] = 1
return matrix
def multiply(mat1: Matrix, mat2:... |
I want to map functions from my functions library (Map called as chain) to input string str. Also that functions (Twitter.removeRT, ...) are regex which replace substrings in input str. I think it is better to save that regex-functions in Map like in my example.
So, the code:
Tail recursion variant
def filterTwitter2... |
I've written up some code that represents the Mandelbrot set in an, admittedly, quite inefficient way. It probably looks awful due to the fact that I did this completely solo, without any external sources aside from the wiki page. What I was wondering is, how can I, without rewriting it completely, fix my code so that ... |
I wrote the below code today:
class Hosts(object):
def __init__(self):
super(Hosts, self).__init__()
engine, connection = _core.get_engine()
self._engine = engine
self._connection = connection
self._lan_table = self.get_table()
def _get_selected_field_value(self, table,... |
I managed to find a way to rotate a slice in-place (previous question on SO). The slice is linear, but represents a 2d square of elements.
Is this approach efficient?
Please check the previous question linked above if anything is unclear about the algorithm.
Code
enum Rotation {
Clockwise,
Counterclockwise,
}
... |
I was looking to replace my use of axios with just fetch, but I didn't like how verbose fetch was with regard to handling JSON output (having to have a separate then call just to return the json). Unfortunately calling text() first to see if it's a JSON response and then only calling json() if so seems wasteful because... |
Based on this question
Thought it was a nice puzzle
Main idea: How to randomly assign shifts to employees based on these restrictions:
As per the O.P.:
Randomly write to cells "1" or "0"
Employees' total shifts in a month can't be more than 7 and less than 4
According to a few criteria like "Vacation" or "Definite sh... |
In the following code, there are some repeated commands. How can I reduce it and make the code more concise and automate it more?
In the following code, I am trying to read different folder files.
The folders have a fixed kind of structure for all different set of data.
I want to access those folders in easier way su... |
I'm learning OS development and have written a single stage bootloader that loads the kernel, enters to protected mode and finally jumps to the kernel.
I'll very appreciate any feedback and suggestion about the code. I'll be definitely glad to see any suggestions on my build system (Makefile and the linker scripts) an... |
My today's idea was to create a POSIX shell function to dump all given arguments, typical use would be to call it from a fucntion, where you already know some arguments are not well set (empty; not integer) and this way you can inspect all given arguments in one go. It reminds me of a PHP var_dump function. :) Would an... |
I am a beginner android developer. I am working on one of my applications. For this application, I wrote an algorithm that is needed to obtain data that is used to build a diagram. I have a list of objects (value, date).
For these objects, it is necessary to build a diagram either in the last month / two weeks / year.
... |
I'm trying to write something that can take a description and a date range and return all the dates that satisfy that description.
Descriptions can be anything from the following...
parsed_tests_dict = [
{"Saturday": [5]},
{"Sunday": [6]},
{"Weekend": [5, 6]},
{"Weekday": [0, 1, 2, 3, 4]},
{"Monda... |
import itertools
import os
import re
from typing import List
class Command:
"""Base command class which all commands inherit from.
Command class implements all common functions and utilities
between commands, like file and directories handling, and specific
commands like arbitrary, text, or picture co... |
I am working in a system that does not have room for an STL (think something like an Arduino), however I do like the comfort of std::function. For now I am only using this to wrap lambdas, but some sort of std::bind replacement is also on the roadmap. Important to know is that exception handling is not advised on said ... |
I am learning Rust. I have written a web crawler that would scrape all the pages from my own blog (which is running on Ghost) and would generate a static version of it. Because of this, I'm not interested in handling robots.txt or having rate limiting.
extern crate select;
use std::io::Read;
use select::document::Docu... |
I'm writing a translate extension for firefox just similar like google translate extension.
I achieve that the listening mauseup and mousedown events to get selection text and popup a div that you can click.
Due to i am new at javacript, i would like some feedback for above code.
Can i do any improvement?
var bubble... |
After lot of research and couple of questions in https://stackoverflow.com/ i managed to create Favorite System in PDO mysql as database. Am not a developer so there may be security issue or better method with my below code.
config.php
try {
//create PDO connection
$conn = new PDO("mysql:host=" . DBHOST . ";po... |
I've started learning C++ using Microsoft Visual Studio. I'm decided to create a simple GUI program that creates a "snowflake" wherever the user clicks on the screen. Seeing as how this is my first C++ program, I would greatly appreciate feedback on any aspect of my code.
snowflakes.cpp
// Includes //
#include <SFML/Gr... |
I have implemented Dijkstra's algorithm in C++, but it seems a bit complicated since I really tried to follow the process of the algorithm as much as I could. If there's any simplification you would suggest, I would really appreciate, because this task was only for me to get familiarized with this method before the A* ... |
This is a popular question in machine coding rounds. The requirements are to build a URL shortener. There are certain registered users who have the capability to define a URL and an optional time to live. The system generates a shortened URL. The unregistered users can also generate a shortened URL with a predefined TT... |
Roman numerals are represented by seven different symbols: I, V, X, L,
C, D and M.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
For example, two is written as II in Roman numeral, just two one's
added together. Twelve ... |
Someone asked about this question on the main StackOverflow. The full question is:
Given a value N, find p such that all of [p, p + 4, p + 6, p + 10, p + 12, p + 16] are prime.
The sum of [p, p + 4, p + 6, p + 10, p + 12, p + 16] should be at least N.
My thinking is:
Sieve all primes under N
Ignore primes below (... |
I wrote an OCaml program that displays a scrolling marquee in the terminal:
Code:
(* Displays moving text in the terminal.
* Uses VT100 escape sequences.
* Usage:
* ocaml <this-file>
* *)
#load "unix.cma"
let rec loop max_col curr_col =
print_string "\x1B[2J"; (* Clear screen. *)
print_string ("\x1B[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.