Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Don't worry if you can't figure it out. Go for a walk, take a nap or do something else to distract you. Get a clear mind.
After that you can start working on the problem again.
Also I am very interested in the problem, could you copy paste it please? :) -
karma108457ySome people start their jobs like that 😄🤔 I would not happily exceed the timeframe and focus on actual tasks
-
zymk11027yI should have mentioned that 3.5 of those hours we're outside of work... There's always too much going on to spend that kind of time working on skill building when there are little fires to be put out lol.
I still spent more time than I should have during work hours but not much.
@404response basically the task was to take a given number, it would always be a positive int, and then print out a string of alternating 1's and 0's for as large at the number was. Ex. 7 would process out to a string 1010101. The function will also always start with a 1. -
zymk11027yI thought that maybe a while loop would work, but couldn't figure out how to get it to alternate between 1 and 0... I had a feeling that there needed to be either a division of 2 or a modulo/modulus for it to work right.
-
For Python start I can recommend https://www.codecademy.com
Python is easy to learn hard to master. Basic stuff and buildin libraries are intuitive and well documented. -
Snob20877yIs your problem learning the basics or are you 'failing' at implementing advanced things?
-
@zymk, the python cookbook is an excellent read if you're looking to get going quickly. Starts with basic loops and iteration and ends with c bindings, concurrency and metaclasses and such.
-
zymk11027yIt looks like an acceptable answer for the challenge was something along these lines:
def stringy(size):
return "10" * (size / 2) + "1" * (size % 2)
I had to look up answers to get this. After looking at the answer and breaking it down going backwards I understand what's going on, but I had no idea that you can multiply strings in python...
Feed a positive int to the size variable,
The function first divides the size by 2.
Then perform a modulo on the size.
Then multiplies the string "10" against the first division of size by 2.
Then multiplies "1" by either 0 or 1 depending on the result from the modulo step.
Then lastly adds either a "0" or a "1" to the end of the repeating "10" string.
@wholl0p I think I'm grasping the basics, I understand operators/functions/the different kinds of loops what eludes me is how to actually USE the right combinations of steps to get the results I'm looking for. I definitely know that I have a long way to go with the more advanced stuff. -
zymk11027y@afrometal Thank you, I used codecademy to learn html/css/js so I'm definitely going to hit te codecademy site again. I tried resetting my progress last night for python cause I got about 14% into it and I wanted to start fresh.
@evilmupp3t Thanks, I'll check out the python cookbook cause I think what's eluding me about programming is how to build the correct order of operations or steps to get to a solution. -
@zymk that's terrible code. Python code should read like a book, not some demented scientists formula for string pudding.
My exams was a print, but you could just as easily add the string instead:
s = '' # empty string
for i in range(n) :
s += str(i+1%2)
print(s) -
zymk11027y@evilmupp3t ROFL, that was part of the reason that I wanted to use a while loop or something similar to achieve code that worked but was also something I could look at in a week and still understand immediately what it does. I hear about spaghetti code all the time so I'm trying to learn how to code the right way.
-
Snob20877y@zymk I don't know if links are okay here but I recently used the following app to learn and improve python:
https://play.google.com/store/apps/...
Really good method of learning -
''.join([str((n+1)%2) for _ in range(n)])
Is not time optimal, but easy to read.
import math
'0'.join(['1' for _ in math.ceil(n/2)])
Should be better.
`str.join()` is much faster than string concatenation.
So our company wants us to start learning/sharpening our Python skills for work. We signed up for CodeWars and ran through our first Kata today. I'm excited to learn, but I don't have any actual experience with anything but HTML/CSS and super basic JS for just things like animation... I feel like such a fucking moron trying to work through this Kata. Because our manager wanted us to only spend like 15-20 minutes on it. I spent over 4 hours trying to figure out the right place to even start, even with reading documentation and trying to find similar examples online and after 4 headsmashingly long hours I couldn't even get an idea of how to tackle the problem.
Watching python videos to try and figure this out...
undefined