3,386 Posted Topics

Member Avatar for SlzzyDzzy
Member Avatar for M.S.
0
187
Member Avatar for zingwing

0 is smaller than any of your numbers in file, so you should initialize `minVal` to `inputArray[0]` and start for from `i=1`.

Member Avatar for Adak
0
232
Member Avatar for hwoarang69

You can basically treat the appearance of x as command 'add previous number to x-count' and any other not-number as 'add previous number to constant value'. Only thing is that if number was not there, you must default to one for x case, 0 for constant.

Member Avatar for TrustyTony
0
114
Member Avatar for dobermiller

The modules name is turtle (as is not C but pure Python). Try also to not use camelCase but words_with_underscores, if possible. See the [PEP8 paper](http://www.python.org/dev/peps/pep-0008/). Or you must download and install this non-standard module: http://www.cs.ucsb.edu/~pconrad/cs8/topics/cTurtle/ http://www.pythonworks.org/pycontext

Member Avatar for TrustyTony
0
225
Member Avatar for greatman05
Member Avatar for kmg2012

I would not use this code as base but think logic fresh, looks like machine translation of loops to recursion, yak :(! * What is the base case you know to sort? * How you reduce the size of problem to ultimately this base case by recursing?

Member Avatar for TrustyTony
0
241
Member Avatar for bsh6wc

v = "min and max 0.00 1.50" print v.rsplit(' ',2)[-2:] "" Output: ['0.00', '1.50'] """

Member Avatar for TrustyTony
0
134
Member Avatar for adrigreat14

With Exceptions: [CODE]from __future__ import division, print_function def solve(v=None, u=None, a=None, t=None): try: v = u + a*t print('v') except TypeError: try: u = v - a*t print('u') except TypeError: try: a = (v-u) / t print('a') except TypeError: print('t') t = (v-u) / a assert v == u + …

Member Avatar for adrigreat14
0
281
Member Avatar for Despairy

@nbaztec: Your code did not quite run and produce expected result, this was what did give it, after some debug: ~~~ import re garbled_text= '----3.82' pattern = r'(?P<data>[+\-]?(?:(?:\d+\.\d+)|\w+))|(?P<garbage>.)' g = '' for m in re.finditer(pattern, garbled_text): if m.group('data'): print m.group('data'), repr(g) # m.groupdict() will also work g = '' else: …

Member Avatar for nbaztec
0
155
Member Avatar for 4evrmrepylrning
Member Avatar for 4evrmrepylrning
0
281
Member Avatar for nostalgia

We can carry a count with us as we move, this works for movesto(a,e, Dist) but crashes my GNU-Prolog for impossible case movesto(c,e), I do not know what should be changed: ~~~ /*-------------- connections between points --------------*/ link(a,b). link(b,c). link(b,d). link(d,e). /*-------------- logic carried out to connect the movements. --------------*/ …

Member Avatar for nostalgia
0
121
Member Avatar for Sundown G
Member Avatar for JeoSaurus
0
122
Member Avatar for FraidaL

Do [decision tree](http://www.daniweb.com/members/nbaztec/758642/comments) and transform it to if statements after testing the tree with permutattions of 1,2,3,4 and 1,1,1,1 as values to sort.

Member Avatar for TrustyTony
0
3K
Member Avatar for cryonize

>better to swap the data, if this was for a real problem, not an exercise Yes and if you swap data, you must still be quite sure that there is not any other pointers existing to the nodes or you have nightmare to debug. I would think so, no real …

Member Avatar for TrustyTony
0
9K
Member Avatar for Despairy

I am not expert in using re in Python, but could this example I made be relevant? ~~~ import sys import re pattern = re.compile(r'\w+') # process the text of this program as input with open('./file.txt') as inp: text = inp.read() match = re.findall(pattern, text) not_match = re.split(pattern, text) print(match) …

Member Avatar for TrustyTony
0
146
Member Avatar for Mohammad Mateen

See: http://www.daniweb.com/software-development/computer-science/threads/324685/a-brief-introduction-to-big-o-notation-the-big-oh-notation

Member Avatar for TrustyTony
0
135
Member Avatar for Mushy-pea

>Because Daniweb now sucks for pasting code. Good job Daniweb. You can put ~~~ before and after code in separate lines and surround the code with empty lines before and after, then you do not need to indent it.

Member Avatar for TrustyTony
0
120
Member Avatar for Dani

Let me recapitulate simply, how I understand the Dani's plan: 1. Old situation with hierarchy of forums was pain in sitting parts to keep up to date and to choose in the correct subforum. 2. Solution of Dani is simply to remove the subforums and encourage to replace the functionality …

Member Avatar for diafol
0
279
Member Avatar for pansquare

[Picking piece of string between separators](http://www.daniweb.com/software-development/python/code/289548/picking-piece-of-string-between-separators)

Member Avatar for nbaztec
0
241
Member Avatar for felix001

What of [these hints](http://lmgtfy.com/?q=DJANGO_SETTINGS_MODULE+is+undefined) you tried?

Member Avatar for TrustyTony
0
187
Member Avatar for Despairy

I would think that good logic is to find a pair of same values and remove them, what is left is odd number values. Making new sequence could be safer to avoid problems in iterating changing sequence.

Member Avatar for mike_2000_17
0
95
Member Avatar for Sunciti

Can not test with your code as we have not definition of the myriad variables in your dictionary as values or keys, and there is some comma missing but it should be something like: `print({key:d[key].keys() for key in d})` If I put strings instead of your variables, I get: ~~~ …

Member Avatar for TrustyTony
0
1K
Member Avatar for Ordella

You might find some easy enough problems in [Rosetta code](http://rosettacode.org/wiki/Rosetta_Code) You can do your own solution and see the previous Java answer, and compare them.

Member Avatar for Ordella
0
106
Member Avatar for White Eagle

print(['e' if letter == 'e' else '-' for letter in 'elephant']) '''Output: ['e', '-', 'e', '-', '-', '-', '-', '-'] ''' Your code is not tested to work and does not belong to code snippets.

Member Avatar for woooee
0
187
Member Avatar for gourav1
Member Avatar for SCass2010

You are looking for wrong tool, you should use http://docs.python.org/library/optparse.html or preferably the new http://docs.python.org/library/argparse.html#module-argparse for parameter aquisition. That said it is easy to just iterate over the parameters and check which starts right way: ~~~ >>> print next(p for p in cmd.split() if p.startswith('--date')) --date=20120323 ~~~

Member Avatar for TrustyTony
0
184
Member Avatar for evinrocks11

You are messing your changes for help enough, by posting here in Community Feedback. How about messing with a good manual?

Member Avatar for happygeek
-4
22
Member Avatar for felix001

I do not understand, post your Python code to see what you mean. (Paste-paint-push **Code**)

Member Avatar for felix001
0
96
Member Avatar for TrustyTony

Here is my take as code tag police in new era of Daniweb: http://www.daniweb.com/software-development/python/threads/418619/generate-page-using-python Reposted here: Could you repost with new code markup, which is indention by at least 4 spaces, after empty line, so you could do in your python editor: ctrl-A, indent, ctrl-C, undo (or close without saving) …

Member Avatar for Dani
0
253
Member Avatar for woooee

The Edit Post does post edited version, but it need refresh of the page before starting to edit. I have suggested that it should say something else like 'Update the Post' in Community Feedback forum. We unfortunately are left sometime on our own, as the staff is busy to get …

Member Avatar for TrustyTony
0
258
Member Avatar for boiishuvo

Could you repost with new code markup, which is indention by at least 4 spaces, after empty line, so you could do in your python editor: ctrl-A, indent, ctrl-C, undo (or close without saving) and paste it to your post. Or make empty line, paste code, select it by mouse …

Member Avatar for woooee
0
342
Member Avatar for sp85202

You are overcomplicating things, pseudocode: empty sequence has 0 even numbers, other sequences have (1 if first number even else 0 + number of even in rest of sequence) even values

Member Avatar for TrustyTony
0
5K
Member Avatar for Ancient Dragon
Member Avatar for coding101

Even there usually is usually in beginning only simulator for new processor and cross compiler for it running in differfent developing environment if new system is not backwards com

Member Avatar for TrustyTony
0
102
Member Avatar for pakiali007

For example [url]http://www.tutorialspoint.com/python/python_functions.htm[/url] has concise explanation of functions with examples.

Member Avatar for TrustyTony
0
237
Member Avatar for markusd5454
Member Avatar for Gazzmonkey

Looks like you are after the anagrams: http://www.daniweb.com/software-development/python/code/285434/super-simple-one-word-anagrams

Member Avatar for TrustyTony
0
153
Member Avatar for snippsat

Looks like the staff is aware of it and they will return in due course: http://www.daniweb.com/community-center/daniweb-community-feedback/threads/418548/tutorials-listing-/1#post1784617

Member Avatar for TrustyTony
0
103
Member Avatar for CimmerianX

Nice way to get formatted input is to use generator function with for: def get_leases(fn): with open(fn) as lease_file: block = '' for line in lease_file: if block and line.startswith('lease'): yield block block = '' block += line if block: yield block for no, lease in enumerate(get_leases('lease.txt'), 1): print('lease {}:\n{}'.format(no, …

Member Avatar for TrustyTony
0
953
Member Avatar for fistfullofbeer

Do you have some desing plans about the style of information presented? If it is only table, it is not so difficult to only generate the HTML and use [Python for CGI]( http://www.penzilla.net/tutorials/python/cgi/ )).

Member Avatar for TrustyTony
0
167
Member Avatar for maxwellp

You are not returning the value for else branch, the newlist is not really needed, you can check with tail of L. And in real life you would do: [CODE] def has_repeats(L): return len(set(L)) != len(L)[/CODE] with hashable item sequence (no sublists). My solution: [CODE]def has_repeats(L): if len(L) < 2: …

Member Avatar for TrustyTony
0
165
Member Avatar for starkles

Post the code you have, sample input data for the function you are strugling with and current output including the full error messages and desired output. Do not forget to push the `[CODE]` before pasting.

Member Avatar for TrustyTony
0
214
Member Avatar for Yoink

Compare with: [URL="http://rosettacode.org/wiki/Hailstone_sequence#Python"]http://rosettacode.org/wiki/Hailstone_sequence#Python[/URL]

Member Avatar for TrustyTony
0
597
Member Avatar for arty.net

Your code is not indented properly, no, that was just problem with your long lines in mobile screen, I will check it up. Finally the indention was off, you are mixing tabs with spaces, also you are naming functions with Capitalized names, which look like object names due to Python …

Member Avatar for arty.net
0
161
Member Avatar for Niner710

[CODE]>>> import numpy >>> m = numpy.array([4, 6, 8]) >>> m array([4, 6, 8]) >>> print m[-1]+16*m[-2]+16**2*m[-3] 1128 >>> sum(m*[16**2, 16, 1]) 1128 >>> bin(1128) '0b10001101000' >>> [/CODE]

Member Avatar for TrustyTony
0
135
Member Avatar for scott_liddle
Member Avatar for shahulsyed88

Is it your or my homework? [url]http://docs.python.org/tutorial/introduction.html#first-steps-towards-programming[/url]

Member Avatar for TrustyTony
0
40
Member Avatar for welshly_2010

Don't know the structure of your data, but the previous example other way: [CODE]data = "abacc" some_dict={key:[k for k in data if k == key] for key in set(data)} print some_dict [/CODE]

Member Avatar for TrustyTony
0
214
Member Avatar for puddlejumper406

How remarkably similar code compared to [url]http://www.reddit.com/r/Python/comments/qm40j/whats_wrong_with_my_code_python/[/url]

Member Avatar for woooee
0
312
Member Avatar for group256

Two dimensional array as List of list is fine, only problem in it is that you must not use * operation to produce the lines from values, as that produces reference to same value. You seem to be actually planning three dimensional array as in your example you have list …

Member Avatar for group256
0
181

The End.