2
votes
1answer
9 views
1
vote
0answers
6 views
WebApi action that updating entity using stored procedure
I have ASP.NET WebApi project. Some of controller has method SetAsMain(int id) that get information about people then use stored procedure update people. How can I ...
-1
votes
0answers
7 views
`player_turns': undefined method `map' for nil:NilClass Ruby [on hold]
Not sure what the issue is here. I am replacing a number with X or O using gets. This is for a tictactoe game
...
2
votes
0answers
23 views
Assembler for the HACK assembly language
Here's my assembler for the HACK assembly language, part of the Nand2Tetris course. I'd really appreciate any comments/criticism/help!
If you want to know what input and output files should look ...
0
votes
0answers
12 views
only 'else if' statement will run even while 'if' statement appears true [on hold]
I am writing a script in which if the window is smaller than 990px the nav will flyout on click, however, if the window is larger than 990px it will flyout on hover. However, it is only recognizing ...
1
vote
1answer
15 views
StringRef - read only std::string like class similar to boost::string_ref
Idea behind the class is same as boost::string_ref or llvm::SrtingRef.
StringRef is immutable and not-owning.
I did not ...
2
votes
1answer
33 views
Finding happy numbers
This is a practice question (ref: https://leetcode.com/problems/happy-number/):
A happy number is a number defined by the following process:
Starting with any positive integer, replace the number by ...
2
votes
1answer
25 views
Construct biggest stacked tower with restriction
Problem
The problem is to build the tallest tower made up of cylinders, respecting all the rules.
Will be arranged on the table, an amount of \$N\$ cylinders.
Each cylinder has one color: Red, ...
-1
votes
2answers
26 views
Argument parser for a word count and/or line count program
How to make code dry in this example? My program is working, but I want to improve it by shorting my code.
.
...
4
votes
1answer
26 views
Words in text counter
This accepts text and returns a list of all words which occur with a required frequency (default frequency is 2). It works well, but gets too slow with large texts, more than 1M words. Where can this ...
-2
votes
0answers
16 views
Differentiate between AJAX requests and non-AJAX requests with same action name but different method signatures [on hold]
I'm using C# and ASP.NET MVC Framework 5.
I have the following controller with an action which deals with both AJAX requests and non-AJAX requests:
...
0
votes
0answers
18 views
Adding Item to Generic List in Session [migrated]
I have a session helper so that my session vars are strongly typed:
...
2
votes
1answer
34 views
Data visibility in classes
I want to provide visibility of incoming messages to the two classes GasOrder and OilOrder. I am using Singleton for this. Can ...
6
votes
4answers
753 views
Beheading of knights, who survives?
We have a round table of n knights, where n is some positive integer. These have failed to satisfy the expectations of the mad ...
6
votes
3answers
270 views
Count every word occurrence from file
How good is this algorithm? Personally I think it's over-complicated and needs some improvement. Should I be using iterators here (I think it's "harder" this way) or indexing? Should I stick with a ...
2
votes
4answers
176 views
Checking the validation of a field through the Property mutator method `set`
I'm newish to C#, being mainly Java oriented. I have a field _config which needs to be a value from 1 to 8, and I have this code which checks to make sure I can ...
1
vote
0answers
27 views
Apriori algorithm for frequent itemset generation in Java
I have this algorithm for mining frequent itemsets from a database. In that problem, a person may acquire a list of products bought in a grocery store, and he/she wishes to find out which product ...
2
votes
1answer
26 views
Utopian Tree in F#
This is the Utopian Tree in F# (from HackerRank)
The Utopian tree goes through 2 cycles of growth every year. The first
growth cycle of the tree occurs during the monsoon, when it doubles in
...
0
votes
0answers
26 views
Awful chess move enumeration function slows down when castling is possible [on hold]
I am currently writing a chess engine in VB.NET, and it (mostly) works (if you ignore the fact that checking for check/checkmate doesn't always work ;)). I'm therefore expanding it onto developing an ...
7
votes
1answer
86 views
Deca dimensional ascending and descending array sort function
Some folks told that a two-dimensional array can solve almost all the problems, but let me disagree with that. That's why I made this Deca dimensional array sort function. The array must be ...
11
votes
0answers
169 views
Cardshifter web client deploy script
The Cardshifter web client is coming along! The game client is a web app written mostly in Angular.js and is hosted at at play.cardshifter.com.
@SimonForsberg (who runs the server) is getting tired ...
-6
votes
0answers
38 views
11 out of 12 test cases passing, problem when \$i > 10^9\$ [on hold]
All of my test case are passing correctly except one test case, I can't find the bug in it.
Wet Shark once had 2 sequences:
$${a_n} = {a_1, a_2, a_3, ... , a_(10^{10})}$$
$${b_n} = {b_1, b_2, b_3, ...
-6
votes
0answers
34 views
Hi,This is my code to display contents of a file,count no.of.lines,words and characters.efficient way to count character pls tell me [on hold]
this code counts no.of.lines,words and characters help me in improving my code.
...
-3
votes
0answers
22 views
New to XML, not sure why DTD is not allowing XML to validate, keeps asking for a specific type [on hold]
I have been stuck on this single attribute for 3 hours and I still have a second case problem, a quiz and an entire C# program to finish by Tuesday. I am working on creating my first DTD and as far as ...
-1
votes
0answers
36 views
2
votes
0answers
33 views
C++ Finite State Machine - follow-up
This question is a follow-up from Object Oriented Finite State Machine. I vastly improved commenting and followed the suggestions from the answer. Additionally, I improved my tests and did some more ...
3
votes
0answers
12 views
Cache with timeout per key
I wrote a general purpose library for in-memory cache with custom timeout for each key.
...
3
votes
0answers
44 views
Canvas animation of network nodes and edges
Having to give the idea of an ever changing network of nodes (each with different impact and possibly more than one color) connecting each other to create something.
I wanted to give it depth ...
1
vote
0answers
41 views
Parse a plain text newsletter and show it with nicer markdown formatting
I wrote some code to parse an e-mailed events newsletter I'm on and redisplay it with better formatting. I like the output, but I'm not thrilled with the code. It feels like there's a lot of ...
3
votes
2answers
99 views
Printing an arrow of asterisks in Haskell
This code will print an arrow of asterisks, like:
*
**
***
****
***
**
*
...
0
votes
0answers
19 views
Audio in python script [on hold]
I want to do a simple text game with a music background in it.
I tried different methods to do it, and most of all i liked to use Snack Sound Toolkit. Here's my code:
...
-3
votes
1answer
54 views
Array to function to int arithmetic
I want to get the value of an integer from within a struct pointer. Simply: int cool = *(*(&(coolPtr->map)) + x); can this be simplified? The rest of the ...
15
votes
4answers
2k views
My first calculator
I've just wrote my first code, which is basically a calculator. Please rate it and suggest improvements (keeping in mind that I'm a beginner).
...
6
votes
2answers
167 views
jQuery plugin to cycle through text and “typewrite” it out
I have written a jQuery plugin (my first for a long time) that simply cycles through strings of text in a data attribute and uses setInterval to type it out - it's ...
2
votes
1answer
42 views
Basic CRUD application for Product, Category & Location with SQLite
I improved the code from my previous question.
At this moment, the 3 entities have not yet a connection with each other. They should only be available for CRUD actions in a SQLite database.
I would ...
2
votes
0answers
60 views
A simple graph walk interception algorithm in Java
I have that girl whose graph walk I want to intercept, but because I am not good at running algorithms in my head, I had to program my computer to do that for me. I would not consider the problem to ...
5
votes
1answer
71 views
Non-blocking, non-threaded HTTP client implementation
This is a C# WinForms program targeting .Net 4.5. I am using it for a movie organizer application that will contact sites like OMDB, MyApiFilms, etc. for data about the movies. At the main application ...
14
votes
1answer
272 views
Simple game of Hangman in Python
I'm starting out with learning how to program in Python and created a Hangman game. I think there is a lot of unnecessary code but I am not sure how to improve it. I wanted to avoid using global ...
1
vote
1answer
24 views
Directory watcher and notifier for files added or removed
I have written a piece of code that notifies if something is added or removed from a folder location:
...
5
votes
4answers
107 views
Utility functions for a linked list
I have written code to add a node to the head of the list. Criticisms and feedback are welcome.
...
3
votes
1answer
33 views
2048 Pythonic Merge Function
This post goes over how I updated my 2048 merge function code from spaghetti code to being somewhat more readable.
Spaghetti Old Code
I incorporated a few techniques from pretty much all of your ...
1
vote
0answers
19 views
Simple event emitter
I have written a simple event emitter in Python, which allows subscribing to events and emitting events (along with monitoring events too). I'm rather new to Python, and would like some feedback on ...
3
votes
0answers
20 views
Android XML parser to parse themes
I used XML to control the theme of an InputMethod for Android. A theme in XML contains the color and the shape of keys.
XML file
...
3
votes
1answer
45 views
Login Authentication & Sign Up
This is a Login Authentication / Sign-up Models for my class project in PHP. I would really appreciate criticisms and any suggestions to improve security, code quality, etc.
Hashing.php
...
1
vote
2answers
117 views
Hacker Rank - Poisonous Plants
I have the solution for the problem, but it is taking me 7 seconds to run on a large dataset. I am trying figure out a better way of doing this. It has to run in under 3 seconds.
Problem Statement:
...
0
votes
4answers
59 views
Evaluating a tic-tac-toe board using a C-style for loop in Rust
I program in C, and it's my favourite language. I've recently found Rust. I like their ideas. Sometimes looks like a weird mixture of C++ and Haskell, but overall it looks nice.
The ...
4
votes
1answer
33 views
Task Reminder - Repeatedly notify every 6 hours
So I'm very much a beginner to Java and Android programming. I've worked a lot more with Python so I might have some quirks from there bleeding into my code here. I'd like a particular focus on ...
1
vote
2answers
69 views
Reduce jQuery append method
Is this the simplest way to write this? This code evaluates if a textbox value exceeds 20 characters, and then displays the proper message (essentially truncating the string and then adding an ...
1
vote
1answer
19 views
Aggregate sum by month
I have JSON data:
var data = [ { dat: 'timestamp', val: 10 }, { dat: 'timestamp', val: 20}, (...)]
Data contains objects with timestamp and value, can be more ...
6
votes
2answers
71 views
Using BubbleSort to sort numbers into ascending & descending order
I have created a simple implementation of the bubble sort algorithm. I have tried to make it as efficient as possible by following pseudocode which I have provided below, making some slight ...