instruction stringlengths 71 71.9k |
|---|
Job -> Many Quotes
Quote -> EmailLogList
EmailLogList -> Many EmailLogs
I want to return a CreatedDate from an EmailLog which has been created most recently - using a Job.Guid.
Is this the best way possible?
public DateTime? GetMostRecentEmailLog(Guid jobGuid)
{
using (DbContext dbContext = new DbContext())
{... |
I have written a module that provides some functions for dealing with Roman numerals. I would like some feedback concerning my style, potential performance or elegance improvements, and any suggestions for additional functions to add.
In particular, I would like to know if there is a clever way to simplify the function... |
I wonder to know if there is any bad smell on my practice for i18n on Angular.
I put the I18n translating function on Angular controller (because I don't know how to put it on HTML template file)
And about the i18n scope, I use this way I18n.t("city." + city_name) to indicate that the city_name is under "city" scope. C... |
This question came from a Java tutorial online:
Write an example that counts the number of times a particular character, such as e, appears in a file.
I was just wondering if there is any way to improve this particular solution.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamRead... |
I have the following code to write:
Modify the Student class so that instead of 3 tests you will now have
an array of 100 tests. However, not all of the scores may be set. You
need to add an additional field to keep track of the number of tests
currently being stored. You will need to modify setTest and getTest ... |
I place various divs on screen by adding random x and y positions successively normalized with this function. My question is, how well is it written? Can I improve it? If so, then how?
I am worried not only about the coding style but also performance since I'm using multiple Math.random()s.
function normalize(n) {
... |
I came to C++ from Java. This is my attempt at making a calculator on about 2 days worth of knowledge. I don't really know what is redundant or unnecessary. Nor do I know of the better ways to achieve this effect.
First class (it does the math):
#pragma once
#include <iostream>
#include <sstream>
#include <string>
usi... |
I am learning C and decided to make an implementation of Base64 encoding according to the info Wikipedia provides about it.
My main question is: should I declare the index_table array inside the get_base64_digit function like static char index_table[] = "blabla"?
A general code review would also be appreciated.
funcs.c... |
I'm writing a struct class in Python and was wondering if this were a good way to write it:
class Struct:
def __init__(self, **kwargs):
for key, value in kwargs.items():
if isinstance(getattr(self, key), str):
setattr(self, key, value)
def create(*args):
newStruct = ... |
I'm updating a website I made awhile ago from a functional design to an OOP design. There are still a lot of functions below this class that I haven't implemented yet but I'm getting to it (such as getUnsentNotifications, fireUnsentNotifications, and other functions such as sendSMS and sendEmail). Please let me know wh... |
I am working on a Laravel 5.1 website where I am counting the average rent of apartments in a specific area. Besides of that I want to get the average rent by amount of rooms in the apartment. The functionality itself isn't anything that hard, but then I want to be able to get the average rent for apartments with e.g. ... |
I am implementing a statistical program and have created a performance bottleneck and was hoping that I could obtain some help from the community to possibly point me in the direction of optimization.
I am creating a set for each row in a file and finding the intersection of that set by comparing the set data of each ... |
I intend to expose a ASP.Net REST API for a project. I would like to use the default ASP.Net Identity system to provide the SQL backend. Users are managed in a different project. For my REST API project I simply point the connectionstring to the same database.
I want to be able to authorize/get the ClaimsIdentity on a ... |
I've picked up the timeout-function below from ActiveState's recipes for Python2 and polished it for python3.4.
Is there any leaner, less clunky way to write it?
import signal, time
class TimedOutExc(Exception):
def __init__(self, value = "Timed Out"):
self.value = value
def __str__(self):
retu... |
I have a dict wherein a value needs to be retrievable by any one of several keys. It seemed that making multiple dictionaries or multiple entries in a single dictionary pointing to the same value object (ref type) was more maintenance than I wanted to commit to.
I decided to use a tuple for the key. I would then use fi... |
I'm currently populating before and after arrays with indexes, based on a number provided. If the input going in is an int, there will be three indexes (left, middle and right). If it is a decimal, there will just be two (left, right). There will me a maximum of three indexes to sort into a maximum of two arrays (befor... |
We are given a map of sides of length n and m (both n and m are less than 1000), divided into n*m fields (squares of side 1). The map looks (for example) like this:
. z x . x
. x x . .
. . x . x
x . . n .
Here n=4 and m=5. We start from the field with "z" and we have to get to the field with "n". Suppose we are at po... |
This is what the code does:
Check if the user's website exists and is active.
After checking the user IP already exists and if the weather 24 hours have passed, if so it deletes the IP database.
Check if there is an ads in the database
Insert a view in the database, insert the ip database
<?php
require_once("../... |
I have refactored the previous combination generator, and now it is an iterator returning combinations as lists. It hides larger constant factors as the previous version, yet it is really easy to use:
for (List<String> combination : new CombinationIterable<>(allStrings)) {
System.out.println(combination);
}
Combin... |
I was given the following instructions
Using the below HTML, using ONLY CSS, JavaScript or jQuery create the following (see attached gif animation):
<div>This is a cube</div>
<div>This is a triangle</div>
<div>This is a big, green circle</div>
Rules:
The HTML cannot be modified in any way
For the animation portion,... |
This is what my viewObject looks like:
{
description: "GOOG AAPL TSLA"
id: 42
ticker_1: "GOOG"
ticker_2: "AAPL"
ticker_3: "TSLA"
timespan: "1mo"
}
Here is the function use to check the object. In a very dirty fashion, it creates a string to be used to replace the URL with:
function createUrl(vi... |
I got the following task to solve:
"PRODUCT_NAME","PRODUCT_CATEGORY","SALES_PRICE"
"Hair Gel","Beauty",6.99
"Scotch tape","Office Supply",2.99
"Office Chair","Office Supply",134.99
"Eraser","Office Supply",0.99
"Lipstick","Beauty",9.99
"Nail Polish","Beauty",8.99
"Note Book","Office Supply",2.99
"Flower Pot","Home & G... |
So I've been looking for examples on the internet for a while now and this seems the most common way everyone is suggesting, but now I ask is there a better way to make a new jframe pop up on click than this.
The code :
JLabel prevention = new JLabel("<html><U><font color='red'>Prevencija</font><U></html>");
preve... |
I am working on an Android unit converter application, but I came to the point where I have to assign the formulas to the calculation method. At the moment I am using a switch-case statement, as it is more neat than an if-else, but still this proves to be very, very lengthy.
The way the application works is the user se... |
Part of my job is to maintain an old application written in Silverlight talking to a WCF service which in turn fetch/persist data into a SQL Server database and in a BI cube.
Most of the security is specified at database level using database roles, users are authenticated using Windows Authentication (integrated secur... |
In preparing a review of this question, I decided to rewrite the code from scratch using a more object oriented approach as I suggested in my review.
To recapitulate the problem statement, we are given an input such as the following:
6 5
. s . . .
. d . . .
. . x . .
. . x . .
. . . . .
. . . . .
The two integers a... |
I know a lot of memory is being used, but how do I make this more efficient in space(and time) .
public class AnagramsTogether {
public static String getAnagramsTogether(String sentence){
if(sentence == null || sentence.trim().equals("")) return null;
String[] words = sentence.split(" ");
... |
This is a simple implementation of a parenthesis-matcher. Given an expression, I want to find out if it is balanced.For example, the expression '{{[[()]]}}' is balanced while '{]{{}}]]' is not. I will output a simple 'NO' is the expression is not balanced and 'YES' if it is.
The algorithm is to push every opening paren... |
I have made a connection pool for SQL Connection objects. The purpose of this object is to provide multi threaded support for the accessing of the underlying database.
The code works by using a reflection proxy for overriding the close() method of the returned connections, so it can detect when the consumer of the API ... |
Task
Write an implementation that determines the count of happy numbers between a given start and end value.
Implementation
public class HappyNumberCounter {
public static int getLastDigit(final long number) {
return Math.toIntExact(number % 10);
}
public static long digitSquareSumCalculator(final long numb... |
I made a simple Blackjack/21 game in C++. It does not use any fancy graphics, just the console output. It is as simple as it can get.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
void printData(int pTotal, int dCard) {
std::cout << "\nYour total is " << pTotal;
std::cout << "\n... |
Here is the problem statement:
Take a second to imagine that you are in a room with 100 chairs arranged in a circle. These chairs are numbered sequentially from One to One Hundred. At some point in time, the person in chair #1 will be told to leave the room. The person in chair #2 will be skipped, and the person in ch... |
I wrote a function that recursively walks a given directory.
module WalkDir (walkDir) where
import System.Directory (doesDirectoryExist, getDirectoryContents)
import System.FilePath ((</>))
walkDir :: FilePath -> IO [FilePath]
walkDir r = contents >>= fmap concat . traverse helper
where contents = fmap (r </>) . ... |
I'm looking for advice on coding practices in general.
public class Knapsack {
public static int getMaxBenefit(int[] weights, int[] benefits, int capacity) {
int[][] maxbenefit = new int[weights.length + 1][capacity + 1];
for (int i = 0; i <= weights.length; i++)
maxbenefit[i][0]... |
Problem statement of PE18 is :
By starting at the top of the triangle below and moving to adjacent numbers
on the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom of the triangle below:
75
... |
Consider this python 3 snippet, where when an import exception is raised, a string 'e' is created that says: "No module named ' packageName'".
The goal is to simply say on exit, that the import error can perhaps be solved by installing a package of the same name. I came up with this, and it works but I'd like to make i... |
My application takes a .csv (comma separated values) file and serializes the data into a binary file. Then it converts the binary file back to a .csv file (identical to the original file).
For example, consider the following .csv file:
John, Appleseed, 435, 89.2
Debbie, Downer, 924, 70.3
Shirley, Temple, 0235, 93.7... |
Can someone please review my code and let me know if there are some bugs or possible improvements?
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
//return true ... |
I was assigned to create a simple Tic Tac Toe game in java for class, and here is what I got. I would like to know how the code could possibly be shortened without using really advanced topics since I haven't covered them yet. Here goes:
import java.util.*;
import javax.swing.JOptionPane;
public class TicTacToe {
... |
The text of a website is checked in a given time period. If there are any changes a mail is sent. There is a option to show/mail the new parts in the website. What could be improved?
#!/usr/bin/env python3
import urllib.request, hashlib, time, html2text, smtplib, datetime, argparse
class urlchange:
def __init__(se... |
I worked around using strtok function so to assign first name and last name to a struct PERSONNE from a char *names[] array. It was not possible to directly modify the *names[] using strtok since it was throwing an exception.
This code works fine but the last loop shows a lot of '\n' until it reaches 10. I am unable to... |
I have 2 alternatives for executing recurring tasks in ASP.NET MVC.
We just need to add some code in Global.asax
First alternative:
private static void ThreadSendNextMail()
{
while (true)
{
HostingEnvironment.QueueBackgroundWorkItem(async cancellationToken =>
{
using (var db = new EFDbContext())
... |
Desired output:
Can I get an shorter version of this code? My instructor just wants me to figure it out my self.
#include <stdio.h>
int main() {
int month,week,day;
printf("Enter month: ");
scanf("%d",&month);
printf("[ 1=Sunday 2=Monday 3=Tuesday 4=Wednesday ]\n[ 5=Thursday 6=Friday 7=Saturd... |
This is the task:
Write a recursive program, which prints all subsets of a given set of N words.
Example input:
words = {'test', 'rock', 'fun'}
Example output:
(), (test), (rock), (fun), (test rock), (test fun),
(rock fun), (test rock fun)
In fact I need to generate all subsets from 0 to words.Length. In Pascal (i... |
I have this class that iterates over all permutations of an input list:
PermutationIterable.java:
package net.coderodde.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
/**
* This class implements an {@code Iterable}... |
Let's say I have this User model:
class User
{
public $id;
public $email;
public $password;
public $errors;
public function isValid()
{
if (strpos($this->email, '@') === false) {
$this->errors['email'] = 'Please enter an email address';
}
if (!$this->password... |
My task for uni is to create a program using structures. In this program I have to make an entry of students, their name, birth date and group (a random number). And I have to search the students according to the input age.
Please note that I am still learning :)
#include <iostream>
#include <cstring>
using namespace ... |
Given a list of \$n\$ objects and an integer \$k \in \{ 1, 2, \dots, n \}\$, this iterator generates all possible ways of partitioning the elements in the list into exactly \$k\$ disjoint, non-empty blocks (partitions).
There is exactly \$S(n, k)\$ such partitions, see https://en.wikipedia.org/wiki/Stirling_numbers_o... |
This is my function for determining the Longest Substring between two strings in Java.
public class Main {
public static String longestSubstring(String str1, String str2){
int row = str1.length();
int col = str2.length();
int[][] checker = new int[row][col];
int max = 0;
i... |
This program makes a call to an API (http://api.football-data.org/) and obtains data for fixtures of Chelsea FC for the next 100 days in JSON format. The JSON is parsed into a Java object and then displays match details in the console. I am looking for any possible improvements I could make to this program. Also, if th... |
Class Student
{
Int studentId,
List<ClassB> Books,
Bool IsPassed
}
Class Book
{
Int bookId,
List<int> pages
}
I am creating a list of students the way below
static void Main(string[] args)
{
var students = GetStudents();
var result = students.GroupBy(r => new { r.StudentId, r.IsPa... |
We have a StreamBuffer class which is not inherited from std::ios_base (or some of it's derivatives such as std::ostream) so that I can use std::fixed operations and I am trying to prevent number showing up in scientific notations. With my below code some numbers are getting shown in scientific notations. We want to av... |
I have written my own CMS for learning, and have included all of my core files below.
This is my first time playing with OOP and prepared statements, so I imagine there may be alot of changing. There is one problem I am having, when I try and check if a username/email already exists in the register function by using ei... |
I have implemented the atof function. Here is my implementation
double atof(const char *str)
{
double a; /* the a value in a*10^b */
double decplace; /* number to divide by if decimal point is seen */
double b; /* The b value (exponent) in a*10^b */
int sign = 1; /* stores ... |
I've been trying to improve my C++ skills as well as work on some general coding techniques so I've attempted to build my first binary search tree in C++ using templates. I've mostly done Java programming but have worked on some smaller C/C++ projects. There are three things that I'm most concerned with to make sure I'... |
I implemented a Vigenere encoding and decoding class. Ideally, the program should be able to take any abritrary file, read into an array of byte, and decode it.
import java.io.*;
class VigenereFilterReader extends FilterReader {
private final char[] key;
private int i = 0;
VigenereFilterReader(Reader in, ... |
I have developed the following implementation of an immutable struct Maybe<T> monad for use in my game project; as an practical exposition on monads to present to my local User Group; and an a demonstration of the use of Static Code Analysis for verification in conjunction with TDD. I am interested in any and all comme... |
I'd like to make sure error details are never sent out in responses from my restify-powered API. The best way to achieve that seemed to be via wrapping server.formatters in another function which filtered-out Errors before passing the transformed body on to the relevant formatter. I've probably missed some more obvious... |
I decided to try and learn Julia for doing scientific computing, and I decided to tackle the problem of finding
$$ \int_{D_{\frac{1}{4}}} x^4 + y^2 dA $$
where \$ D_{\frac{1}{4}} \$ is the part of the unit circle in the first cuadrant.
My code in Julia is the following:
using Distributions
e = 10.0^(-3);
p = 0.85;
var... |
This is an exercise from my computer programming class. This program reads in student scores from the user (input) and displays the total points earned along with a grade. I am tasked with modifying it to ask the user for confirmation when a score higher than 100 is entered. Plainly, it should not add a score greater t... |
I have a Windows program that prompts the user to input a file path and filename. I then check that the file exists with Directory.Exists. Then the user inputs a filename and I check it using this answer to check whether the filename is valid or not (it may or may not yet exist).
using System;
using System.IO;
using Sy... |
My code is basically the home page (index.php) of a website for finding products. It accesses a database table to get a list of all countries and then populates a <select> so the user can add a country to their search filter while finding products.
Are there any website "code smells" in this code?
Is it considered cle... |
Given a 2d array, the problem is to find the largest sum, where each subsequent is >= the previous digit but < all of the 'neighbour' digits. You can only move up, down, left and right.
My solution will run in \$O(N*M)\$ time with \$O(N*M)\$ space (please correct me if I'm wrong).
The solution is as follows: Start at a... |
I have implemented an Array class using templates. I have used a std::allocator object for memory allocation. Will it be better to use operator new along with placement new for memory allocation?
array.h
#ifndef ARRAY_H
#define ARRAY_H
#include <memory>
#include <cstddef>
template <typename T> class Array;
template<... |
This is my first app I have made after learning programming on iOS.
Most of the app is complete just the UI and some features are left to be added.
Any optimizations and coding practices would be very helpful.
The code can be found on my github repo
Download link for zip if there are some problems with github version:... |
I have written code to find whether the path exists between source and destination in a directed graph. I have used BFS and instead of ArrayList or queue. I have written my own helper class.
Please let me know how the code can be improved.
public class Graph {
private int numVertex;
// Helper class, which can ... |
I started writing a script to handle my file downloads in osx because they quickly pile up and it gets time consuming to do this manually by drag and drop. I am looking forward to get some feedback.
require 'filewatcher'
require 'pathname'
require 'fileutils'
class FileAction
def initialize(filename, event)
@fi... |
I'm very new to C++ and Arduino, with a background in Python. I've written this code for a countdown timer and a simple menu to set the time available to each player, using button handling code from here.
It works as expected, but I don't know whether this is good idiomatic C++/Arduino code or if I could be using bette... |
The purpose of this code is to log the inputs of a form (which is a menu for a shop) to the database to be kept as records as well as printed out as a receipt at the store.
I have been learning how to code from the internet and tried to put together my knowledge in a project. The code is working, but I would like to ad... |
Below is the code I have written to enhance my understanding of Command Pattern in Java.
As per my study and understanding, when we have some entities [ which we call as receivers ] then Command pattern is useful in encapsulating those unrelated receivers and the operations in command objects. Please provide me feedba... |
Our Sonar code analysis server tells me
Boolean literals should not be redundant. Redundant Boolean literals
should be removed from expressions to improve readability. Tag:
Clumsy
and categorizes it as a minor bug.
Is this an error in the associated Sonar/FXCop C# rule (maybe it cannot handle nullable types?!) ... |
I've implemented a BackgroundWorker in my WPF app. My code is pretty ugly though. I've been told to write as little as redundant code as possible. IS there some generic Method I could employ to reduce the amount of code?
//BackgroundWorker Databases
private void worker_updateDatabases(object sender, RunWorkerCo... |
Soo... I recently read a meta-post about the inherent problems of reputation. It listed some things like:
Confirmation bias.
Demotivating for low-rep users.
Hubris and elitism of high-rep users over low-rep users.
Incorrect representation of competence.
...
So I thought to myself: "How would the network be, just with... |
How can this method that inserts a hashref into a database table be improved? It assumes that the columns of the database table are named identically to the fields in the hashref. The return value is the id field created by the insert.
sub insert(){
my ($table, $data) = @_;
my ($fields, $placeholders, $values... |
Is there a better way to do this Java 8 String Unique Permutations in Parallel
package com.bos;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.stream.IntStream;
public class StringPermutation {
private static Set<String> set = new ConcurrentSkipLis... |
I am coding a proof of concept on the danger of JavaScript poisoning, XSS and other client side attacks.
Therefore, I coded some JavaScript payloads. As I am not very familiar with JavaScript (I actually hate this language). I would really appreciate if you could give me some recommendations in order to improve the cod... |
I am slowly learning PHP and have been using prepared statements.
I have a simple category.php page, which takes a category tag to display posts from that category, such as localhost/php/category.php?tag=sysadmin. I want to select the Category Title from the "j_oracle_cat" table based on the value of the incoming tag i... |
I've made the following VBA script to analyse text recurrence in a huge batch of descriptions.
For a small part of the batch the code run smoothly, but when I include everything it tends to loose control, get stuck and both Excel and VBE freeze.
What I did to avoid this (at least most of the times), is to include tempo... |
Script intended to remove Vault & Consul setup before run re-provision them on server.
This is my first Ruby script, so will be perfect to see my mistakes here.
#!/usr/bin/env ruby
require 'net/ssh'
$me = File.basename(__FILE__)
print "\n[#{$me}] Vault & Consul DESTROY started on the #{$HOST}.\n"
if not ARGV.empty?... |
I did not find a single working implementation of using an Executor Service with a Blocking Queue. So , I have come with with a working sample. Thoughts?
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import ja... |
In an effort to learn C# / improve my coding skills, I've started working on the Project Euler problems. I see that I may have been overthinking things a bit after finishing problem 7:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can
see that the 6th prime is 13.
What is the 10 001st prime num... |
When a user clicks on "Case", it pops up a box where they have to input a number, which is later used to calculate the value to Euro and around to other values. After this, it checks which value is larger than 0 and writes it to the display box with a white line between each value.
I want to optimize this code. What's ... |
This is my first PHP project - just to write to something to learn from. I made a page with form to send some quote to server and display some quotes from db.
I'm just starting with PHP so point out anything that could help me improve.
Live version.
quote-a-day.php
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/... |
I have code that backup files to remote servers.
There are 2 pandas data frames:
storedfiles: that points to the files already stored in previous runs
filelist: a list of candidates to be stored in one of the depots (comes from a config file).
Filelist structure has the following columns:
In [10]: filelist
Out[10]:
... |
What I need to do is fetch the XML link using curl then get a student ID and check if the ID is present in the database. If yes, then I need to get other details from another database table.
My code works fine but it's kinda slow. I later need to add more functions in this which will make the loading speed slower. Is t... |
I have create a functioning automated traffic light sequence using an array and if statements. It all work correctly but I am wondering if there is anything more I can do to improve my code without changing to structure or way it works, so without the use of dictionary's etc.
<!DOCTYPE html>
<head>
<title> Traffic... |
I'm a freshman in Python world, I used to program in C.
I wrote a function/method that returns the power of a number:
def pow(x, y):
powered = x
if y == 0:
return 1
while y > 1:
powered *= x
y -= 1
return powered
Mine is a logic question (correctly): if I set y = 0 then it ... |
I am trying to write code for simulating movement of single elevator. This was a question to me and was pretty straightforward as the use-case was explained properly. So the problem contains following data:
inputFloors : all floors elevator should go to. e.g. {5, 2, 9, 3, 8, 1}
currentFloor : current floor where eleva... |
I have this (recursive) binary search implementation in Python, and I want you to criticize every aspect of it. It is a naive implementation, (drilling the basics and stuff), but, I want you to comment on the perceived clarity, maintainability of the code, defensive programming practices, test cases that could be usefu... |
This is one part of my website, it fetches a list of habits from my Restful API.
Each description of habit in list gets append to a list item in the HTML. During this loop, a event click listener is attached to each description.
After that, a page navigation will get created.
I made it so that every page will only disp... |
As an exercise, I limited my self to the man pages. I didn't look for a previous existing implementation because I wanted to see how well I could do on my own. I also tried to handle as many cases as I could think of. I am sure there are weaknesses so feel free to point them out. Where can I improve my usage of the C s... |
I'm from PPCG so I was making an esolang and I decided to write it in Python. Eventually it went from an esolang to an OEIS (Online Encyclopedia of Integer Sequences) lookup tool. I'm very new to Python.
Essentially this program takes an OEIS sequence number (e.g. 55 for sequence A000055) and the nth number in the seq... |
I have been working on a simplistic weather application that utilizes the openweathermap.com API. I have an ajax call to make an HTTP request to get a JSON object that contains the data which is returned in the success callback from the HTTP request. I use JQuery to display the response object's data. All of which resi... |
I have a lot of experience in Python and Haskell but am new to C++, so I'm wondering if my code is idiomatic. For one of the first assignments in my class, I wrote a linked list class (the "cities" are nodes in the linked list, the teacher wanted to make things interesting, I guess). Here's the header I had to implemen... |
I'm taking in a string of input from the command line, and when prefixed by 0o or 8# interpreting it as an octal string. I'd like to convert it to a byte array more directly, but I'm not sure how to perform the bit carrying in LINQ.
All three of these methods are fully working; you can checkout the repository or just d... |
This module is going to be part of a larger ElixirChess library for validating chess positions and moves, but I started with the core of it which is parsing a position from FEN notation into a more consumable format and back again. I'm basing this somewhat on Chess.js, so I decided to convert the board to a tuple of pa... |
I'm willing to listen to any advice you have for improving it.
from collections import defaultdict
import nltk
import numpy as np
seq, freq, sample = [t for ts in [[None] + nltk.casual_tokenize(line) + [None] for line in open("file.txt").readlines()] for t in ts], defaultdict(lambda: defaultdict(int)), lambda curr: n... |
Here is my code for converting a sorted array to a binary search tree. Please review and let me know the improvements or some better way of solving this.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeN... |
Here is my code.
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public List<List<Integer>> levelOrder(TreeNode root) {
List<List<Integer>> list = new LinkedLi... |
I just finished writing a program which working with a database. Throughout the process when working with people to get past some of the hurdles I faced I was ridiculed for my SQL statements. I have never fully understand what to do to protect myself and I know there is a lot of information out there to read. But now t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.