Go Back   ZeldaPower Forums > ZeldaPower > General Chat

Reply
 
Thread Tools Display Modes
Old Jul. 18, 2017, 05:16 PM   #1
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 Programming Thread

So some ZPers have expressed an interest in learning to program and I think it's a great idea since software is basically all the US manufactures these days.

This thread is for learning to program, solving problems, and talking architecture.

For background - my programming background is primarily C# but I know enough about JavaScript to shoot myself in the foot and I've played with Python and C++ in the past .
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 18, 2017, 06:28 PM   #2
Jessica
Arsenault
Hero
 
Jessica's Avatar
 
Join Date: Dec. 31, 2001
Posts: 2,999
Default Re: Programming Thread

what's your best fizz buzz
__________________

D - O - G - A - R - S
Jessica is online now   Reply With Quote
Old Jul. 18, 2017, 06:39 PM   #3
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

I should figure out a fizz buzz in assembly for if that ever comes up in an interview. Everybody does fizz buzz in C-ish pseudocode. I want to stand out.
__________________
Pinflan_Jinglewit is offline   Reply With Quote
Old Jul. 18, 2017, 06:50 PM   #4
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

Quote:
Originally Posted by Jessica View Post
what's your best fizz buzz
Well I mean do you want an "Enterprise" style Fizzbuzz where we assume every conditional is a business requirement that could change radically and become ridiculously complicated and therefore decouple the conditions or are you thinking Code Golf or what?
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 18, 2017, 10:05 PM   #5
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

I mean I'd probably do along the lines of

Void main()
{
Var upperlimitString = Console.Readline("How long to fizzbuzz?");

Var upperlimit = Int.Parse(upperlimitString);

For (int i = 1; I < upperlimit; i++)
{
If (Fizzbuzz(I))
{
Console.Writeline("FizzBuzz");
}
Else if (Buzz(I))
{
Console.Writeline("Buzz");
}
Else if (Fizz(i)
{
Console.Writeline("Fizz");
}
Else
{
Console.Writeline(I);
}
}
}



But then the more interesting thing is all the valid permutations of the above.
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 18, 2017, 10:45 PM   #6
Ben
Half a gangster
Platinum Triforce Legend
 
Ben's Avatar
 
Join Date: Feb. 13, 2002
Posts: 23,198
Default Re: Programming Thread

in Java:

Code:
while (true) { System.out.print(Character.toString((char) new Random().nextInt(256))); }
it will eventually print out the FizzBuzz sequence.
__________________


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. 19, 2017, 01:25 PM   #7
Exo
Epically Epic ツ
Hero
 
Exo's Avatar
 
Join Date: Jun. 27, 2006
Location: UK ☂
Posts: 2,802
Default Re: Programming Thread

I'd love to understand coding better! I think I am bit dumb when it comes to stuff like that though lol. I do know a bit of html and bbcode though. But, i guess that is as basic as it gets
__________________
I took a deep breath and listened to the old brag of my heart:

Symuun, Symuun, Symuun..

EXO & Symuun 2006 - 2017 R.I.P
Exo is offline   Reply With Quote
Old Jul. 19, 2017, 02:14 PM   #8
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

So yeah, the FizzBuzz exercise above is a good one to learn with. Basically for a range of numbers, you print the number, unless it's divisble by 3 (print Fizz), 5 (print Buzz), or both 3 and 5 (print FizzBuzz).
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 20, 2017, 03:59 PM   #9
Ben
Half a gangster
Platinum Triforce Legend
 
Ben's Avatar
 
Join Date: Feb. 13, 2002
Posts: 23,198
Default Re: Programming Thread

I decided to do this for real and since I am more of a DB guy I did it in SQL (Oracle):

Code:
select case when mod(r,5*3) = 0 then 'FizzBuzz'
            when mod(r,5) = 0 then 'Buzz'
            when mod(r,3) = 0 then 'Fizz'
            else to_char(r)
       end as "Buzzified"
from (select rownum r
      from dual
      connect by rownum <= 100);
__________________


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. 20, 2017, 05:35 PM   #10
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 that's pretty cool, it never occurred to me that you could do Fizbuzz in DB queries
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 20, 2017, 05:37 PM   #11
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

Also this seems like a great thread https://amp.reddit.com/r/shittyprogr..._it_still_has/
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 20, 2017, 05:43 PM   #12
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

Best FizzBuzz

http://pastebin.com/a6UevGxC
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 20, 2017, 05:49 PM   #13
Ben
Half a gangster
Platinum Triforce Legend
 
Ben's Avatar
 
Join Date: Feb. 13, 2002
Posts: 23,198
Default Re: Programming Thread

Quote:
Originally Posted by Niroht View Post
Also this seems like a great thread https://amp.reddit.com/r/shittyprogr..._it_still_has/
before I clicked that link I thought to myself "the top post will be the enterprise edition". I was not disappointed.
__________________


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. 20, 2017, 06:02 PM   #14
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

I looked at the file structure and one file for that...it's glorious.
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 20, 2017, 09:45 PM   #15
Rachael
Lady Feral
Triforce Legend
 
Rachael's Avatar
 
Join Date: Sep. 22, 2004
Posts: 11,217
Default Re: Programming Thread

Quote:
Originally Posted by Niroht View Post
Ah, brainfuck.
__________________
Rachael is offline   Reply With Quote
Old Jul. 20, 2017, 10:13 PM   #16
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

Even better - JSFuck. You don't even need a special compiler. Also you can hack eBay using it unless they relented and fixed their vulnerability
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 21, 2017, 03:01 PM   #17
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

Here's FizzBuzz in Piet

https://github.com/cheezgi/piet-proj...r/fizzbuzz.png
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 21, 2017, 04:46 PM   #18
Kao
administrator
Platinum Triforce Legend
 
Kao's Avatar
 
Join Date: Mar. 21, 2000
Location: Chicago
Posts: 21,835
Default Re: Programming Thread

C# time!

public void FizzBuzz(int start = 1, int end = 100)
{
String str;
for(int num = start; num <= end; ++num)
{
str = "";
if(num%3 == 0)
str += "Fizz";
if(num%5 == 0)
str += "Buzz";
if(str == "")
str = num;
Console.WriteLine(str);
}
}
Kao is offline   Reply With Quote
Old Jul. 21, 2017, 06:17 PM   #19
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 an interesting take on it.

But what happens when your requirement changes to print "Xyzzy" instead of "Fizzbuzz"?
__________________
t̀h̴̢̧̧͠ę̷́͜ ̛̀͘s̴̀̕͢o̡ņ̵̨͢͡g̶̢̢͡͝ ҉͘ţ̡͏h̴͡
I̮̯̮͈ͮ̀ͥ̐ṭ̜̮̹͕͛ͪ ̧̹̥̫̙͉͂ͯi͓̤̫̤͕̪s̨̽̉ͦ
Niroht is offline   Reply With Quote
Old Jul. 21, 2017, 07:27 PM   #20
Jessica
Arsenault
Hero
 
Jessica's Avatar
 
Join Date: Dec. 31, 2001
Posts: 2,999
Default Re: Programming Thread

perl -l print !($_ % 15) ? "FizzBuzz" : !($_ % 5) ? "Buzz" : !($_ % 3) ? "Fizz" : $_ for 1..100


or better yet


perl -l print $_ % 15 ? $_ % 5 ? $_ % 3 ? $_ : "Fizz" :"Buzz" : "FizzBuzz" for 1..100
__________________

D - O - G - A - R - S

Last edited by Jessica; Jul. 21, 2017 at 07:32 PM.
Jessica is online now   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:57 AM.


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