Go Back   ZeldaPower Forums > ZeldaPower > General Chat

Reply
 
Thread Tools Display Modes
Old Jul. 21, 2017, 08:38 PM   #21
Niroht
h̬̓̉ͧ̔́̚ẻ͊ͪ͊ͯ͌ͥ͡ ̛̜̎̓ͦ͊̈
Triforce of Wisdom
 
Niroht's Avatar
 
Join Date: Aug. 3, 2004
Location: Yes
Posts: 36,192
Send a message via Yahoo to Niroht
Default Re: Programming Thread

Oh that's right perl has really weird ternaries. Also nice on recognizing that fizzbuzz condition is actually %15

I've put what I've got currently for my mobile app on https://github.com/Niroht/LorequestMobile. It's nothing really to speak of right now - just a welcome page and a small map, but hopefully I've got it going in the right places with IOC.
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 21, 2017, 10:07 PM   #22
Pinflan_Jinglewit
Gold Legend
 
Pinflan_Jinglewit's Avatar
 
Join Date: Feb. 13, 2003
Posts: 9,691
Send a message via AIM to Pinflan_Jinglewit
Default Re: Programming Thread

Let's get some prolog up in here.

fizzbuzz(X) :- 0 is X mod 15, write('FizzBuzz').
fizzbuzz(X) :- 0 is X mod 3, write('Fizz').
fizzbuzz(X) :- 0 is X mod 5, write('Buzz').
fizzbuzz(X) :- write(X).

dofizzbuzz :- foreach(between(1, 100, X), (fizzbuzz(X),nl)).

Note: I haven't done anything with prolog since the one assignment I had back in college where I had to use it.
__________________
Pinflan_Jinglewit is offline   Reply With Quote
Old Jul. 21, 2017, 11:52 PM   #23
Ben
Half a gangster
Platinum Triforce Legend
 
Ben's Avatar
 
Join Date: Feb. 13, 2002
Posts: 23,198
Default Re: Programming Thread

why bother with fancy algorithms when you can just google it

Code:
#!/bin/bash
#--------------------------
# FizzBuzz with Google API
#--------------------------

# get my api key and cx from files
API_KEY=`cat my_google_api_key`;
CX=`cat my_cx`;

# ask google politely for the answer
SEARCH_TERMS='what+is+correct+fizz+buzz+output+please'

# build google api url
URL='https://www.googleapis.com/customsearch/v1?key='$API_KEY'&cx='$CX'&q='$SEARCH_TERMS;

# make curl http request to google api and parse json result for links to
# each search result page and put results into array
result_urls=($(curl --silent --url $URL | grep -oP '(?<="link": ").*?(?=",)'));

for result_url in "${result_urls[@]}"
do
   # make curl http request to search result url and get response body
   result_page=$(curl --silent --url $result_url);
   
   # parse response body for something that looks like it might be in the expected format for fizzbuzz sequence.
   # this makes some assumptions about the format - namely that each item in the sequence is on a new line and
   # in a table cell. the fact that one of the confirmed answers from the search results happens to be in this
   # exact format is a complete coincidence and had no impact on the design of this program.
   answer=$(echo "$result_page" | grep -Po "(?i)(?<=>)([0-9]+|FIZZ|BUZZ|FIZZBUZZ)(?=</td>)");
   
   # check if the answer is the expected length
   if [ $(echo "$answer" | wc -l) -eq 100 ]; then
      echo "$answer";
      echo "";
      echo "thank you $result_url";
   fi
   
done

exit 0;
this actually works.



of course it is a little cheap because it only works if the result is in that exact format. but it could be expanded to try other formats like comma delimited lists, etc
__________________


Quote:
Originally Posted by SageofFire View Post
I hope your community rots along with it's rotten users.
Ben is offline   Reply With Quote
Old Jul. 21, 2017, 11:57 PM   #24
Jessica
Arsenault
Hero
 
Jessica's Avatar
 
Join Date: Dec. 31, 2001
Posts: 2,999
Default Re: Programming Thread

it's very polite
__________________

D - O - G - A - R - S
Jessica is online now   Reply With Quote
Old Jul. 22, 2017, 07:44 AM   #25
Niroht
h̬̓̉ͧ̔́̚ẻ͊ͪ͊ͯ͌ͥ͡ ̛̜̎̓ͦ͊̈
Triforce of Wisdom
 
Niroht's Avatar
 
Join Date: Aug. 3, 2004
Location: Yes
Posts: 36,192
Send a message via Yahoo to Niroht
Default Re: Programming Thread

Lolcode Fizzbuzz

Quote:
HAI
CAN HAS STDIO?
I HAS A VAR IZ 0
IM IN YR LOOP
UPZ VAR!!1
IZ VAR BIGR THAN 100?
GTFO.
KTHX
IZ VAR LEFTOVAR 15 LIEK 0?
VISIBLE "FIZZBUZZ"
KTHX
ORLY?
IZ VAR LEFTOVAR 5 LIEK 0?
VISIBLE "BUZZ"
KTHX
ORLY?
IZ VAR LEFTOVAR 3 LIEK 0?
VISIBLE "FIZZ"
KTHX
NOWAI
VISIBLE VAR
KTHX
KTHX
KTHXBYE
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Aug. 28, 2017, 09:58 PM   #26
Niroht
h̬̓̉ͧ̔́̚ẻ͊ͪ͊ͯ͌ͥ͡ ̛̜̎̓ͦ͊̈
Triforce of Wisdom
 
Niroht's Avatar
 
Join Date: Aug. 3, 2004
Location: Yes
Posts: 36,192
Send a message via Yahoo to Niroht
Default Re: Programming Thread

Hey so

We should have a code challenge of some sort.

Maybe Project Euler?
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Oct. 24, 2017, 09:09 PM   #27
Niroht
h̬̓̉ͧ̔́̚ẻ͊ͪ͊ͯ͌ͥ͡ ̛̜̎̓ͦ͊̈
Triforce of Wisdom
 
Niroht's Avatar
 
Join Date: Aug. 3, 2004
Location: Yes
Posts: 36,192
Send a message via Yahoo to Niroht
Default Re: Programming Thread

For anyone interested, I've a couple of demo apps I put together for job applications. They're meant to demonstrate that I know what I'm talking about with like TDD, interfaces, generics, etc so they're a little Enterprisey. Also one I made up to help Phil with some programming homework.

https://github.com/Niroht/MeetingPlanningApp
https://github.com/Niroht/MVVMDemoApp

https://github.com/Niroht/PolygonAreaCalculatorDemo
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:59 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 1999 - 2015 ZeldaPower.com