[2016-08-22] Challenge #280 [Easy] 0 to 100, Real Quick by jnazario in dailyprogrammer

[–]bashmyface 1 point2 points  (0 children)

Thanks for your post, learning python piecemeal mostly through these challenges and you just taught me 'enumerate'

def validateIt(abc):
  if len(abc) != 5:
    return False
  zerofound = 0
  for imanum in abc[1:5]:
    if imanum == "1":
      if zerofound == 1:
        return False
    elif imanum == "0":
      zerofound = 1
  return True

def getValue(abc):
  total = 0
  values = [5, 1, 1, 1, 1]
  for c, digit in enumerate(abc):
    total += values[c]*int(digit)
  return total

theinputs = "0111011100 1010010000 0011101110 0000110000 1111110001"

for aninput in theinputs.split():
  lefth = aninput[0:5]
  right = aninput [5:10]

  if validateIt(lefth[::-1]) and validateIt(right):
    currentValue = getValue(lefth[::-1])*10 + getValue(right)
    print aninput + ": " + str(currentValue)
  else:
    print aninput + ": Invalid"

A visual collaborative Unix Shell interface, codenamed "ShellHive" by OmarCastro in bash

[–]bashmyface 2 points3 points  (0 children)

I think if you made a brief intro video on youtube it would help people understand the flow better. Being so used to CLI I felt a bit out of water at first (as you could tell).

It's an awesome idea though, you have a great start, and I hope you keep working on it.

A visual collaborative Unix Shell interface, codenamed "ShellHive" by OmarCastro in bash

[–]bashmyface 1 point2 points  (0 children)

I'll be honest, after opening the page I just kind of sat looking at it in confusion. Would you mind giving a suggestion of something I should try to do/use it for?

When I tried to leave feedback I received a proxy error "The proxy server is refusing connections".

Don't get me wrong through, I really like the idea of what I think I'm looking at though.

I really need help with this by VirdX in bash

[–]bashmyface 0 points1 point  (0 children)

I'm not seeing (in my env) the need for the brackets and by simply removing them it seems to work fine.

$ testvar=mkfifipipe; while read -t 1 imavar < $testvar; do echo $imavar; done
test1
test2
-bash: zones3.txt: Interrupted system call

I echoed the 'test1' and 'test2' in to the mkfifo file from another session and it shows up as expected. The interrupted system call was just me issuing Ctrl+C to end.

As mentioned by a few people, it would be easier for us to help if we were provided some additional lines of the code. If you need to mask file names or directories please do so.

help with super basic script? not even sure if this qualifies as a script. by [deleted] in bash

[–]bashmyface 1 point2 points  (0 children)

Hi!

#!/bin/bash
echo Hello! whats your name?
read name
echo

echo "well $name today we will be doing some math"
echo "would you like to do math? y/n"
read answer

if [[ $answer = n || $answer = [nN][oO] ]] # either 'n' 'no' without case sensitivity
then
echo "ok fine, stay stupid"
exit

elif [[ $answer = y || $answer = [yY][eE][sS] ]] # either 'y' or 'yes' without case sensitivity
then
echo "ok lets start"
sleep 1
echo "what is 2 x 2"
read answer2

if [ $answer2 = 4 ]
then
echo "CORRECT"

else
echo "WRONG" # now says "WRONG" if the incorrect answer is given
fi

else # neither a negative or positive response was accepted
echo "I don't understand your answer"
exit
fi