I might as well in any interview question in the future take a more interesting approach by default to weed out the companies that simply want to hire a coding monkey that cannot talk.
But FizzBuzz is a perfect example of returning a Stream<String>
And well adding min and max arguments is also a very logical step
But I would stop there, I wouldn't abstract it more away or you'll get some heavyweight solution
To me the solution I presented is as easy as the regular loop and possibly written even faster, I did a mess up on fizzBuzzify though, I should just have used the three dumb switch statements
Oh @SimonAndréForsberg about the Java/Tesseract tool, I'm in the process currently of writing up a draft email to my boss to let him decide if I can use the code as my own or not
@bazola To find every where a method is called, right click on the method and choose "Open in assistant editor". At the top of the assistant editor where the file structure is shown, hover over "Callers". i.stack.imgur.com/FV9AF.png — nhgrifyesterday
Wow, that took longer than expected (though right around the 6-8 week mark), but we finally have a semi-working prototype of the new profile page.
Recap
There’s a longer explanation on part 1 but the gist of it is this: we’re splitting the profile into two pages:
An “About Me” page which is w...
My iterative solution to the problem.
My logic follows Method 2 mentioned in the solution to that problem. Suggestions welcome.
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node* next;
};
void printList (struct node* head)
{
struct node* current;
for (...
I just want a function that return (self.numerator, self.denominator)
As a convenience function
Because if somewhere off in the future I have a function that takes an (Int,Int) tuple as the argument, passing the result of that function is a little cleaner than building the tuple on the fly.
And does it hurt for the function to exist and not be used?
I was thinking about doing a FizzBuzz in which one functions sets a bitmask, the other function takes in a bit mask and prints the correct value based on the bitmask.
Which.... sets those properties and triggers the `didSet`.... Which.... sets those properties and triggers the `didSet`.... Which.... sets those properties and triggers the `didSet`.... Which.... sets those properties and triggers the `didSet`.... Which.... sets those properties and triggers the `didSet`.... Which.... sets those properties and triggers the `didSet`....
I have created a tool that lets me calculate the profitability of doing certain actions in an MMORPG game which I play, it's more edging towards a quick-and-dirty solution than towards a neat solution because it's simply a tool and does not need excessive robustness, however I do think there is r...
@nhgrif Or is there a way to change the value that actually gets set? didSet is called after the actual set I suppose, so is there anything for before the actual set?
I made a small example to show you that all your worries are in the past. Before you implement this yourself though, keep Mat's remarks in mind: I made this as a quick sketch and separating the mappings from the context, naming conventions, etc are important for your code's clarity.
That being ...
I've put the edit link as the alt text of the image, too. we do have blind users.
@JeroenVannevel could TournamentMatch be superfluous?
In that case TournamentMatch class should be deleted and replaced by composition 1:N Tournament - TournamentMatchResult. The names of classes are misleading which should be corrected. — VDohnal1 min ago
Followup to this
Here's my current code for this cube root approximation:
public static final BigInteger _3=BigInteger.valueOf(3);
public static BigInteger cbrt(BigInteger n)
{
BigInteger temp=BigInteger.ZERO.setBit(n.bitLength()/3+1),
root;
do {
root=temp;
temp=root.add(root...
Ever need some music made let me know. Also, everything in the Psych-Nein section you can download free. You should listen to Dark Matter there it's awesome.
I've updated my text-based terrain generator a lot. Even though I haven't worked on it all that much. I really just want to know, like usual, is there anything I can improve? How can I shorten the code? What can be made more efficient? Yada yada yada...
#!/usr/bin/env python
from random import ...
C (Intel Core Duo + OS X/Darwin), 248 bytes
#include <unistd.h>
#include <mach/mach_time.h>
#define M mach_absolute_time()
main(){char*s="JJJIHGFGHIJJJ@BDFHJJJHFDB@JJJJ@JJJJBBBBBBB";uint64_t i,t,y=1;for(;*s;s++){
for(i=40;i;i--){for(t=M+(*s&15)*9090909;t>M;)y*=7;usleep((11-(*s&15))*9091);}}}
T...
Since today is apparently a good day for...unlikely FizzBuzz implementations, I decided to contribute another, this one in C++:
#include <iostream>
#include <functional>
#include <vector>
#include "xrange.h"
int main() {
std::vector<std::function<void(int)> > funcs {
[](int i) { std...
I've just started programming and read a book called Head First Java.
I thought it would be fun to make a training project that i can put all the stuff i learn into. So the question is if the code i've written in here is just really bad or good code written for a beginner.
I've got 4 classes
M...
Since today is apparently a good day for...unlikely FizzBuzz implementations, I decided to contribute another, this one in C++:
#include <iostream>
#include <functional>
#include <vector>
#include "xrange.h"
int main() {
std::vector<std::function<void(int)> > funcs {
[](int i) { std...
> Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"
If you are only worried about showing Min and Max, and nothing else is the desired result then why not use an immediate calculation approach like this? It surely does not store unnecessary inputs -
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(s...
First, the struct itself:
struct Fraction {
var numerator: Int {
get {
return self.numerator
}
set (newNumerator) {
self.numerator = newNumerator
}
}
var denominator: Int {
get {
return self.denominator
}
set (newDenominator) {
...
Fizz buzz (also known as bizz buzz, or simply buzz) is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz".
Play
Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by three is replaced by the word fizz and any divisible by five by the word buzz. Numbers divisible by both become fizz buzz. A player who...
First, the struct itself:
struct Fraction {
var numerator: Int {
get {
return self.numerator
}
set (newNumerator) {
self.numerator = newNumerator
}
}
var denominator: Int {
get {
return self.denominator
}
set (newDenominator) {
...
I have no idea why the second variant produces no error.
The behaviour that you want is a feature. For you to use any feature, the feature must be thought of, considered to be a good idea, designed, specified, implemented, tested, documented and shipped to users.
For Java, one or more of th...
> For C#, all of those things did happen -- about fourteen years ago now -- and so the corresponding program in C# has produced an error since C# 1.0.
and lol:
Stupidest tech-hipster answer I've read on this site so far. Not only does this answer not actually answer the OP, but it just stands to insult a programming language. This is not constructive nor helpful. The worse part is that some people actually upvoted this garbage. — CyberneticTwerkGuruOrcyesterday
Please suggest improvements to this game to make it more idiomatic python. Also how should I refactor to make line 183 (restart game instance if you die) actually work?
import random
import time
class Hero:
def __init__(self):
self.level = 1
self.max_hp = 3
self.hp =...
MS SQL Server, no loops. ;)
WITH Numbers AS (
SELECT 1 as Number
UNION ALL
SELECT Number+1 FROM Numbers WHERE Number < 100
)
SELECT CASE
WHEN Number % 15 = 0 THEN 'FizzBuzz'
WHEN Number % 5 = 0 THEN 'Buzz'
WHEN Number % 3 = 0 THEN 'Fizz'
ELSE CAST(Number as varchar)
...
In mathematics, the remainder is the amount "left over" after performing some computation. In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division). In algebra, the remainder is the polynomial "left over" after dividing one polynomial by another. The modulo operation is the operation that produces such a remainder when given a dividend and divisor.
Formally it is also true that a remainder is what is left after subtracting one number from another, although this is more properly called the difference. T...
in this simple program for write minimum of 2 numers :
cin>>a,b;
min=a;
if (b<min){
min=b;
}
cout<<min;
create XML for this program:
<start>
<InOut>
<in> a </in>
<in> b </in>
<out> min </out>
</InOut>
<calc>
<ins> a=3 </ins>
<ins> b=5 </ins>
...
i have flowchart for detect minimum in 2 number i write c++ code replace flowchart image i edit this code and replace flowchart with c++ code @Jamal — MinA57 secs ago