Testing SteemBin

in steembin •  7 years ago  (edited)

Please excuse the dust, just wanted to try out SteemBin. Not too bad. I'd like a way to enter a description/comment before the formatted text so I can give some context to my post. Plus I'd like to be able to add more tags. Right now I'll need to edit my post for a number of reasons including extra tags.

View on SteemBin


//I thought I'd test out SteemBin as I nice way to share code snippets via Steem. This is a Java program from one of my advent of code solutions.

public class Puzzle02a {

    public static void main(String[] args) {
        String input = "3893445835429722678558456317563893861752455542588369533636585887178232467588827193173595918648538852463974393264428538856739259399322741844613957229674619566966921656443476317729968764183945899765294481327998956154956571467872487576314549468261122281384513266834769436913544431258253346374641589492728885222652146158261225296144835682556133922436438188211288458692217737145834468534829945993366314375465767468939773939978272968388546791547526366348163672162245585168892858977723516752284597322176349412485116173844733679871253985762643852151748396593275274582481295864991886985988427966155944392352248314629138972358467959614279553511247863869663526823326467571462371663396188951696286916979923587358992127741723727623235238531991996999181976664226274715591531566495345212849683589582225465555847312199122268773923175183128124556249916458878785361322713513153175157855597289482439449732469754748544437553251412476225415932478849961897299721228198262823515159848941742786272262236888514421279147329383465929358896761449135917829473321834267122759371247338155787774952626616791265889922959653887288735233291968146648533754958199821789499914763279869931218136266492627818972334549751282191883558361871277375851259751294611921756927694394977764633932938573132221389861617195291742156362494769521829599476753198422283287735888197584327719697758442462886311961723849326959213928195182293316227334998926839139915138472514686689887874559367524254175582135318545912361877139367538434683933333264146289842238921989275112323681356256979576948644489986951538689949884787173194457523474156229389465725473817651516136514446513436419126533875125645855223921197481833434658264655912731133356464193251635637423222227273192628825165993827511625956856754776849919858414375874943572889154281862749595896438581889424559988914658387293414662361364793844213298677236787998677166743945812899526292132465751582925131262933636228593134861363493849168168765261647652342891576445292462341171477487223253795935253493869317616741963486473";
        
        int length = input.length();
        int spacing = length/2;
        int sum = 0;
        for (int i=0; i<length; i++) {
            int lastIndex = (i-spacing);
            if(lastIndex < 0) lastIndex+=length;
            int last = Character.getNumericValue(input.charAt(lastIndex));
            int next = Character.getNumericValue(input.charAt(i));
            if(last == next) {
                System.out.println(last);
                sum += last;
            }
            last = next;
        }
        System.out.println(sum);
    }

}

View on SteemBin

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

This post has received a 3.13 % upvote from @speedvoter thanks to: @rantar.