Open Side Menu Go to the Top

08-19-2014 , 03:38 PM
Hmmpphhh... guess I'll try making a temp variable that is a list. Then convert that to a string at the end. Thank you!
** 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 **
08-19-2014 , 03:55 PM
All the cool kids use modulo here...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-19-2014 , 04:14 PM
Quote:
Originally Posted by animas
Hmmpphhh... guess I'll try making a temp variable that is a list. Then convert that to a string at the end. Thank you!
I don't know how to do that. lol
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-19-2014 , 04:46 PM
ruby 1 liner:

"abcdefghijklmnopqrstuvwxyz".split('').map{|x| x.next[0]}.map{|x| 'aeiou'.include?(x) ? x.upcase : x}.join
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-19-2014 , 08:41 PM
Respect yo!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 05:08 PM
Some dude built a functional 1KB hard drive in minecraft and it is amazing

http://imgur.com/a/NJBuH
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 05:31 PM
anyone remap capslock to backspace?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 07:17 PM
I have caps lock being control and control remains control so when people take over my keyboard they don't bitch non stop

Scroll lock is caps lock, because I don't think I've ever intentionally touched that key
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 09:07 PM
Quote:
Originally Posted by animas
I don't know how to do that. lol
Second attempt. Still not passing...

Code:
def LetterChanges(str): 

  alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y']
  capital = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y']
  vowel = ['a', 'e', 'i', 'o', 'u', ]
  word = str.split()
  for i in range(len(word)):
    if word[i] == 'z':
      word[i] = 'a'
    else:
      word[i] = alpha[alpha.index(word[i]) + 1]
    if word[i] in vowel:
      word[i] = capital[alpha.index(word[i])]
      
  answer = word.join()
  return answer
      
# keep this function call here  
# to see how to enter arguments in Python scroll down
print LetterChanges(raw_input())
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 09:29 PM
Code:
 => python
Python 2.7.6 (default, Jan 28 2014, 15:43:10)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> str = "someword"
>>> str.split()
['someword']
>>> list(str)
['s', 'o', 'm', 'e', 'w', 'o', 'r', 'd']
>>>
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 09:29 PM
Quote:
Originally Posted by animas
How bad is this? It's a coderbyte challenge and it doesn't pass, but I can't quite figure out why not.

Here are the instructions:



Code:
def LetterChanges(str): 

ref = "abcdefghijklmnopqrstuvwyz"
vowel = "aeiou"
    for i in range(len(str)):
        if str[i] == "z":
          str[i] = "a"
        else:  
          str[i] = ref[ref.index(str[i]) + 1]
        if str[i] in vowel:
          str[i] = str[i].uppercase()
return str
    
# keep this function call here  
# to see how to enter arguments in Python scroll down
print LetterChanges(raw_input())
Your reference string is missing the letter "x"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 09:38 PM
Damnit this is hard lol.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 10:24 PM
Code:
>>> word = 'word'
>>> for letter in word:
...     print(letter)
... 
w
o
r
d
>>>
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 11:01 PM
Quote:
Originally Posted by animas
Second attempt. Still not passing...
What you originally had should work if you create an empty string and then use string.append() instead of trying to change the original string.

I am a noob as well.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 11:16 PM
Wait no I got mixed up, there is no string append. I would create an empty string and then use concatenation:

Code:
def LetterChanges(str): 

ref = "abcdefghijklmnopqrstuvwyz"
vowel = "aeiou"
str2 = ""
    for i in range(len(str)):
        if str[i] == "z":
          str2 = str2 + "a"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 11:56 PM
Quote:
Originally Posted by Larry Legend
Some dude built a functional 1KB hard drive in minecraft and it is amazing

http://imgur.com/a/NJBuH
Awesome. Now all he needs is some NOT, AND, OR and NOR chips and he's got a working computer.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-20-2014 , 11:57 PM
Quote:
Originally Posted by PJo336
I have caps lock being control and control remains control so when people take over my keyboard they don't bitch non stop

Scroll lock is caps lock, because I don't think I've ever intentionally touched that key
The worst is insert. I always pop that key off on any windows keyboard.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-21-2014 , 01:01 AM
Quote:
Originally Posted by suzzer99
The worst is insert. I always pop that key off on any windows keyboard.
i used to think so but i'm starting to find uses for insert key when editing one char or spaced tables for example. backspacing/spacing is a waste of time when i could be overwriting
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-21-2014 , 09:45 PM
Quote:
Originally Posted by daveT
Code:
>>> word = 'word'
>>> for letter in word:
...     print(letter)
... 
w
o
r
d
>>>
Word!

Here's one that scored the maximum amount of points. Not by me, of course.

Code:
def LetterChanges(str): 
  ret = ''
  for ch in str:
    if ch.isalpha():
      ch = chr(ord('a') + (ord(ch) + 1 - ord('a')) % 26)
    if ch in 'aeiou':
      ch = ch.upper()
    ret += ch
  return ret
Takes care of capital letters as well as the z to a transfromation. Mad respect to people who write this kind of ****.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-21-2014 , 10:06 PM
My keyboard doesn't have an "insert", need to numlock-off numpad0 to get it. double-sized "Delete" instead, love it. I activated windows accessibility thing so it beeps PC speaker if I hit caps-lock - that's a great feature too.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2014 , 01:13 AM
Quote:
Originally Posted by animas
Word!

Here's one that scored the maximum amount of points. Not by me, of course.

Code:
def LetterChanges(str): 
  ret = ''
  for ch in str:
    if ch.isalpha():
      ch = chr(ord('a') + (ord(ch) + 1 - ord('a')) % 26)
    if ch in 'aeiou':
      ch = ch.upper()
    ret += ch
  return ret
Takes care of capital letters as well as the z to a transfromation. Mad respect to people who write this kind of ****.
I don't like it. One branch shifts and the second branch converts to upper.

To keep things consistent, the author could have done:

Code:
>>> chr(ord('a') - 32)
'A'
I hate mutating variables in-place like he is with ch. Use a place-holder variable instead, IMO.

[oops]

In light of my above complaints, I offer this alternative, which I think accomplishes the goal of the program and is clearer to understand:

Code:
import string

def silly_function(word):
    s = string.ascii_lowercase
    ans = ''
    v = 'aeiou' ## and sometimes 'y' and 'w', obv.

    for letter in word:
        t = s[s.index(letter) - (len(s) - 1)]
        if t in v:
            t = t.upper()
        ans += t
    return ans

print(silly_function('xyz'))
I didn't check if the item is a letter, but I do think that if a character in the string is not a letter, the function should return an error, not continue on as if everything is normal.

Last edited by daveT; 08-22-2014 at 01:38 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2014 , 01:31 AM
Yesterday, db girl asked me a strange question, and I asked: "Have you ever used a version control system?"

"What's that?"

I began the workday by teaching her the basics of using a local git repo using bash and the GUI (on Windows, sigh). I began with ls, mkdir, touch, add, commit, which she thought was all pretty interesting. Once I showed diff, she was in awe. Then we moved over to the GUI browser and I showed her the commit history and she delighted as only a hacker in the heart could be delighted.

Then she fired off a bunch of questions and I said, "the rest is for you to discover."

"Wow, that's a great way to start the day!"



It felt good to see someone so excited about a tool like that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2014 , 03:07 PM
Code:
t = s[s.index(letter) - (len(s) - 1)]
I'm confused at this part. Say the letter is k. That would make s.index('k') = 10. Len(s)-1 would be 25. So, 10-25, would leave you with s[-15], and I'm not sure about how string.ascii_lowercase works, but... wait, oh ****, I just got it, I think. Nice hand!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2014 , 03:13 PM
Damn I don't think I'll ever be good at programming lol
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-22-2014 , 07:27 PM
let me google that for you

Quote:
Originally Posted by animas
So, 10-25, would leave you with s[-15]
http://lmgtfy.com/?q=python+negative+index

Quote:
, and I'm not sure about how string.ascii_lowercase works,
http://lmgtfy.com/?q=string.ascii_lowercase
** 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