create account

RE: Code Wars Python Challenge: Vowel Count by steevc

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @themarkymark/code-wars-python-challenge-vowel-count

· @steevc ·
List comprehensions are cool, but putting everything in one line can make code hard to debug. Starting with a more step by step approach can help validate your algorithm. I notice one of the solutions checks for upper case, but the exercise specified it was all lower case. 

I've been doing a course that uses functional languages where you are discouraged from using loops. That means lots of recursion which can be inefficient in some language, but can make for elegant code.
properties (22)
authorsteevc
permlinkre-themarkymark-qgn3jr
categorycodewithmarky
json_metadata{"tags":["codewithmarky"],"app":"peakd/2020.09.4"}
created2020-09-14 08:28:39
last_update2020-09-14 08:28:39
depth1
children3
last_payout2020-09-21 08:28:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length478
author_reputation1,383,331,593,704,510
root_title"Code Wars Python Challenge: Vowel Count"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,618,849
net_rshares0
@themarkymark · (edited)
List comprehensions are the preferred way to iterate in Python.  It is considered the "Pythonic" way to do things. 

For the upper() you mean the RGB to hex challenge?  I noticed the test output required upper case. The solution also showed uppercase output.  
👍  
👎  
properties (23)
authorthemarkymark
permlinkre-steevc-qgn456
categorycodewithmarky
json_metadata{"tags":["codewithmarky"],"app":"peakd/2020.09.4"}
created2020-09-14 08:41:30
last_update2020-09-14 08:43:12
depth2
children2
last_payout2020-09-21 08:41:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length260
author_reputation1,777,423,768,627,181
root_title"Code Wars Python Challenge: Vowel Count"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,618,961
net_rshares-155,229,000,897
author_curate_reward""
vote details (2)
@steevc ·
From experience I know that writing the shortest code can cause issues when you need to expand functionality later. Need to consider what is best for each case. Sometimes shorter code is not necessarily more efficient. It depends a lot on optimisations done in the compiler or interpreter and they are pretty clever these days.

The one line solution for finding vowels had 

in 'aeiouAEIOU'

but that went beyond the requirement.
properties (22)
authorsteevc
permlinkre-themarkymark-qgn56b
categorycodewithmarky
json_metadata{"tags":["codewithmarky"],"app":"peakd/2020.09.4"}
created2020-09-14 09:03:48
last_update2020-09-14 09:03:48
depth3
children1
last_payout2020-09-21 09:03:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length430
author_reputation1,383,331,593,704,510
root_title"Code Wars Python Challenge: Vowel Count"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,619,171
net_rshares0
@themarkymark ·
Oh I thought you meant one of my solutions so I looked through my older posts lol. 

I agree about shorter code isn't better all the time I've mentioned it in most of my posts. 
👍  
👎  
properties (23)
authorthemarkymark
permlinkre-steevc-qgn5ch
categorycodewithmarky
json_metadata{"tags":["codewithmarky"],"app":"peakd/2020.09.4"}
created2020-09-14 09:07:30
last_update2020-09-14 09:07:30
depth4
children0
last_payout2020-09-21 09:07:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length177
author_reputation1,777,423,768,627,181
root_title"Code Wars Python Challenge: Vowel Count"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,619,202
net_rshares-726,092,088,504
author_curate_reward""
vote details (2)