I got my navigation bar to be the color I want of Blue background with white text.
Here is my code which works but this feels totally hacky. Please suggest improvements
styles.xml
<resources>
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:ac...
I am trying to write a program which, given a number as an input, prints the prime factors AND the exponents of the prime factors of that number.
Example:
input
20
output
2^2 5^1
And this is the code that I've come up with:
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
I have a Python script which requires lots of arguments to be passed each time.
My preference is to have all this information stored in (global) variables at the top of the script. Another option would be to have them on a file (one per line) and have the script read them from the file.
I usuall...
It's a leetcode problem called Word Ladder, which goes like :
Given two words (start and end), and a dictionary, find the length of
shortest transformation sequence from start to end, such that:Only one letter can be
changed at a time. Each intermediate word must
exist in the dictionar...
I'm supposed to create a program the creates two methods a reverse method and a palindrome method and for whatever reason it's not working. I've spent hours on it and, since my professor is out of town I can't email him to have a look at it. :( so if anyone could give me some feed back or hints t...
How can I design my own function, in Scheme, which reverses a list of numbers.
(rev (list 1 2 3 4 5)) -> (list 5 4 3 2 1)
I need to do this recursively, and in Beginner Student Language with List Abbreviations.
Thank you.
I have a data set I am looking at for fun and would like to fit the model using loglm().
The problem is, is that I don't know much about R and don't understand data frames. The data set is a 2X2X2 contingency table with gender(male,female), opinion A(support, oppose), opinion b (support,oppose)...
Long story short, I wrote this jQuery form plugin as an exercise to better understand how other form plugins work. If you have any suggestions about how to improve this (or my coding style in general) let me know.
var Form = function(options) {
options = options || {};
this.url = optio...
OK I see that @JaDogg - That one also seems a little harsh, I'm certain you mean well and I see you added to it just now to make it more gentle.
A very simple rule of thumb I use constantly, is when using the English Present Simple Form, e.g., "do this", "change this", etc., just adding a simple "I would suggest/recommend that you do this" or whatever helps make things easier to swallow, especially for brand new users.
I have a header and data which I need to represent in one Byte Array. And I have a particular format for packing the header in a Byte Array and also a different format to pack the data in a Byte Array. After I have these two, I need to make one final Byte Array out of it.
// below is my header o...
I just want to know if this approach will have any errors. I did some testing and it seems like it works.
But what are it's limitation? Anything I should improve in this?
<?php
function downloadAsTXT($cms, $token) {
foreach($cms->GetDatabaseTables() as $table) {
$tableDa...
In current C++ language, there is no class like datetimein the standard which can be used in the program. However with additional of modules like regex chrono we can write the general purpose class like datetime. Here is my current implementation for this:
#include<iostream>
#include<string>
#in...
I think this tag should be made synonym with javascript. It currently has only 6 questions, 4 of which are JavaScript. One is tagged instead cold-fusion and another .net. It has 0 followers. I'm just concerned it doesn't really serve any useful purpose.
From the ECMAScript page on Wikipedia:
...
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeLo(TimSort.java:773)
at java.util.TimSort.mergeAt(TimSort.java:510)
at java.util.TimSort.mergeCollapse(TimSort.java:437)
at java.util.TimSort.sort(TimSort.java:241)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(SortingFocusTraversalPolicy.java:136)
I am working on a parenthesis checker program in java that that reads in a text stream from standard input and uses a stack to determine whether or not its parentheses are properly balanced. For example, thisshould print true for [()]{}{()()} and false for [(]). I have made a stack class of my ow...
I just need some feedback why I am not able to display the result or why its not compiling. I trying to work with function in c++ to compute a formula.
Thanks for your time.
here is the code
#include <iostream>
#include <cmath>
using namespace std;
void beamMoment(double num1, double num2 ){...
For this lab you should re-use your Dice class from the previous week.
The user inputs a number n which determines the number of groups of 6 dice to be
rolled.
The program should output x, which is the number of times 6n dice are rolled
before they show an equal number of all values. For exam...
@Vogel612 On it. Worked on it a bit earlier. It keeps getting an error page from SO when trying to post a message. Maybe the webagent isn't set up properly.
What form of the method you find more readable?
Version with local variables:
public void checkRetrievedIds( List<Integer> expectedIds, List<Integer> retrievedIds ) {
Set<Integer> expected = new HashSet<>( expectedIds );
Set<Integer> retrieved = new HashSet<>( retrievedIds );
Set<...
This is called from a VF page,
styleClass="{!IF(isWindows8Device, 'windows', 'not_windows')}"
So if it's a windows device, return true.
The best thing to do would be to add one method in DeviceDetectionCls to check for any windows device, instead of two methods.
For the purpose of this que...
Assuming interstellar travel, and self sufficient colonies in other star systems, what are some methods of destroying the Earth while leaving minimal impact on the colonies?
Context
I would like to keep Earth based culture and languages intact, without having to deal with "modern" (modern being...
Problem Statement:
Design a STUDENT class to store roll, name, course, admission date and
marks in 5 subjects taken from user. Create an array of STUDENT
objects. Provide methods corresponding to admission date and receiving
marks, preparing mark sheet. Support must be there to show t...
I have just been informed that the following code written by me is extremely poor. I have absolutely no idea why. It is memory efficient, and looks clean to me. But still the feedback is very poor. I have no clue on why. If someone can put some comments, I will be highly grateful. I have to pass ...
Based on chrisco's suggestion to debug the selected view (which I had already done, but went to try again for good measure), I noticed a couple of other options at the bottom of the Editor menu.
Automatically Refresh Views
Refresh All Views
I clicked "Refresh All Views" and after Xcode had a ...
This coding style is confusing.
Let's unravel the line of code in question:
self.currentDog >>> getWalks >>> getWalkAtIndex >>> setUpCell
What's happening here? To make sense of this, we essentially have to read this backwards.
What are we doing? We're setting up a cell.
With what informa...
I have the following LINQ statement:
from alpha in alphas
let beta = betas.SingleOrDefault(b => b.A == alpha.A)
select beta ?? betas;
which with the inputs
var alpha = new[]
{
new { A = 1, B = "A" },
new { A = 2, B = "B" },
new { A = 3, B = "C" },
};
var beta = new[] { new { A = ...
Hey Currently I am developing a chess game but have gone to the mistake of putting all my java code in one java file
I need help cutting up my code into more manageable chucks
I was hoping someone could show me how to take out all the piece movements and put them in a separate file which then l...
stackexchange.com is behaving very strangely today on two of our webservers. Luckily we have nine of them available, so until we've found and fixed the underlying issue I've taken those two servers out of the load balancer, letting the remaining (apparently not drunk) web servers handle the traff...
In Code Review after receiving some suggestions should I edit my posted code according to the suggestions, so I get more and more improved suggestions... Or should I leave the post as it is?
Well it seems like I got here 3 repetitive sections, how to optimize them? THe changes are only in sql query and in foreach parts.
<?php
$action = mysql_real_escape_string($_POST["action"]);
$optional = array(
"reportdate_from" => isset($_POST['reportdate_from']) ? mysql_real_escape_string...
I have been doing this test task for C# Dev role at UBS.London recently and have been rejected. No reason stated yet. Was wondering if you can take a look and provide feedback on what I can do to improve solution. The task description is below and solution itself is on GitHub. Also attached code ...
Is there something as "they have too little in common to use a superclass"?
In my case, doing iOS programming, in a project, every screen has the same background. So I created a superclass which only has:
.h
@property (nonatomic) IBOutlet UIImageView *backgroundImageView;
.m
- (void)viewDid...
In the courts, all that mechanically changes is that dead people become witnesses.
However...
I feel that they might not make for reliable witnesses.
(SPOILERS: Phoenix Wright: Ace Attorney)
In Phoenix Wright, Ace Attorney, the DL-6 case is a case in which a spirit medium is used to communic...
I can't remember if it was @Malachi or @Mat'sMug who wanted more info on async/await in C#, but I found this link on SO that is pure gold. It helped me understand it pretty well
I may be missing something but what is the difference between doing:
public void MyMethod()
{
Task t = new Task.Factory.StartNew(DoSomethingThatTakesTime);
t.Wait();
UpdateLabelToSayItsComplete();
}
public async void MyMethod()
{
var result = Task.Factory.StartNew(DoSomethingThatTakesTi...
Also for more info on that, see this guy here: stephencleary.com He speaks at a conference that I frequent and is both very knowledgeable and practical in this area. If you're interested in hearing him speak: codemash.org/accepted-session-list he's got two talks on Async this year.
I have moved ToLower() method to word.ToLower() from sentence.ToLower() because I couldn't come up with correct unit test to test call to ToLower() at that time. Basically I discovered that all my unit tests are passing if I just remove call sentence.ToLower(). So to make this call ToLower() testable I moved it to current position. I could be wrong here. — gemasp3 mins ago
No specific question here. I am beginning with java and here is an exercise. The rules of game:
You roll two dice. Each die has six faces, which contain one, two,
three, four, five and six spots, respectively. After the dice have
come to rest, the sum of the spots on the two upward faces ...
your naming makes me stop and think much harder than I should...
foreach (var chr in sentence)
are you iterating over each character, in the sentence? looking at this I think logically I would iterate through the words of the sentence and then the characters of the words... so this confuses ...
> your naming makes me stop and think much harder than I should...
`foreach (var chr in sentence)` are you iterating over each character, in the sentence? looking at this I think logically I would iterate through the words of the sentence and then the characters of the words... so this confuses me a little.
After addressing all issues in the previous post I've re-factored the
code. I'm looking for a code review on the code below.
/***************************************************************************************************
Arc
Arc occupies one user defined global variable. The library is...
As your review is now, you're making the statement that iterating over sentence character by character is wrong, and that one should iterate over the words instead.
I don't have a problem with your advice, I have a problem with it being incomplete
actually..
> use String.Split and create a string array, maybe create a dictionary of the distinct words from the first array, then loop through the first loop and increment an integer value the corresponds to that word in the dictionary.
good advice
+
> When you are done looping then print out your Dictionary.
makes an alternative solution
is good, I guess
> Looks like this is what you were doing, but then you loop through the Sentence character by character and that doesn't make sense; you have characters, then you have words, then you have sentences, then you have Paragraphs, then you pages, then chapters, then it can go to acts or sections and then books. you skipped from characters to Sentences... Why?
You're drifting off the assignment
The assignment was "count the times I use each word in a sentence", not in a book.
> I imagine that you were worried about contractions, that should be a word-level function/method to tell other word objects being compared to it that there are actually 2 words inside that object.