Open Side Menu Go to the Top

09-27-2014 , 02:12 PM
The reason I ask is because a review post I wrote in this forum a few days ago has completely vanished off google. It was on the first page when specifying the within the past week time frame but now is gone. No trace.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
09-27-2014 , 04:00 PM
Quote:
Originally Posted by Anais
Also, I apparently got docked a point on an assignment for using concatenation before we learned about it. Saved me 18 key strokes, but at what cost?
i would say based on this alone odds are good that both professor and class are close to worthless.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 04:03 PM
Quote:
Originally Posted by blackize5
The universe implodes.

If a is less than b and b is less than c, a cannot be greater than c
int A = -50;
int B = 20;
unsigned int C = 30;

A < B is true

B < C is true

(unsigned int)A > C is true
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 05:31 PM
Quote:
Originally Posted by gaming_mouse
i would say based on this alone odds are good that both professor and class are close to worthless.
Our professor doesn't really teach so much as show us one thing at the start of class and then help us with homework. Which is honestly how school should be imo. Another of my teachers does nothing but read nearly verbatim from the book for class. Should be the job of the students to read the book!

The school I'm at had a pretty good in for a local code farm tho, so I'm pretty much finishing here just to get employed ASAP and get some experience.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 05:38 PM
Quote:
Originally Posted by Anais
Also, I apparently got docked a point on an assignment for using concatenation before we learned about it. Saved me 18 key strokes, but at what cost?
1 point...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 05:40 PM
Quote:
Originally Posted by adios
int A = -50;
int B = 20;
unsigned int C = 30;

A < B is true

B < C is true

(unsigned int)A > C is true
Redefining wrong isn't going to work in his class...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 05:40 PM
That one point accounted for 10% of the grade!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 09:17 PM
Code:
def count_change (amt, denoms):
    ways = [0] * (amt + 1)
    ways[0] = 1
    for denom in denoms:
        for j in range(denom, amt + 1):
            ways[j] += ways[j - denom]
    return ways[amt]

print(count_change(6, [1, 2, 3]))
After doing my own silly solution, I searched for better answers and found the above.

I don't understand how it can work, I added print to denom, j, and ways, searched around on combinations, and I have a slight recollection of how this can work with bit-shifting but I can't recall it exactly.

Although I see what it is doing, I don't get how it works correctly:

Code:
>>> denom 1
j 1
ways [1, 1, 0, 0, 0, 0, 0]
denom 1
j 2
ways [1, 1, 1, 0, 0, 0, 0]
denom 1
j 3
ways [1, 1, 1, 1, 0, 0, 0]
denom 1
j 4
ways [1, 1, 1, 1, 1, 0, 0]
denom 1
j 5
ways [1, 1, 1, 1, 1, 1, 0]
denom 1
j 6
ways [1, 1, 1, 1, 1, 1, 1]
denom 2
j 2
ways [1, 1, 2, 1, 1, 1, 1]
denom 2
j 3
ways [1, 1, 2, 2, 1, 1, 1]
denom 2
j 4
ways [1, 1, 2, 2, 3, 1, 1]
denom 2
j 5
ways [1, 1, 2, 2, 3, 3, 1]
denom 2
j 6
ways [1, 1, 2, 2, 3, 3, 4]
denom 3
j 3
ways [1, 1, 2, 3, 3, 3, 4]
denom 3
j 4
ways [1, 1, 2, 3, 4, 3, 4]
denom 3
j 5
ways [1, 1, 2, 3, 4, 5, 4]
denom 3
j 6
ways [1, 1, 2, 3, 4, 5, 7]
7
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 10:50 PM
Quote:
Originally Posted by daveT
Code:
def count_change (amt, denoms):
    ways = [0] * (amt + 1)
    ways[0] = 1
    for denom in denoms:
        for j in range(denom, amt + 1):
            ways[j] += ways[j - denom]
    return ways[amt]

print(count_change(6, [1, 2, 3]))
This is a classic DP problem, hopefully I can offer a decent explanation.

Ways is a list which tells you how many ways you can add up to the value of the index. The value at the index 0 is just to initialize the process. After iterating through with $1, you will have:

[1,1,1,1,1,1,1]

Let's repeat with $2. If 2 is less than or equal to the index, you add the number of ways to get to the value from the prior index (ways[j - denom]). Another way to think about it: to get to $5, you need to add the ways to get to $3.

This is the process for $2:
Code:
 0 1 2 3 4 5 6
[1,1,1,1,1,1,1]
[1,1,2,1,1,1,1]
[1,1,2,2,1,1,1]
[1,1,2,2,3,1,1]
[1,1,2,2,3,3,1]
[1,1,2,2,3,3,4]
And that's pretty much it. A more difficult variation of this problem is to print out all the possible solutions.

Much better SICP explanation referenced by gaming_mouse: http://mitpress.mit.edu/sicp/full-te...ml#%_sec_1.2.2

Last edited by rsabb24; 09-27-2014 at 11:04 PM. Reason: include better/official explanation
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 10:54 PM
dave, this is also straight out of SICP, somewhere near the beginning, possibly even the first chapter. the scheme answer they discuss is similar to the python one above.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 11:09 PM
Ah, carp.

I get it now. For some silly reason, I'm thinking about maps and missed the idea that they are using indices on an array instead of maps.

For some reason, I was thinking that they were simply adding the denomination to the nth position of the array instead of reusing the previous values.

Amazing how fast one can get rusty at this stuff.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-27-2014 , 11:20 PM
The other evening, I wrote this stuff:

Code:
def memoize(f):
    memo = {}
    def inner(x):
        if x not in memo:
            memo[x] = f(x)
        return memo[x]
    return inner

@memoize
def fib_recur(x):
    if 0 <= x <= 1:
        return x
    return fib_recur(x - 1) + fib_recur(x - 2)
Code:
def fib_iter(x):
    memo = {0: 0, 1 : 1}
    for i in range(x + 1):
        if i not in memo:
            memo[i] =  memo[i - 1] + memo[i - 2]
    return memo[x]
Is it generally more elegant to use maps or arrays for these kinds of problems? I seriously never considered it before, but I'm guessing that if you can guarantee a linear relationship among all of the items, there would be much more interesting things that can be piled on top of it, but if the results can be sporadic, then the space and time would be smaller with a map.

In the general small case, I'm guessing it really doesn't matter.

Last edited by daveT; 09-27-2014 at 11:25 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 09:46 AM
I am making a little tool that's fetching the most occurring words of a 2p2 thread.

Doing this for fun.

Here are the results for this thread since index950:

Code:
Key : work Value : 152
Key : good Value : 145
Key : time Value : 130
Key : people Value : 127
Key : code Value : 120
Key : c Value : 111
Key : use Value : 104
Key : score Value : 101
Key : make Value : 94
Key : job Value : 83
Key : going Value : 82
Key : need Value : 76
Key : python Value : 76
Key : experience Value : 71
Key : best Value : 71
Key : programming Value : 67
Key : language Value : 65
Key : better Value : 63
Key : question Value : 60
Key : stuff Value : 60
Key : things Value : 60
Key : etc Value : 54
Key : point Value : 54
Key : years Value : 54
Key : java Value : 52
Key : used Value : 52
Key : bit Value : 52
Key : find Value : 51
Key : since Value : 49
Key : working Value : 48
Key : test Value : 47
Key : start Value : 46
Key : read Value : 46
Key : write Value : 45
Key : works Value : 45
Key : learn Value : 44
Key : class Value : 44
Key : set Value : 44
Key : sort Value : 43
Key : doing Value : 43
Key : end Value : 42
Key : davet Value : 41
Key : interview Value : 41
Key : problem Value : 41
Key : understand Value : 41
Key : least Value : 40
Key : b Value : 38
Key : x Value : 38
Key : done Value : 38
Key : easy Value : 38
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 03:00 PM
bex989, I am assuming that this is from this thread? Interesting tool. How'd you do it?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 04:23 PM
Yup it's from this thread since page 950 to onward, so 30+ pages.

It's Java 8 with jsoup, made it this morning but it's an idea I had for a while.

Basically you input a 2p2 thread and I have a mechanism to make it fetch until last page.
Every post is within "div[class=postbitlinks]" so I just select all of them for every page and do some fine filtering.

I am using Radix Tree to compute the most occurring words (obv. I filter them through stop-words).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 05:21 PM
Random question. Has anyone used the module Poker-0.19.0 with Python 3.4.1 lately?

And been able to install it correctly? Its giving me somewhat of a headache

Last edited by TopPair2Pair; 09-28-2014 at 05:42 PM. Reason: potatoes?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 05:32 PM
Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato Potato

I'm in your stats potatoing your potatos
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 05:41 PM
It's funny how C is talked about more than Python which is more talked about than Java.

And stop posting my screen name, please. kthx.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:09 PM
Okay, davet.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:12 PM
What does DaveT think of potatoes though?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:18 PM
If you used the tool on an entire forum, it might be interesting to see which threads relate closest to each other by comparing lexicons. This could be useful as a feature in a forum ("you might also be interested in...")
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:21 PM
" I see you like threads about racism, you might also like the politics forum "
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:22 PM
Quote:
Originally Posted by Anais
" I see you like threads about racism, you might also like the SMP forum "
fyp
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 06:43 PM
Quote:
Originally Posted by kerowo
What does DaveT think of potatoes though?
I'm not allergic to them, and I love love love eating them.

You have Russet Potatoes
You have Red Potatoes
You have White Potatoes
You have Yellow Potatoes
You have Fingerling Potatoes
You have French Fried Potatoes

You have French Fried Potatoes
You have Oven Baked Potatoes
You have Casserole du Potatoes
You have Seasoned Potatoes
You have Fried Potatoes
You have Chicken a'la King w/ Potatoes
You have Corn & Potatoes
You have Hash Browned Potatoes
You have Deep Fried Potatoes

I love potatoes. Potatoes are the staple of my life.

Quote:
Originally Posted by Anais
" I see you like threads about racism, you might also like the politics forum "
lol.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-28-2014 , 07:00 PM
Quote:
Originally Posted by kerowo
fyp
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m