this post was submitted on 25 Oct 2024
1 points (100.0% liked)

TechTakes

1356 readers
49 users here now

Big brain tech dude got yet another clueless take over at HackerNews etc? Here's the place to vent. Orange site, VC foolishness, all welcome.

This is not debate club. Unless it’s amusing debate.

For actually-good tech, you want our NotAwfulTech community

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 16 hours ago (1 children)

I still cannot believe that they couldn't special-case count 'R' in "strawberry" for their Strawberry model like what the fuck

[–] [email protected] 0 points 10 hours ago (1 children)

Hell, I could probably special-case that shit, and I'm barely a programmer.

[–] [email protected] 0 points 9 hours ago (1 children)

Update: As a matter of fact, I did. Here's some Python code to prove it:

# Counts how many times a particular letter appears in a string.
# Very basic code, made it just to clown on the AI bubble.

appearances = int(0) # Counts how many times the selected char appears.
sentence = input("Write some shit: ")
sentence_length = len(sentence) # We need to know how long the sentence is for later
character_select = input("Select a character: ") # Your input can be as long as you wish, but only the first char will be taken

chosen_char = chr(ord(character_select[0]))

# Three-line version
for i in range (0, sentence_length):
    if chosen_char in sentence[i]:
        appearances = appearances + 1

# Two-line version (doesn't work - not sure why)
# for chosen_char in sentence:
#     appearances = appearances + 1
# (Tested using "strawberry" as sentence and "r" as character_select. Ended up getting a result of 10 ("strawberry" is 10 chars long BTW))
    
# Finally, print the fucking result
print("Your input contains "+str(appearances)+" appearances of the character ("+character_select+").")

There's probably a bug or two in this I missed, but hey, it still proves I'm more of a programmer than Sam Altman ever will be.

[–] [email protected] 0 points 8 hours ago* (last edited 7 hours ago)

the for x in y statement takes iterable y and assigns a value from it to x per iteration (loop), so what happens is that it's reassigning chosen_char each loop to the next item from the sentence

(sum([x for x in sentence if x == chosen_char]) would be a quick one-liner, presuming one has downcased the sentence and other input/safety checks)

(e: this post was in response to your 2-liner comment in the code)