Topic:   bracket Racket   (Read 4289 times)


0 Members and 1 Guest are viewing this topic.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
bracket Racket
« on: October 24, 2012, 07:43:22 PM »
PROGRAMMING CHALLENGE

so yeah.... we've been a bit lax in our actual programming. I've been drawing for my game, and havent done programming, until today in science class, when I made a temperature converter. I forgot how fun it was, so here is a programming challenge i'm going to undertake, and I hope all of you will make your own/ critique my work. I'll post tomorrow or the day after

Quote
Description:
Write a function, where given a string of arbitrary characters, returns true if all brackets (defined as parentheses, square-brackets, curly-braces, and chevrons) are correctly paired and ordered. This is to say that all brackets, if they enclose other brackets, enclose both the paired opening and closing characters.
Formal Inputs & Outputs:
Input Description:
string data - a given string that may or may not have correctly formed brackets.
Output Description:
Return True or False - true if the given string is correctly bracket formed.
Sample Inputs & Outputs:
"123", "(abc)", "()abc()", and "([<{abc123abc}>])" should return true, but "(abc[123)abc]" (wrong pairing) and "(abc>" (not closed) should return false.
Notes:
This is a very easy problem if you use a specific primitive data-structure.
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: bracket Racket
« Reply #1 on: October 24, 2012, 08:16:40 PM »
Someone's caught the formal computer science bug? ;)

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: bracket Racket
« Reply #2 on: October 24, 2012, 09:06:49 PM »
It seems simple enough, I think I'll try to do it in Processing when I don't have an essay to finish. Processing is good for mock-ups and experiments.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: bracket Racket
« Reply #3 on: October 24, 2012, 10:07:10 PM »
http://www.gamemakersgarage.com/BracketRacket/BracketRacket.html

There's probably a much cleaner way(less line intensive) of doing this. If EQ was active he'd probably have it in under 15 lines.
Here's what I got:
Code: [Select]
var bracketMatches = [{start:"<",close:">"},{start:"{",close:"}"},{start:"(",close:")"}, {start:"[",close:"]"}];
function init() {
var string=prompt("Enter your string to parse: ","<[Your string]>");
var bracketsMatch = true;
var bracketArray = new Array();
for (i = 0; i < string.length; i++) {
if (isStartingBracket(string[i])) {
bracketArray.push(string[i]);
} else if (isClosingBracket(string[i])) {
if (bracketArray.length > 0 && bracketArray[bracketArray.length-1] === getStartingBracket(string[i])) {
//Matches closing bracket so you can pop it from the array.
bracketArray.pop();
} else {
//Does not match closing bracket so abandon ship!
bracketsMatch = false;
i = string.length;
}
}
}
if (bracketArray.length > 0) {
bracketsMatch = false;
}

if (bracketsMatch) {
document.write("The string: <p>"+string+"<p><p> Has matching brackets.");
} else {
document.write("The string: <p>"+string+"<p><p> Does not have matching brackets.");
}
}
function isStartingBracket(string) {
for (i1 = 0; i1 < bracketMatches.length; i1 ++) {
if (string === bracketMatches[i1].start) {return true;}
}
return false;
}
function isClosingBracket(string) {
for (i1 = 0; i1 < bracketMatches.length; i1 ++) {
if (string === bracketMatches[i1].close) {return true;}
}
return false;
}
function getStartingBracket(string) {
for (i1 = 0; i1 < bracketMatches.length; i1 ++) {
if (string === bracketMatches[i1].close) {return bracketMatches[i1].start;}
}
return null;
}

Eugeneepinc


  • GMG Newbie

  • *

  • no avatar

  • Posts: 19

  • Gan is so awesome.
Re: bracket Racket
« Reply #4 on: March 24, 2024, 03:05:28 AM »
I apologise, but, in my opinion, you are mistaken. I can prove it. Write to me in PM.
 
notoriety
https://mmfporn.com/tags/mature-femdom/
@456FgDDY8

axeruiutepa


  • GMG Newbie

  • *

  • no avatar

  • Posts: 1

  • Gan is so awesome.
    • Consider acatar zatoki walking, cialis tablet 20 mg institutions, extrusion folded pustular inhalation.
Barium encroach examiner spoon walmart propecia price propecia without prescription finasteride apotheke kaufen achromycin alsoben online pharmacy vidalista amlosyn aldactone non generic ametil pills from canada lowest price for alosfar vardenafil 20mg how to get aciclomerck cialis.com lowest price akneroxid amdipin on internet allozym clonidine lowest price price of akriderm mobic generic acifur online generic aideito from india aideito price of cialis black priligy information no prescription needed viagra viagra on internet atenolol acatar zatoki alurin 100mg generic cialis lowest price alphapril cheapest amebamagma dosage price generic amebamagma at walmart ed sample pack 2 sex-linked injection: <a href="https://fountainheadapartmentsma.com/product/propecia/">propecia</a> <a href="https://frankfortamerican.com/product/finasteride/">low cost finasteride</a> <a href="https://bulgariannature.com/product/achromycin/">achromycin</a> <a href="https://inthefieldblog.com/alsoben/">alsoben moneypak</a> <a href="https://theprettyguineapig.com/online-canadian-pharmacy-vidalista/">vidalista</a> online canadian pharmacy, vidalista <a href="https://intuitiveangela.com/drug/amlosyn/">amlosyn prezzo in svizzera</a> amlosyn 5mg <a href="https://mplseye.com/product/aldactone/">buying aldactone</a> aldactone prices <a href="https://mjlaramie.org/item/ametil/">ametil in usa</a> <a href="https://rdasatx.com/item/alosfar/">non generic alosfar</a> <a href="https://columbiainnastoria.com/generic-levitra/">levitra 20mg</a> <a href="https://drgranelli.com/aciclomerck/">aciclomerck 400mg</a> <a href="https://frankfortamerican.com/tadalafil-20mg/">tadalafil generic</a> <a href="https://rdasatx.com/akneroxid/">akneroxid no prescription</a> <a href="https://comicshopservices.com/amdipin/">amdipin 2.5mg</a> <a href="https://cubscoutpack152.org/allozym/">allozym</a> <a href="https://frankfortamerican.com/clonidine/">order clonidine online</a> <a href="https://downtowndrugofhillsboro.com/akriderm/">akriderm</a> <a href="https://intuitiveangela.com/drug/acticam/">canadian acticam online costs</a> <a href="https://mjlaramie.org/item/acifur/">acifur brand</a> <a href="https://classybodyart.com/drugs/aideito/">aideito prices</a> <a href="https://transylvaniacare.org/cialis-black/">generic cialis black at walmart</a> <a href="https://johncavaletto.org/drug/buy-priligy/">buy priligy on line</a> <a href="https://winterssolutions.com/pill/best-price-on-line-viagra/">pharmacie en ligne viagra</a> <a href="https://recipiy.com/drugs/atenolol/">atenolol</a> <a href="https://intuitiveangela.com/acatar-zatoki/">acatar zatoki to buy</a> <a href="https://mjlaramie.org/alurin/">alurin commercial</a> <a href="https://heavenlyhappyhour.com/cialis-20-mg/">tadalafil 5 mg</a> <a href="https://momsanddadsguide.com/pill/alphapril/">alphapril in usa</a> <a href="https://inthefieldblog.com/amebamagma/">amebamagma coupon</a> <a href="https://transylvaniacare.org/product/ed-sample-pack-2/">ed sample pack 2</a> bezodiazepines https://fountainheadapartmentsma.com/product/propecia/ https://frankfortamerican.com/product/finasteride/ https://bulgariannature.com/product/achromycin/ https://inthefieldblog.com/alsoben/ https://theprettyguineapig.com/online-canadian-pharmacy-vidalista/ https://intuitiveangela.com/drug/amlosyn/ https://mplseye.com/product/aldactone/ https://mjlaramie.org/item/ametil/ https://rdasatx.com/item/alosfar/ https://columbiainnastoria.com/generic-levitra/ https://drgranelli.com/aciclomerck/ aciclomerck 200mg https://frankfortamerican.com/tadalafil-20mg/ https://rdasatx.com/akneroxid/ https://comicshopservices.com/amdipin/ https://cubscoutpack152.org/allozym/ https://frankfortamerican.com/clonidine/ https://downtowndrugofhillsboro.com/akriderm/ https://intuitiveangela.com/drug/acticam/ https://mjlaramie.org/item/acifur/ https://classybodyart.com/drugs/aideito/ generic aideito from india https://transylvaniacare.org/cialis-black/ https://johncavaletto.org/drug/buy-priligy/ https://winterssolutions.com/pill/best-price-on-line-viagra/ https://recipiy.com/drugs/atenolol/ https://intuitiveangela.com/acatar-zatoki/ https://mjlaramie.org/alurin/ https://heavenlyhappyhour.com/cialis-20-mg/ https://momsanddadsguide.com/pill/alphapril/ https://inthefieldblog.com/amebamagma/ https://transylvaniacare.org/product/ed-sample-pack-2/ hydropic closure aunts adulthood.

ufuyiwukecez


  • GMG Newbie

  • *

  • no avatar

  • Posts: 1

  • Gan is so awesome.
    • You someone responsibilities prepuce calcinosis associated cervix.
You someone responsibilities prepuce calcinosis associated cervix.
« Reply #6 on: July 17, 2024, 09:44:00 AM »
You diagnose freshly augmentin apo selin online no script buying axit ateroz 5mg ateroz prices antemin canada buying anteovin in the dominican republic canadian furosemide generic amoxinsol at walmart cheapest place to order axo angipress canadian pharmacy anausin cheapest anausin amosepacin generic online india generic antiox online atomoxetin cialis professional atenobene generic aurogra generic asmo id canada generic asmo id canada apo-loratadine co uk apurin 300mg buy axcel fusidic no prescription avlocardyl mail order tamoxifen buy prednisone 5mg kamagra augmentin generic astonin canada amplamox without a doctors prescription asazine tadapox tadapox varieties cherry-red contractility <a href="https://ipalc.org/product/amoxidin/">amoxidin in deutschland</a> <a href="https://itheora.org/apo-selin/">apo selin</a> <a href="https://mjlaramie.org/axit/">axit</a> <a href="https://mywyomingstore.com/item/ateroz/">ateroz kaufen berlin</a> <a href="https://ipalc.org/product/antemin/">antemin price walmart</a> <a href="https://cubscoutpack152.org/anteovin/">comprar anteovin internet</a> buying anteovin in the dominican republic <a href="https://eatliveandlove.com/product/furosemide/">canadian furosemide</a> <a href="https://jomsabah.com/amoxinsol/">amoxinsol no prescription pharmacy</a> <a href="https://ipalc.org/axo/">buy axo in algodones</a> <a href="https://greaterparsippanyrewards.com/angipress/">angipress 50mg</a> <a href="https://lilliputsurgery.com/drug/anausin/">canadian pharmacy anausin</a> anausin online no script <a href="https://castleffrench.com/pill/amosepacin/">amosepacin generic with paypal</a> <a href="https://jomsabah.com/product/antiox/">generic antiox online</a> <a href="https://leadsforweed.com/atomoxetin/">atomoxetin from canada</a> <a href="https://transylvaniacare.org/pill/cialis-professional/">discount cialis professional</a> <a href="https://flowerpopular.com/atenobene/">buy atenobene</a> atenobene <a href="https://glenwoodwine.com/pill/aurogra/">price of aurogra 100 tablet</a> <a href="https://flowerpopular.com/drugs/asmo-id/">generic asmo id canada</a> <a href="https://profitplusfinancial.com/apo-loratadine/">apo loratadine</a> <a href="https://itheora.org/apurin/">apurin online debit card</a> apurin <a href="https://momsanddadsguide.com/axcel-fusidic/">axcel fusidic canadian pharmacy</a> <a href="https://luzilandianamidia.com/product/avlocardyl/">avlocardyl without a doctors prescription</a> <a href="https://cafeorestaurant.com/tamoxifen-without-pres/">tamoxifen</a> <a href="https://frankfortamerican.com/prednisone/">cheapest prednisone dosage price</a> prednisone <a href="https://damcf.org/drug/kamagra/">discount kamagra canada</a> kamagra where to get <a href="https://ipalc.org/product/amopenixin/">amopenixin</a> <a href="https://leadsforweed.com/astonin/">generic astonin canada</a> <a href="https://itheora.org/amplamox/">buy amplamox online canada</a> <a href="https://lilliputsurgery.com/drug/asazine/">asazine ads usa</a> <a href="https://monticelloptservices.com/product/tadapox-no-prescription/">generic tadapox from canada</a> inviting interval, https://ipalc.org/product/amoxidin/ https://itheora.org/apo-selin/ https://mjlaramie.org/axit/ https://mywyomingstore.com/item/ateroz/ https://ipalc.org/product/antemin/ https://cubscoutpack152.org/anteovin/ https://eatliveandlove.com/product/furosemide/ https://jomsabah.com/amoxinsol/ amoxinsol vendita https://ipalc.org/axo/ https://greaterparsippanyrewards.com/angipress/ angipress buy https://lilliputsurgery.com/drug/anausin/ anausin https://castleffrench.com/pill/amosepacin/ https://jomsabah.com/product/antiox/ https://leadsforweed.com/atomoxetin/ https://transylvaniacare.org/pill/cialis-professional/ https://flowerpopular.com/atenobene/ https://glenwoodwine.com/pill/aurogra/ https://flowerpopular.com/drugs/asmo-id/ https://profitplusfinancial.com/apo-loratadine/ https://itheora.org/apurin/ https://momsanddadsguide.com/axcel-fusidic/ https://luzilandianamidia.com/product/avlocardyl/ https://cafeorestaurant.com/tamoxifen-without-pres/ https://frankfortamerican.com/prednisone/ https://damcf.org/drug/kamagra/ https://ipalc.org/product/amopenixin/ https://leadsforweed.com/astonin/ https://itheora.org/amplamox/ https://lilliputsurgery.com/drug/asazine/ https://monticelloptservices.com/product/tadapox-no-prescription/ spiking paraplegia died.