These are chat archives for FreeCodeCamp/Help

30th
Jun 2018
Alexander R Bott
@Abott1222
Jun 30 2018 02:02
integers suck in js
Karma Drukpa
@coderkarma
Jun 30 2018 03:51
@thekholm80 , if there are numbers of in array [ 1, 2 , 3,4,5,2,1,1,23,32,2,2,2]
i have to find the given number how many times has it been repeated?
Kyle Holm
@thekholm80
Jun 30 2018 03:52
do you need to know how many times that number appears in the array? or are you looking for a repeated sequence?
for example, in [ 1, 2 , 3,4,5,2,1,1,23,32,2,2,2] the number 1 appears 3 times, but it is repeated once 1, 1
Karma Drukpa
@coderkarma
Jun 30 2018 03:53
let me sent you how i did
yes ,
parameters (arr, num), so whatever num is invoked the number should be output
Kyle Holm
@thekholm80
Jun 30 2018 03:56
what was your solution?
hensn5250
@hensn5250
Jun 30 2018 03:57
@coderkarma interested in your solution also. Just learned a new way of using .filter that may be helpful.
Karma Drukpa
@coderkarma
Jun 30 2018 03:57
i am sure my way is to off
i am embrassed to paste here
Kyle Holm
@thekholm80
Jun 30 2018 03:58
i want to see it because i still have no idea what you're trying to do
Karma Drukpa
@coderkarma
Jun 30 2018 03:58
okay
hensn5250
@hensn5250
Jun 30 2018 03:58
paste it and you can delete it later using the ... over here ------------------------------------------------> ^^^
Karma Drukpa
@coderkarma
Jun 30 2018 03:59
function countValues(arr, num){
   let count = 0;
     for (let i = 0; i < arr.length; i += 1){
        if ( arr[i] !== arr[i + 1]){
             count = 1;
        } else {
            count +=1;
        }
     }

     return count;
}
// countValues([4,1,4,2,3,4,4], 4) // 4
Kyle Holm
@thekholm80
Jun 30 2018 03:59
oh, okay so you are counting how many times num appears in arr
Karma Drukpa
@coderkarma
Jun 30 2018 03:59
that's wrong one
Kyle Holm
@thekholm80
Jun 30 2018 04:00
i thinkfilter() is a great way to do this
Karma Drukpa
@coderkarma
Jun 30 2018 04:00
since i haven't used num
Kyle Holm
@thekholm80
Jun 30 2018 04:00
return arr.filter(el => el === num).length
Karma Drukpa
@coderkarma
Jun 30 2018 04:00
i can't used filter that is requirement
Kyle Holm
@thekholm80
Jun 30 2018 04:00
ah
your code looks good, but why if ( arr[i] !== arr[i + 1]){ instead of if (arr[i] === num) { ?
and count = 1 will reset your count, not increase it
actually, it all seems kinda off lol
hensn5250
@hensn5250
Jun 30 2018 04:03
yea the method he's using looks more for sorting
Karma Drukpa
@coderkarma
Jun 30 2018 04:04
my codes seems off here i knew it . I wanted to keep track of how many times has number been repeated
Kyle Holm
@thekholm80
Jun 30 2018 04:04
so with just a for loop:
count = 0

loop through array:
  if current array index === num:
    increase count by 1

return count
psudo code
Karma Drukpa
@coderkarma
Jun 30 2018 04:04
that sounds much better.
thanks
oh my god
see this is the reason why i tripped off
so much in alogrithm
that was simple logic right there
thanks kyle
Kyle Holm
@thekholm80
Jun 30 2018 04:06
:+1:
Karma Drukpa
@coderkarma
Jun 30 2018 04:06
give me your brain for next 6 months
i got my coding programing coming up
Kyle Holm
@thekholm80
Jun 30 2018 04:07
when i write complex algos (when i first started, they were all complex lol) i start it off by listing out the steps I think i need in comments, then fill in the code
like
Karma Drukpa
@coderkarma
Jun 30 2018 04:07
I guess doing FCC algorithms helps to understand fundamentals well. i might have to do all .
Kyle Holm
@thekholm80
Jun 30 2018 04:07
// need a counter variable
// need to loop through array
  // check each index to see if it equals num
// return counter
hensn5250
@hensn5250
Jun 30 2018 04:08
same here, do the pseudo-code then fill in actual code
Karma Drukpa
@coderkarma
Jun 30 2018 04:09
even pesudo code doesn't work when i don't understand medium or hard algo.
Kyle Holm
@thekholm80
Jun 30 2018 04:09
then that evolves into
// need a counter variable
let count = 0;
// need to loop through array
for (let i = 0; i < arr.length; i++;) {
  // check each index to see if it equals num
  if (arr[i] === num) counter++;
}
// return counter
return counter;
Karma Drukpa
@coderkarma
Jun 30 2018 04:09
i THINK I MIGHT BECAUSE OF not understanding question properly, failing to think
i know
right
woah!!!
hensn5250
@hensn5250
Jun 30 2018 04:10
@coderkarma It might just be a case of needing more practice. The more you do something the more confident you get doing it.
Kyle Holm
@thekholm80
Jun 30 2018 04:11
yeah
hensn5250
@hensn5250
Jun 30 2018 04:11
Also ask for help as a last resort or once you've hit a road block. Chances are you will likely find a solution quicker by yourself than looking.
Kyle Holm
@thekholm80
Jun 30 2018 04:11
i do a lot of codewars, it's a good way to keep sharp
and i learn a lot
Karma Drukpa
@coderkarma
Jun 30 2018 04:13
I kept saying i need to get my fundamental strong, and i do feel that i know some fundamentals of JS, but i t comes to solving problems, my brain just stop responding , it gets completely blank . In arrow , filter, reduce, map, i am extremely poor
hensn5250
@hensn5250
Jun 30 2018 04:14
Have you programmed with any other language before?
Karma Drukpa
@coderkarma
Jun 30 2018 04:14
no, this is my first language ever
Did some online udemy course on html, css, bootraps,
i feel good about those and
colt's course web development was quite different level, i thorougly enjoyed , still going but it just taking long time.
hensn5250
@hensn5250
Jun 30 2018 04:16
Well JS can be difficult even for people who have programmed with other languages. So if it is your first time know that you are not* alone in the confusion.
Karma Drukpa
@coderkarma
Jun 30 2018 04:16
it's not that i don't like solving problem or language but it's only not getting that sharp brain
Kyle Holm
@thekholm80
Jun 30 2018 04:16
i'd do the freeCodeCamp JS and ES6 lessons
Karma Drukpa
@coderkarma
Jun 30 2018 04:17
sure kyle
Kyle Holm
@thekholm80
Jun 30 2018 04:17
by the time you earn the JS cert you should have a decent understanding of JS
at a high level, anyway
hensn5250
@hensn5250
Jun 30 2018 04:18
@coderkarma what do you use as a reference guide?
Karma Drukpa
@coderkarma
Jun 30 2018 04:18
sure, thank @thekholm80 give me some advices on this
well, currently i am taking online course on udemy and following instructor code along, i feel, i am learning things, but in the meantime , i totally stopped doing alogrithms.
@hensn5250 mdn, ELoquent js
Kyle Holm
@thekholm80
Jun 30 2018 04:20
@coderkarma yeah, happy to help. we all start at the beginning, i remember what it was like
Karma Drukpa
@coderkarma
Jun 30 2018 04:20
speaking JS
But i Don't spend much time in reading book.
hensn5250
@hensn5250
Jun 30 2018 04:22
@coderkarma a good reference for web develment is Mozzilla's MDN WebDoc. You can get them in app form with DevDocs.io ....correction
Kyle Holm
@thekholm80
Jun 30 2018 04:23
i'd be lost without MDN
Karma Drukpa
@coderkarma
Jun 30 2018 04:23
I have committed myself to put 6-8 hours day learning and i have been doing that but not practicing alogrithms
yes i always refer Mdn
hensn5250
@hensn5250
Jun 30 2018 04:24
yes MDN is a true life saver. Makes searching so much easier.
Karma Drukpa
@coderkarma
Jun 30 2018 04:25
dev doc is seems awesome. thanks
Anker
@ankerpeet
Jun 30 2018 05:00

I have this button that calls a javaScript function

<button type="button" onclick="close()">X</button>

This is the javaScript:

function close() {
  console.log("test");
  $(".overlay").css("display","none");
}

can anyone see anything wrong here? I have no idea why its not working. My other javaScript functions are called by clicks just fine

it wont even do my console.log("test")
Claudio Restifo
@Marmiz
Jun 30 2018 05:04
@ankerpeet close is a global window method, try calling it onClose or something like that. Should work :)
Anker
@ankerpeet
Jun 30 2018 05:16
@Marmiz thanks dude!
Claudio Restifo
@Marmiz
Jun 30 2018 05:18
:+1:
Anker
@ankerpeet
Jun 30 2018 05:18
@Marmiz its working now. That was driving me crazy!
Claudio Restifo
@Marmiz
Jun 30 2018 05:27

that's why you'll see many people using a small prefix on functions methods... makes them even clearer to read:

onClose
afterClose
beforeUpdate
afterConfirm
onClick

and so on :)

psyperl
@psyperl
Jun 30 2018 05:35
andSoOn
Claudio Restifo
@Marmiz
Jun 30 2018 06:12
onAndSoOn
which is kinda like Promise.All.then
Henry
@GitHub-Henry
Jun 30 2018 07:02
A bit dated but may help React newbies
aaaaalilili
@aaaaalilili
Jun 30 2018 07:08
<p {font-size: 30px;}>
</p>
why the font of the pragraph don't change?
Karma Drukpa
@coderkarma
Jun 30 2018 07:10
you have to do like this
p { font- size : }
John
@taloloy18
Jun 30 2018 07:24
done
Karma Drukpa
@coderkarma
Jun 30 2018 07:25
nice
John
@taloloy18
Jun 30 2018 07:37
Hi
Your code should set the opacity property to 0.7 on the anchor tags by selecting the class of links.
alpox
@alpox
Jun 30 2018 07:55
@taloloy18 <style> tags are not allowed in the css pane in codepen. Only css goes there. Also, you have text in the css pane which doesn't belong there
Oh, I get it
My code dont run what's the problem?
alpox
@alpox
Jun 30 2018 08:26
@taloloy18 I guess I cannot see what you changed
julien Demarque
@JulienDemarque
Jun 30 2018 08:33
hello! I have a kind of stupid question: what is the name of a div with absolute position that kind of pop up, and that you can close by clicking on a "x"? I am asking because I want to make one, but I was looking if bootstrap has something like this but I can't remember the name....
julien Demarque
@JulienDemarque
Jun 30 2018 08:39
Find it!!! It is called a modal... :)
John
@taloloy18
Jun 30 2018 08:58
Mine is done
Mehdi Amlal
@mehdiamlal
Jun 30 2018 09:05
Hey guys! What do you think is the best approach, using middleware functions or writing all the code inside the route handler?
May Kittens Devour Your Soul
@diomed
Jun 30 2018 09:11
@taloloy18 human, why do you have <style> tags in css window?
delete style tags from css window
John
@taloloy18
Jun 30 2018 09:21
yep, I deleted it already. . human? XD
May Kittens Devour Your Soul
@diomed
Jun 30 2018 09:21
now you should see it all properly :cat:
John
@taloloy18
Jun 30 2018 09:23
Thank you! I was reminded already earlier. :)
Are you done with all the challenges?
May Kittens Devour Your Soul
@diomed
Jun 30 2018 09:35
no. I've done level one
John
@taloloy18
Jun 30 2018 09:40
lol. you're funny
1LifeLess
@1LifeLess
Jun 30 2018 11:26
var printNumTwo;
for (var i = 0; i < 3; i++) {
  if(i === 2){
    printNumTwo = function() {
      return i;
    };
  }
}
console.log(printNumTwo());
// returns 3
Can someone please explain how the I updates to 3?
alpox
@alpox
Jun 30 2018 11:29
@1LifeLess Thats because of the nature of var. When a variable is declared as var (Like i), it gets defined in the functionscope (Or global scope in this case).
This means that the i returned by the function is the value the variable i (in global scope) has at the time of the execution of the function (In the console.log).
This is 3 because thats the value of i after the loop has ended.
1LifeLess
@1LifeLess
Jun 30 2018 11:30
@alpox huuu so the return affect only on the nested function but not on the for loop?
alpox
@alpox
Jun 30 2018 11:34
@1LifeLess a loop does not have a return/return value.
1LifeLess
@1LifeLess
Jun 30 2018 11:35
yeah but you can stop a loop with return/break
@alpox thanks
alpox
@alpox
Jun 30 2018 11:57
@1LifeLess you would stop a loop only with return if the loop is in a function - because then you end the function and return a value from it
Break does not return a value and stops a loop immediately regardless of the context
1LifeLess
@1LifeLess
Jun 30 2018 11:58
@alpox i see thanks a lot
What wrong with my code?
alpox
@alpox
Jun 30 2018 12:35
@taloloy18 wrong for what?
John
@taloloy18
Jun 30 2018 12:45
It's not working. I already added the code
The nav element should have a background-color of the adjusted cyan tone using the hsl() property.
May Kittens Devour Your Soul
@diomed
Jun 30 2018 13:25
what are we cooking here? web template?
hue hue hue :smiling_imp:
Lee Arnold
@nsanity1
Jun 30 2018 14:40
someone up to help a newbie with a error question?
it's about changing the font size lesson for CSS
Kyle Holm
@thekholm80
Jun 30 2018 14:41
sure, what did you try?
Lee Arnold
@nsanity1
Jun 30 2018 14:42
<style>
.red-text {
color: red;
}
p {
font-size: 16px
}
</style>
Kyle Holm
@thekholm80
Jun 30 2018 14:42
you're missing a ; after 16px
Lee Arnold
@nsanity1
Jun 30 2018 14:42
please tell me it's not that simple...lol
Kyle Holm
@thekholm80
Jun 30 2018 14:43
that should do it
Lee Arnold
@nsanity1
Jun 30 2018 14:43
that was it
thanks
Kyle Holm
@thekholm80
Jun 30 2018 14:43
:+1:
Lee Arnold
@nsanity1
Jun 30 2018 14:43
i'm getting better at this, but it definitely is a steep learning curve
Kyle Holm
@thekholm80
Jun 30 2018 14:44
it gets easier, the more you do it
Lee Arnold
@nsanity1
Jun 30 2018 14:44
i bet
tamil12345t
@tamil12345t
Jun 30 2018 15:00
Guys What are the prequesites to learn tensorflow.js
Can someone point me the right direction
Kyle Holm
@thekholm80
Jun 30 2018 15:01
@tamil12345t have you looked at the docs? they have tutorials there
tamil12345t
@tamil12345t
Jun 30 2018 15:02
The thing is I am new to javascript,
Kyle Holm
@thekholm80
Jun 30 2018 15:02
ah, yeah i'd learn JS first
tamil12345t
@tamil12345t
Jun 30 2018 15:03
I know little bit of js now
But to learn tensor flow
Do you need to know algebra and stuffs
Kyle Holm
@thekholm80
Jun 30 2018 15:05
maybe to some extent? the concepts behind tensorflow are fairly advanced, but i suppose you could just dive in and address each missing bit of fundamentals as it arises
tamil12345t
@tamil12345t
Jun 30 2018 15:06
Okay if start with tensorflow js I will be able to pick up right
Kyle Holm
@thekholm80
Jun 30 2018 15:06
i can't say if you will be able to pick it up ... that's entirely up to you. i think if you're willing to put in the work to fill whatever knowledge gaps you have, there is a potential for success
i will say if you get some of the fundamentals out of the way first, you may find it much easier
tamil12345t
@tamil12345t
Jun 30 2018 15:09
Thank you @thekholm80
Ene Catalin
@EneCatalin
Jun 30 2018 15:45
you sure it's that easy ?
pretty sure that's not exactly algebra but linear (college) algebra galore
@tamil12345t if you wanna play with stuff like tensorflow why not use python ?
Kyle Holm
@thekholm80
Jun 30 2018 15:47
i think you can use tensorflow without college level algebra, but i don't know to what extent
Ene Catalin
@EneCatalin
Jun 30 2018 15:48
tbh he can pick up the algebra at least
Kyle Holm
@thekholm80
Jun 30 2018 15:49
at least it's not calculus
Ene Catalin
@EneCatalin
Jun 30 2018 15:49
I mean the basic formulas are meh, tedious at worst
but not hard
I survived linear algebra (no idea how, I can't even divide properly) so that should say something about the difficulty
Kyle Holm
@thekholm80
Jun 30 2018 15:50
lol
I legit failed an exam because I made a wrong division
Kyle Holm
@thekholm80
Jun 30 2018 15:51
i always did well in math, but i never enjoyed it
Ene Catalin
@EneCatalin
Jun 30 2018 15:51
it was an easy "apply stupid formula full of multiplications and divisions" kind of exam (pretty sure it was very similar to L Algebra if it wasn't actually exactly that"
I promptly made a mistake at the start
I always did bad in math and I never enjoyed it either. Now I need to learn it anyway
found out ML rocks
Kyle Holm
@thekholm80
Jun 30 2018 15:52
i've seen some pretty awesome projects done with tensorflow & tensorflow.js
Ene Catalin
@EneCatalin
Jun 30 2018 15:52
I don't really have the time but I wanna get the hang of linear algebra and a bit of probabilty
then python
Kyle Holm
@thekholm80
Jun 30 2018 15:53
i love python
Ene Catalin
@EneCatalin
Jun 30 2018 15:53
yeah, python rocks
I wanna be able to do stuff like this
it's so effing cool
Kyle Holm
@thekholm80
Jun 30 2018 15:55
everyone doing ML that i've spoken to says the hardest part is cleaning/normalizing data for training. that's where it'd be nice to have pandas and numpy, not sure if JS has equivalent libraries
Ene Catalin
@EneCatalin
Jun 30 2018 15:55
ostrich is language racist
it's not about finding an equivalent, it's about not writing JS over python :P
Kyle Holm
@thekholm80
Jun 30 2018 15:55
lol
Ene Catalin
@EneCatalin
Jun 30 2018 15:57
don't you just have a thing about random languages ?
Kyle Holm
@thekholm80
Jun 30 2018 15:57
i like to hate on php
Ene Catalin
@EneCatalin
Jun 30 2018 15:57
oh me too
Kyle Holm
@thekholm80
Jun 30 2018 15:57
it's a hobby of mine
Ene Catalin
@EneCatalin
Jun 30 2018 15:57
had to write two scripts in it recently
holy f
$ $ $ $ $ $ $ $ $
Kyle Holm
@thekholm80
Jun 30 2018 15:58
lol
Ene Catalin
@EneCatalin
Jun 30 2018 15:58
why force me to write that symbol ?
I defined the effing variable already
oh and debugging
dear god
did you know PHP has no native debugging tools ?
you need to set that up
Kyle Holm
@thekholm80
Jun 30 2018 15:59
i've never actually tried php - i think it would diminish my uninformed bias if i learned anything about it
Ene Catalin
@EneCatalin
Jun 30 2018 16:00
you'd just hate it more
the second you needed to debug something and see the hoops you probs need to jump trough
Kyle Holm
@thekholm80
Jun 30 2018 16:00
lol
Ene Catalin
@EneCatalin
Jun 30 2018 16:01
then there's its image libraries
hint: they're shit
php sucks at image processing
Kyle Holm
@thekholm80
Jun 30 2018 16:03
i'm watching an AI play mario kart now
it's insane
Ene Catalin
@EneCatalin
Jun 30 2018 16:03
ikr ?
watched a few of those and decided I need to make stuff like that
too good
Kyle Holm
@thekholm80
Jun 30 2018 16:04
i wonder how much of my job i could automate
then i could get more jobs, automate them, get more ... soon i'd have all the jobs
Ene Catalin
@EneCatalin
Jun 30 2018 16:06
there's also plenty of courses out there for ML
and it's just starting to boom
we still have a solid 1-2 decades to take advantage of it and get bags of cash from it
Kyle Holm
@thekholm80
Jun 30 2018 16:07
ML is the new 'dot com boom'?
Ene Catalin
@EneCatalin
Jun 30 2018 16:07
I mean not every cretin can write ML and get hired
so not really
again, it requires linear algebra, statistics, quite a bit of calculus and a few other random bits of math
but think of it. Big companies that amass insane amounts of data thanks to the way the internet works
they need that data scanned
  • if you can write this stuff you can def make sites/write other kinds of apps
Kyle Holm
@thekholm80
Jun 30 2018 16:10
that's why ML never really got going before now - the amount of data it takes to train a network is enormous
which is why i've never tried it. downloading 500gb of data would be horrible at my connection speeds lol
Ene Catalin
@EneCatalin
Jun 30 2018 16:11
it would take me about one day
or two
Kyle Holm
@thekholm80
Jun 30 2018 16:11
if i weren't cheap i'd get some azure or aws time
Ene Catalin
@EneCatalin
Jun 30 2018 16:12
no idea what that is
Kyle Holm
@thekholm80
Jun 30 2018 16:12
cloud computing, storage, etc
use microsoft or amazon's servers to do all the heavy lifting
Ene Catalin
@EneCatalin
Jun 30 2018 16:18
sounds expensive
Kyle Holm
@thekholm80
Jun 30 2018 16:21
yeah. probably cheaper than building something with xeon processors and a few nvidia teslas though
Ene Catalin
@EneCatalin
Jun 30 2018 16:21
I mean if you're just starting out you probs don't need that much power
i have a friend who plays with ml and for basic projects your average laptop will do
Kyle Holm
@thekholm80
Jun 30 2018 16:25
true - just takes more time
Ene Catalin
@EneCatalin
Jun 30 2018 18:11
can still use it to look over certain sets of data like cancer and stuff like that
May Kittens Devour Your Soul
@diomed
Jun 30 2018 19:46
Xtesla
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:46
hello
anyone here?
May Kittens Devour Your Soul
@diomed
Jun 30 2018 19:48
no. not really
Kyle Holm
@thekholm80
Jun 30 2018 19:48
just the kittens
May Kittens Devour Your Soul
@diomed
Jun 30 2018 19:49
there's a football match in Russia, so every1's watching that. except kittens, of course
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:49
can i get help with challenges
May Kittens Devour Your Soul
@diomed
Jun 30 2018 19:49
yes u can, if u ask. kyle'll help u
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:49
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex.match = /coding/; // Change this line
let result = extractStr; // Change this line
Kyle Holm
@thekholm80
Jun 30 2018 19:51
@Tomato-of-Justice you need to use the match() method
String.match(regex)
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:53
what do you mean
doesn't method go after codingregex
Kyle Holm
@thekholm80
Jun 30 2018 19:53

i mean the instructions say:

Apply the .match() method to extract the word coding.

and you have not done that

oh, i see. no it doesn't go after codingRegex
in their example:
let ourStr = "Regular expressions";  // this is the string
let ourRegex = /expressions/;  // this is the regex
ourStr.match(ourRegex);  // this is using match()
the only thing their example is missing is catching the output of match var someVariable = String.match(regex)
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:56
i am confused
Aditya
@ezioda004
Jun 30 2018 19:56
Maybe hes confused cause .test() syntax is regex.test(str) where its opposite for .match, its string.match(regex).
Kyle Holm
@thekholm80
Jun 30 2018 19:57
maybe
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:57
i usually google the answer and reverse engineer from that
but google has failed me
Kyle Holm
@thekholm80
Jun 30 2018 19:58
sorry, i'm not going to give you the answer
Aditya
@ezioda004
Jun 30 2018 19:58
@thekholm80 I tried that kata, its interesting. Failing the last test.
Kyle Holm
@thekholm80
Jun 30 2018 19:58
mine times out on the second test
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 19:58
where do i apply the method
Kyle Holm
@thekholm80
Jun 30 2018 19:59
i assume it's the second test anyway, my code loops like 500k times
@Tomato-of-Justice did you look at the example code?
see how they used it?
Aditya
@ezioda004
Jun 30 2018 19:59
@thekholm80 Sample test or when you submit?
Kyle Holm
@thekholm80
Jun 30 2018 19:59
@ezioda004 i don't recall for sure
it's been since April lol
Tai An Zhou
@Tomato-of-Justice
Jun 30 2018 20:00
i did
ok maybe i am just too tired now
sigh coding is hard sometimes
Aditya
@ezioda004
Jun 30 2018 20:01
@thekholm80 Lol, I think I know how to solve it but I'm being lazy.
So when you do jnz x steps you can make a new loop with steps iteration and possibly calculate other register values. That way you wont have to run all the previous steps again and again.
Kyle Holm
@thekholm80
Jun 30 2018 20:02
that was where i figured i needed to optimize, to somehow predict the outcome of that rather than just looping through it
Aditya
@ezioda004
Jun 30 2018 20:03
Exactly but implementing that is a bit pain.
Kyle Holm
@thekholm80
Jun 30 2018 20:03
but by that point i was ready to rage quit. and that's what i did lol
i'm only good at writing bad code
Karma Drukpa
@coderkarma
Jun 30 2018 20:04
you are super good @thekholm80
Aditya
@ezioda004
Jun 30 2018 20:05
Theres quite some conditions like what if in steps theres bunch of inc, dec for different variables, what if theres a mov in b/w them. Too many if statments
Kyle Holm
@thekholm80
Jun 30 2018 20:05
@coderkarma haha thanks. this one really kicked my butt though
Aditya
@ezioda004
Jun 30 2018 20:09

@thekholm80 So if

dec b
dec a
jnz a -2 //a = 4, b = 2

Would this code run till a = 0 or b = 0?

Kyle Holm
@thekholm80
Jun 30 2018 20:11
until a = 0
jnz x y - jumps to an instruction y steps away (positive means forward, negative means backward), but only if x (a constant or a register) is not zero
Aditya
@ezioda004
Jun 30 2018 20:12
b would go negative, right?
Kyle Holm
@thekholm80
Jun 30 2018 20:13
yes
Theodore P.
@Ierofantis
Jun 30 2018 20:47
Hi friends
Kyle Holm
@thekholm80
Jun 30 2018 20:48
@Ierofantis :wave:
Theodore P.
@Ierofantis
Jun 30 2018 20:50
After a long time I went to my profile on beta version to see some of my old solutions but I couldnt see any. Also I have three legacy certs from the older fcc version and now I wanted just for fun to complete front end libraries cert. So I completed the last project and I dont know how to claim my cert. Any help on how to find my old solutions and how to claim a cert?Thanks
Kyle Holm
@thekholm80
Jun 30 2018 20:51
if you click on Settings after signing in (or your picture, if you see that instead) then scroll down you should see all the certs there
and also be able to claim any you qualify for but have not yet claimed
Theodore P.
@Ierofantis
Jun 30 2018 20:58
@thekholm80 you are right, thanks :)
Kyle Holm
@thekholm80
Jun 30 2018 20:58
:+1:
May Kittens Devour Your Soul
@diomed
Jun 30 2018 20:59
@thekholm80 have u seen fat porn
Kyle Holm
@thekholm80
Jun 30 2018 20:59
that was a risky click
May Kittens Devour Your Soul
@diomed
Jun 30 2018 20:59
:joy:
they're running out of names, I swear
Kyle Holm
@thekholm80
Jun 30 2018 21:00
lol
maybe they'll make a mono porn and i can replace operator mono in my editor
May Kittens Devour Your Soul
@diomed
Jun 30 2018 21:04
one can dream :smile_cat:
Kyle Holm
@thekholm80
Jun 30 2018 21:40
@ezioda004 what if you looped through the jnz once, compared the values before/after, calculated the number of loops that could run then multiply each register?
Aditya
@ezioda004
Jun 30 2018 21:44
@thekholm80 What is theres a jnz in the previous step? Recursion maybe?
Kyle Holm
@thekholm80
Jun 30 2018 21:44
yeah, you'd just have to calculate the inner jnz the same way
i think it could cut down the number of loops by a ton
well i mean not recursion, just a separate function you can call when a jnz is reached
maybe pass it the current values, the steps involved, etc and it could calculate and return the changes
Aditya
@ezioda004
Jun 30 2018 21:47
I'm close, passed 12 failed 1, yeah I'm doing similarly.
Kyle Holm
@thekholm80
Jun 30 2018 21:47
oh nice
Aditya
@ezioda004
Jun 30 2018 21:48
This is the one thats also timing out, heres ins for it
[ 'mov a 1',
  'mov b 1',
  'mov c 0',
  'mov d 26',
  'jnz c 2',
  'jnz 1 5',
  'mov c 7',
  'inc d',
  'dec c',
  'jnz c -2',
  'mov c a',
  'inc a',
  'dec b',
  'jnz b -2',
  'mov b c',
  'dec d',
  'jnz d -6',
  'mov c 18',
  'mov d 11',
  'inc a',
  'dec d',
  'jnz d -2',
  'dec c',
  'jnz c -5' ]
Kyle Holm
@thekholm80
Jun 30 2018 21:49
oh geez
i'm running it through my code to see how long it takes to complete
Kyle Holm
@thekholm80
Jun 30 2018 21:54
at 30 sec so far lol
1 min 45 sec
geez
Aditya
@ezioda004
Jun 30 2018 21:55
Lol
Must be like atleast 100,000+ iterations there
Kyle Holm
@thekholm80
Jun 30 2018 21:57

i think i logged the iterations for this one:

code = '''\
mov c 12
mov b 0
mov a 200
dec a
inc b
jnz a -2
dec c
mov a b
jnz c -5
jnz 0 1
mov c a'''

and it was over 500k, so i'm guessing that test is well into the millions

Aditya
@ezioda004
Jun 30 2018 22:03
Wew, could use optimization for sure :smile:
Kyle Holm
@thekholm80
Jun 30 2018 22:03
lol
Aditya
@ezioda004
Jun 30 2018 22:07
Ugh I wanna sleep but I know I'll forget my thought process if I dont solve it now.
Kyle Holm
@thekholm80
Jun 30 2018 22:07
lol write some comments
Aditya
@ezioda004
Jun 30 2018 22:08

write some comments

Pff, I like to live on the edge.

Karma Drukpa
@coderkarma
Jun 30 2018 22:20
why @ezioda004
lol
Brian Marquis
@brimarq
Jun 30 2018 23:28
Anyone here free to take a look at my Markdown Previewer? It passes all tests but #6, driving me nuts. Dev tools clearly shows the test is wrong. Does anyone else have this issue with that project?
Oops… I hit enter too soon. Here’s the forum post with the info. https://forum.freecodecamp.org/t/markdown-previewer-fails-test-6-not-detecting-h1-tag-in-preview/205172