« first day (1435 days earlier)      last day (3506 days later) » 
00:00 - 16:0016:00 - 00:00

12:00 AM
I think recursion is often abused for things that don't work well recursively.
 
Lets look at it from an Discrete Mathematics point of view. You have several rules. The first number is 1. Each number of the fibonacci series will be represented by F(n) where n is the number in the series. Given the first number is 1, that means we start with
F(1) = 1
the second rule is that the second number is also 1
F(2) = 1
The last rule you need to know is that to get any Fibonacci number F(n), all you do is take the previous Fibonacci number F(n-1) and add it to the previous number to that F(n-2).
Now, notice how the replacement happens. That is the recursive self definition. So now lets look at a further example of F(6).
F(6) = F(5) + F(4)
However, we don't know 4 or 5 yet. So we substitute down (recurse).
F(6) = replace F(5) + replace F(4)
F(5) = F(4) + F(3)
F(4) = F(3) + (F2)
and we already know F(3) and F(2) to be 2 and 1 respectively. So now we can go back out from there
F(4) = 2 + 1 = 3
F(5) = 3 + 2 = 5
F(6) = F(5) + F(4) = 5 + 3 = 8
 
F(U)
I just had to.
 
O(MG)
 
hahaha
O(MG) == evaluated at compile time.
 
That doesn't mean it has to compile :P
 
12:12 AM
Not all of that is true anymore
but still, it's amusing :P
 
@OMGtechy That's only true in languages that don't support recursion well :p
 
I'm on about within C++
I am a C++ nerd.
Looking to expand my horizons.
Got Mr Skeet's book today in the post :D
So my fairly limited C# should be massively expanded
 
@OMGtechy Learn F# then :p at least you'll have to learn something conceptually very different
 
I would love to, but my head would fall off
Same goes for Haskell
 
F#'s much more approachable than Haskell, IMO
 
12:15 AM
I shall learn them, but only once I've got my head around a few languages like C# C++, and Python is the other I'm interested in
 
Off-topic for the room, but I'm somewhat interested in learning C++ before the end of my degree. I hear that C++ has a lot of bad books, are there any good places for me to begin?
 
since it's not "pure" - you can still do OO, and imperative/etc
it's just not default
 
@ReedCopsey thing is, because you CAN do non functional things in it I'll get too tempted
@user1112560
4278
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a well-written...

 
@OMGtechy Yeah, but then you find it's easier to do them functionally, and the rabbit hole begins... and next thing you know, you don't like other stuff ;)
 
Ugh... thank you, should have just googled.
 
12:16 AM
@ReedCopsey I've used functional STYLE in C++ before, when I was doing some multithreading
 
frankly I think getting better at C++ template metaprogramming will help too, since it's functional
 
that's Stroustrup's new book - and supposed to be pretty good
 
He does another too
Depends on your level of programming ability really
 
My level of coding is cat smoking cigarette
 
12:17 AM
I do one to one lessons, if you're interested #shamelessselfadvertisement
 
lol bro
I do landscaping for a living
You think I have money?
I ate crackers for dinner.
 
@user1112560 be careful you don't get the old ones
 
@OMGtechy you'll find it's just so different when you use a language really designed for it
 
@ReedCopsey yeah, I do want to at some point
 
there's no better time than now :)
 
12:19 AM
@Tokencodingnewbie $5 == 1 hour
@ReedCopsey there is when I'm trying to learn C# well and Python a little atm :P
I can only do so much
It's next on the list though
 
@OMGtechy Thanks, I know to be careful, I've seen a lot of PHP tutorials on the web ;)
 
@OMGtechy yeah, but don't bother with C# :p
or at least not past very beginning C#
 
@ReedCopsey throws exception
 
I shouldn't learn c#?!
What is this madness.
 
you'll learn better habits and become a more well rounded programmer
since it'll be a fundamentally different approach
@Tokencodingnewbie C# is fine - I'm saying more "if you already know C++, and are trying to expand your horizons, there are better options out there..."
 
12:21 AM
Oh ok.
 
though, I don't love C# as intro to programming anymore, too many things are just fundamentally screwed up in C# - as Luca Bolognese once said...
x = x + 1; --- There are so many things wrong with that, it's scary
and that's where we start people learning programming :S
 
@ReedCopsey it's more that my work is in C# at the moment
and my other work may be in Python
and my other other work may be in Java...shudder
 
if you're working in C# - you'll already pick it up pretty quickly, then ;)
 
Yeah, but there's making a program in C#, and there's knowing C# well and doing things the C# way. Coming from C++, there's a danger that I'll copy the style over, hence my investment in Jon Skeet.
 
Whenever I work with Java, I just pretend I'm working with C# from 7 years in the past.
9
 
12:25 AM
@user1112560 That's funny. Now, I'm: Whenever I work with C#, I just pretend I'm working with F# from 7 years past. :p
since async workflows went into F# in 2007 :D timing is perfect
 
Daamn... :D
 
hehehehe
 
Hahaha
Sadly, I have nothing to add of a humorous nature.
 
Tried to pick up the F# tutorial whilst waiting at an airport a year or two ago... Had security come over because Visual Studio's dark theme is scary looking :/
 
Me either.
 
12:27 AM
Do need to pick it up again, especially after learning Haskell with my degree this year.
 
yeah - well, there are very good reasons to ignore it: fsharpforfunandprofit.com/posts/…
 
I think functional programming is a good thing to know, even if you never use it.
 
yeah - learning it will change how you write other code
 
Exactly.
 
learning F# makes C# developers much better C# developers
anyways, I'm out of here - have a nice weekend all
 
12:30 AM
Template metaprogramming makes me a much better C++ dev too xD
 
That article's really too smarmy for me to read, feels like it's meant as light entertainment and for preaching to the choir.
 
adios
 
Enjoy, have fun :)
 
@user1112560 it's just all satire
 
Programming challenge that's nice and easy if you're interested.
 
12:31 AM
Definitely is, just doesn't seem like it'd convince anyone :P
@OMGtechy Shoot away
 
Ok, so simplest version first: write a program that reverses a string in a language of your choice.
OTHER than python or perl
 
Unicode or ascii?
 
or any other language that lets you do it in one line like a dick
Assume it's stored in a char
and you don't need to worry about that
@Tokencodingnewbie join in :D
 
I have no opinion on the topic lul
I'm rewriting this fibonacci thing to an array right now.
and listening to old punk albums
 
god dammit
 
12:35 AM
Sorry to disappoint, maybe when I know stuff I can chime in.
 
You can chime in on this one!
It's a very simple one that is awesome in many ways.
 
hrm
What is the question haha
 
write a function that reverses a string
without calling .Reverse or any shite like that
 
I don't know D:
Get each letter and reverse it?
 
Have a go
try
This is a problem solving exercise
And a common one to be asked at that
 
12:39 AM
Wow, i didn't know this even existed. A chat room for the worlds C# programmers, /highfive
 
@James welcome :D
I hang around in C++ lounge, here (recently) and GDSE
 
Should I just C/P the code into the box?
 
post a link
so as not to spoil it for others
 
do it, i wanna see if the chat room does C# syntax highlighting automatically.
or not, '-)
 
12:41 AM
Well I'm doing the kfrey suggested exercise
 
Not really going ham on code tonight, so tired, damn work.
 
@James it doesn't
 
Actually... scratch the "".Join, Concat should work.
 
@user1112560
5 mins ago, by OMGtechy
without calling .Reverse or any shite like that
 
12:42 AM
Wait... no
 
that would be epic though wouldnt it. could do .net assembly intellisence in the chat box. lol.
 
but... I <3 reverse
 
Yes, but you're not solving the problem
 
whats this exercise?
 
If I had that available, I wouldn't use your function. I would just use .Reverse
@James I am testing folks
Reverse a string
 
12:43 AM
hm ok
 
Do not use .Reverse or anything else that hides the implementation
you can do it in any language
But if you're doing it in python, don't use the [:] think for example, as that's like calling reverse
 
using stringbuilder is allowed?
 
I've found that if you ask a C++ dev this, they do it in seconds, but if you ask a Java developer...no idea
@James does it hide anything away?
C# devs are apparently reacting the same way as Java devs so far
 
it just allows you to index into characters
 
Oh that's fine
as in myString[0]?
 
12:47 AM
if you were really going to do this in C#, you would definitely use stringbuilder, otherwise you are allocating a bunch of intermediate string garbage
 
I have a feeling there's more to the puzzle.
 
@James that loos ok (I haven't run it).
@user1112560 there is ;)
I shall reveal it soon
 
i haven't run it either '-) wrote it in pastebin
 
the logic is there anyway
Ok so both look fine
 
There's the XOR method, of course.
 
12:51 AM
Do not reveal anything
the challenge is going to be altered now
 
I don't know what I'm not meant to be revealing.
 
Any method that might hint to other people
So, slight change
You must reverse the string in-place. This means you must modify the string passed in without making another string.
Understand the problem?
 
Unsure - the underlying buffer is private. Would calling .ToCharArray(), then performing in-place modifications on that be allowed?
 
Assume the string is mutable
and you can access elements by index
The language isn't really the target here, it's the logic
so assume you can do inputString[0] = 'h'; and things like that
 
12:59 AM
Mutable strings? Is this guitar? lol
 
@James that still creates a new string
 
oops hadn't submitted the changes. try now pastebin.com/iT3FvyRZ
 
@James that still still creates a new string (you're copying it) :P
 
nope
 
ah sorry
misread
that's what I was looking for, yes
 
1:01 AM
I realise it's probably out-of-scope, but that's a really tough question if you take into account graphemes.
Not /really/ hard, but definitely interesting
 
The logic I was looking for is there anyway
 
lol graphemes? do you mean like reversing the phoenetic syllables?
 
It's not hard at all, but it's just interesting when you take tools away from people when they're used to having them
 
i had to write a really complex terrain system in C#... there was a lot of generating cells, splitting cells, culling triangles into cells, clipping triangles to cells...
thats the sortof thing where you just have to work the algorithm out
 
@user1112560 you got an answer? :)
 
1:04 AM
because theres not like a .. magical linq method that will do any of that for you '-)
 
People get too used to having a method that does it for you magically
Sure they're great,but you should be able to do things like reverse a string efficiently and make a linked list etc
 
Typical interview question, keep the basics memorised now.
/technically/ incorrect for C#, but it's efficient.
 
@user1112560 that isn't in place
@James neither was yours, but the logic was xD
 
well i did need to use a temp character
but a char != a string, right?
 
yes but that's fine
that is the best solution I know of
I can't really imagine another
 
1:08 AM
well
don't some CPUs have atomic swap address operations?
 
Mind explaining why it isn't in-place logically?
Implementation-wise, I'm not messing with the string buffer, admittedly.
 
@user1112560 I just saw new string, I didn't actualy read the rest, sorry :P
 
yea its the same as mine
 
god damn C# getting in the way of the problem
oh awesome
 
1:09 AM
we arent actually able to index into strings
 
Which is stupid IMO
 
so the allocate you see is really just turning it into a string which is indexable
 
I did say assume you can index the string :P
 
yea, but i already had it written '-)
 
12 mins ago, by OMGtechy
so assume you can do inputString[0] = 'h'; and things like that
Ok another problem that won't have C# in the way this time
simple and hard at the same time
I don't think I've asked it before here
 
1:11 AM
public static  void Fibonacci()
        {
            numbers[0] = 0;
            numbers[1] = 1;
            numbers[2] = 1;


            Console.WriteLine(numbers[0].ToString());
            Console.WriteLine(numbers[1].ToString());

            numbers[3] = numbers[2] + numbers[1];

            for (int i = 2; i < 99; i++)
            {
                Console.WriteLine(numbers[i]);

                numbers[i+1] = numbers[i - 1] + numbers[i - 2];
            }
            Console.ReadLine();
Is what I'm trying to do in the for loop not allowed?
 
That's not recursion, but as previously mentioned recursion isn't the best way to solve it either ha
 
Still, looks alright to me
 
I'm on the right track though?
It doesn't work lul
 
so long as the requirement isnt that it has to be arbitrary length
because you need to preallocate an array of that size
 
1:13 AM
I did
 
meh, forget that
 
static int[] numbers = new int[100];
 
anyway, you've got the right idea for solving the problem properly. If you're trying to learn about recursion though, no.
 
@OMGtechy ping me when the next puzzle comes up, gotta continue trying to understand what this code is doing.
 
How does one recursion
 
1:15 AM
assume that numberN-1 and numberN-2 are arguments to a method '-)
 
I thought just looping it was the idea?
 
@Tokencodingnewbie quite the opposite
int doSomething(int a, int b)
{
    if(a == foo) return a * b;
    else doSomething(b--, a--);
}
 
recursion means a method calls itself
 
totally random example
not saying it does anything useful, but it's recursion
 
The heck is the point of that.
 
1:17 AM
38 secs ago, by OMGtechy
not saying it does anything useful, but it's recursion
 
its just a different way of looping
 
NOO
don't tell him the damn answer! :P
 
Factorial... not fib?
 
still xD
 
Tell who the answer?
 
1:18 AM
You haha
 
I had no clue what he posted
haha
 
I think palindromes are a better example, although I still solve that by looping IRL
 
Still need to at least find an example to show the concepts of the base case and the reduction of the parameter?
 
I suppose so yeah
Maybe a range summer would be a good example without giving too much away
 
I guess this recursion thing is leading to this minimax algorithm
Need to learn one thing before attempting something else.
Might just go to gaming, don't want to get too burned out :P
 
1:23 AM
Minimax is an application of recursion, so yep.
 
I have off this weekend, that I know of.
I have a date tomorrow, and math lab, then I'm pretty open.
 
here's an example of recursion
I have no idea what minimax is
 
@OMGtechy What is the purpose of that?
 
it sums all numbers between min and max
so instead of 0 + 1 + 2 + 3 + 4, you type rangeSum(0, 4)
 
I guess I mean it in a deeper sense?
 
1:30 AM
ideone.com/bRipb2 - same code, split up differently.
 
@Tokencodingnewbie what do you mean?
 
Like how could it be used for something practical?
I dunno haha
 
Recursion has the base case (min == max), and the recursive case (the code afterwards).
 
That IS practical
 
Minimax uses recursion, as does tree traversal.
 
1:31 AM
instead of typing 0 + 1 + 2 + ... N
 
Anyone ever hear of Nancy Framework?
 
you type rangeSum(0, N)
did Nancy make it?
 
Nope
 
Damn
 
@OMGtechy Amusing, no... It is for Owin / Katana
 
2:30 AM
ugh I said I was going to play video games and here I am still
Reading about recursion.
 
Don't worry, soon you'll find yourself enjoying it enough that you completely lose track of time.
 
Well I'm enjoying it enough to not play my game :P
but I should go to bed
 
2:55 AM
@Tokencodingnewbie never!
 
 
2 hours later…
4:53 AM
Guys anybody knows that how to load Word Document with new Instance of Word Application using Process.Start() method?
I have found a link support.microsoft.com/kb/210565 where i can find all command line arguments. I found /n to load word document in new instance but, i think i doing it incorrectly.
 
 
4 hours later…
8:31 AM
Hi
 
@Greg heard of it, never used it
 
8:48 AM
I understand very little of that
 
I think you got the right guy the first time
 
I can usually understand some dutch, dunno why
 
9:01 AM
Wow that is cool I just got access to my 7 year old hotmail and twitter account, huh.
 
 
1 hour later…
10:05 AM
i have access to my hotmail accout from like... idk, when i was in 7th or 8th grade maybe...it has 19,829 unread email messages :)
most of which is porn and penis enlargement spam
 
 
5 hours later…
3:20 PM
Ok so I made a program with recursion.
 
3:33 PM
@Tokencodingnewbie awesome!
 
Still confused on how I could use it to determine every available spot on a tic tac toe board.
 
You could use it to determine the AI's next move. Personally, I prefer to loop it, but you could.
 
Do I go through the array and determine which spots are open?
 
Could do yes.
foreach(var element in container) { ... }
@Tokencodingnewbie want a guide?
 
A guide? >.>
 
3:40 PM
To solving whatever problem you're having
I won't solve it for you, I'll just continuously nudge you in the right direction
 
Oh I don't want it solved for me, I like nudging.
I tried that test thing you were talking about
 private void Button_Click(object sender, RoutedEventArgs e)
        {

            Dictionary<int, Button> determineButton = new Dictionary<int, Button>{{0, Button1}, {1, Button2}, {2, Button3}, { 3, Button4}, {4, Button5}, {5, Button6},
                {6, Button7}, {7, Button8}, {8, Button9}};

            for (int i = 0; i < 9; i++)
            {
                if (isX[i] == 1 || isX[i] == 2)
                {
                    MessageBox.Show(determineButton[i].Content + " is taken");
                }
It semi works.
 
Semi?
Does it just go "naaa" every now and then? xD
 
It's not printing the button it just says "X is open"
 
Have you stepped through it with a debugger?
 
I'm pretty sure this is why
MessageBox.Show(determineButton[i].Content + " is taken");
I want to print the key value
 
3:50 PM
But have you stepped through it with a debugger?
Or set a breakpoint?
 
Yeah
The code works, it's just the output
ok I got it.
private void Button_Click(object sender, RoutedEventArgs e)
        {

            Dictionary<int, Button> determineButton = new Dictionary<int, Button>{{0, Button1}, {1, Button2}, {2, Button3}, { 3, Button4}, {4, Button5}, {5, Button6},
                {6, Button7}, {7, Button8}, {8, Button9}};


            for (int i = 0; i < 9; i++)
            {
                Button myButton = determineButton[i];
                if (isX[i] == 1 || isX[i] == 2)
                {
                    MessageBox.Show(myButton.Name + " is taken");
It works, joy. but how can I use this data in a useful manner? So the computer can be like "Hrm I should put an O in here"
 
Well, look at it like a human would first
How do you work it out?
 
I'd look for spots to either block my opponent or win.
 
Ok, now how do you know what blocks and what is a win?
And how do you know WHEN you need to block?
 
I know if my opponent needs one more "O" they will win, so I have to block it.
 
3:59 PM
if(shouldblockOpponent()) { blockOpponent(); }
else { getCloserToWinning(); }
 
I know if I place one more "X" next to two of them I will win.
 
Personally, I like to think at things at a very high level (like above) and then implement each function
 
00:00 - 16:0016:00 - 00:00

« first day (1435 days earlier)      last day (3506 days later) »