Giter VIP home page Giter VIP logo

4ever-clojure's Introduction

4ever-clojure

Unfortunately 4clojure is shutting down: https://twitter.com/borkdude/status/1412117420173561861

Original thread that explains why 4clojure is shutting down: https://groups.google.com/g/clojure/c/ZWmDEzvn-Js

Now that 4clojure is shutting down (thanks for all the year of hosting it!), perhaps it's time to consider some alternatives. - borkdude

@borkdude suggested this in his tweet:

Another alternative would be to port it to self-hosted CLJS or sci and host it on Github pages and use localstorage. No need to maintain a running JVM server somewhere that way. Perhaps with the option to download your solutions as an archive.

And so I made it, using the awesome sci and special thanks to 4bb from where I copied the problems edn.

Live

Deployed at https://4clojure.oxal.org/

Solutions archive

You can view the solutions from each individual page eg: https://4clojure.oxal.org/#/problem/102/solutions

The archive repo is available at: https://github.com/oxalorg/4clojure-solutions-archive/

Develop

The easiest way to start up a local server would be to install Babashka and run the dev script defined in bb.edn:

bb dev

Alternatively, you can carry out the instructions of the Babashka script manually:

npm install # only needed once
cp "public/index.template.html" "public/index.html"
npx shadow-cljs watch :my-build

If you are a fan of emacs and cider, then you can open up emacs and run cider-jack-in-cljs. It will automatically start shadow-cljs in watch mode.

shadow hosts the dev server at http://localhost:8000

Test your own version live

You can deploy your own instance via GitHub Actions:

  1. Go to Settings -> Pages
  2. Choose Build and deployment -> Github Actions
  3. Upload your repository or trigger the build

Todos

  • Ship a crude version
  • Make it noice!
  • use localstorage to store solutions
  • easy navigation
  • scrape problem difficulty (can perhaps also get ranks data?)
  • better alerts (modals?)
  • show user which problems they have solved
  • import /export data of the user in a .edn file
  • github actions auto deployment
  • create a new section of problems "community powered questions"
  • add new community problems directly via github

4ever-clojure's People

Contributors

bobbicodes avatar bolivier avatar borkdude avatar coderprans avatar harismh avatar humorless avatar invertisment avatar jeroenvandijk avatar oxalorg avatar pengx17 avatar pradeepbishnoi avatar seanstrom avatar sivakusayan avatar sjongejongejonge avatar whamtet avatar zeniten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

4ever-clojure's Issues

Switch Problems 31 and 30

Here are the solutions that I used for 30 and 31 respectively

30:
#(map first
(partition-by identity %1))
31:
#(partition-by identity %1)

I know that the exercises are all very freeform, but I do think that each problem has a few highly idiomatic solutions (and for these 2 I think the ones I've provided are idiomatic); Since problem 30 builds off of problem 31, I think their order should be switched.

Thank you so much for the 4clojure project!

problem 3 not work

Message Method toUpperCase on function String() { [native code] } not allowed!

Solved counter

Hello and thanks for keeping this amazing exercise collection online!
Would that be too much of a nuisance to add a counter of one's solved problem somewhere on the main page?

Can't eval (lazy-seq [1 2 3])

When evaluating that, the "maximum number of elements reached" is triggered. I believe this is why the exception must be in a lazy seq as well.

Evaluation of wrong arity code results in `pass`

The UI check or eval function is bad because on error (let's say we call ([inc] 1 2 3 4 5)) the custom eval returns a string:

(defn eval-string [source]
  (try (sci/eval-string* context source)
       (catch :default e
         (with-out-str (error-handler source e)))))

This is the code from current version.

Repro:
Go to https://4clojure.oxal.org/#/problem/38 (it will call user's code with multiple args)
Enter [] into the field
Outcome: pass fail pass

A quickfix of if (true? passed?) works when presenting the data but this probably needs to be decided in a better way.

It would be a basic refactoring into some kind of a map or similar thing but this function is used all over the place.

Site is not loading

When trying to access I'm getting:

This site can’t be reached4clojure.oxal.org took too long to respond.
ERR_CONNECTION_TIMED_OUT

Can you please check it out?

improve code input box

  • line numbers would be cool
  • code highlighting? even better
  • auto indenting? or maybe indents with tabs

image

Yeah linting won't work as we do fill in the blanks 🙈

Show link to next unsolved problem after solving problem

I think the "flow" of solving problems can be improved by showing the link to the next unsolved problem, after solving a problem. Or maybe already even before, so you can just navigate to the previous, next and perhaps a random next problem?

Problem 119 - "is"-macro not available

In problem 119:

(is (= (__ :x [[:o :e :e]
the check of the solution fails completely because the is-macro isn't available.

Since this additional step is not needed, it should be omitted.

Edit:
As a workaround I added a definition for it at the begin of my function as a dummy:
(fn [p b] (defn is [arg] args) (...

Implement restrictions

  • Configure such that an error is thrown for restricted functions, probably by using sci deny
  • Show a warning for restricted functions - #14 solves this

Incorrect numbering of exercises or missing exercises

Description:
Incorrect numbering of exercises or missing exercises.
If you go over the numbers of all the exercises, these are the exercises / numbers that are missing:
109, 113, 123, 129, 130, 133, 136, 138, 139, 142, 149, 151, 152, 154, 155, 159, 160, 163-165, 167, 169, 170, 172, 174-176, 178-194

Problem 125 is trivial and not as in 4clojure

The original from 4clojure.com is this:

(= (str '__) (__))

The current one expects a function of two arguments and is badly formatted too:

(= (__ '(fn [x] (__ x x))
                            '(fn [x] (__ x x)))
                       ((fn [x] (__ x x))
                        '(fn [x] (__ x x))))

And it means that = is allowed in the new "complicated" version and not in the original version.
Does this mean that all problems are now different?

It was hard in the original, now it's trivial as one symbol will solve it.

Problem 89 instructions confuse me

(= false (__ [[:a :b] [:a :b] [:a :c] [:c :a]
               [:a :d] [:b :d] [:c :d]]))

So, I am not actually sure what to make of this. I interpreted "unidirectional" to mean that [:a :c] and [:c :a] were the same edge. But if I disregard the two duplicate edges, it seems to me that (d c) (c a) (a d) (d b) (b a) is a valid solution to this. Is the intent that this one is necessarily false because some edges appear twice in the list, and you can't visit them all while only visiting them exactly once, or am I missing something else?

Input Field Not Cleared

When you answer a question and then use the link to go to the next question, your previous answer stays in the answer box.
Even after deleting it and filling in the correct one, the answer isn't accepted.
Refreshing the browser fixed it.
I'm on Firefox.

Keyboard focus gets stuck at code text-area

Goal: I want to submit my exercise answers w/o using a mouse.

Issue: I am unable to Esc or Tab out of the code text-area to the "Run" button to submit my code answers. It might seem that the focus is stuck in the code text-area... but I have the ability to "Tab-Shift" back out in the opposite direction. Is there a keyboard shortcut to submit my exercise answers?

Proposed Solution: Not sure exactly how atm, but, to enable keyboard only navigation and usage of 4ever-clojure. Accessibility fixes and/or keyboard shortcuts could be possible resolution routes.

Would it be helpful for me to investigate potential fixes?

Thank you guys for making 4Clojure continue on!

Ps. I also noticed that the successful exercise submission modal does not trap user focus as it should - this will make the site less accessible for differently abled visitors. There are a few ways to fix this that keep dev work to a minimum while offering maximal accessibility - I'm happy to support as I can!

Errors with problem 87 solutions

In problem 87:

(= (__ 3 4 5 60) '(= (+ (* 3 4) 5) 60))

should be:

(= (__ 3 4 5 60) '(= (* 3 4 5) 60))

and the last two:

(= (__ 1 2 10 100 2001) '(= (+ 1 (* 2 10 100)) 2001)
(= (__ 1 2 10 100 1300) '(= (* (+ 1 2 10) 100) 1300)

are missing an ending parenthesis

clojure.core/format is not accepted in Problem 16

https://4clojure.oxal.org/#/problem/16

#(format "Hello, %s!" %)

is one of [the accepted solutions](https://4clojure.oxal.org/#/problem/16/solutions) but I see the following error. 

#error {:message "Could not resolve symbol: format", :data {:type :sci/error, :line 1, :column 7, :file nil, :phase "analysis"}} 

It works on regular bb

Babashka v0.3.1 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (format "Hello, %s!" "Kenji")
"Hello, Kenji!"

Is it possible to run the tests against the solutions archive?

Lazy load view solutions page

Currently if you open the 'view solutions' of problem 1 - it goes into a frozen state and then after a minute or so it shows up all solutions. Will be good user experience to load first 5-10 solutions and then on scroll down bring the next 10 etc.

https://4clojure.oxal.org/#/problem/1/solutions

Also, can think for creating a Set and remove duplicate solutions. Look at the screenshot with duplicate solution for problem 1 (it might be the case for other as well). Better will be to clean the solutions data one time (remove duplicate) and store it.

image

Can't delete outer paren when testing my own function in REPL

This is on mobile. So there is no Ctrl+-> and delete keys. Also to do character selection I need to use my finger and somehow select a single character.

So not being able to use my backspace gets in the way. Paren matching is great effort but for me it brings frustration only.
For instance let's consider this case:

I'm testing my function to increase a number 5 because I don't yet want to submit the solution because it's not yet correct.
So what I would do is to wrap it into a (__ 5) so that I could test it in the REPL:

((fn [x] (inc x)) 5)

Then I would click Run, close the modal and try to see the result (when I'll find it) (that's also pretty bad).

And then when I want to clean it up (the outer invocation parens) I can't and that's especially bad on mobile.
If I place my cursor here and press backspace then nothing happens and instead it moves to the left by one symbol:

((fn [x] (inc x)) 5)[CURSOR]
->
((fn [x] (inc x)) 5[CURSOR])

So um... that's not good. And then if I want to delete some forms inside I also suffer from this behavior because "unbalanced parens bad".
For me this feels more like I'm forced to do it this way and it's especially bad when I really want to edit very large functions on mobile when I'll do the harder problems.
IMO this hinders the use of this app as only the trivial problems will be attempted at all. Because others will be unusable.

So in that case I end up inserting identity everywhere but that's only useful for small problems. And this is not good (I did do this on original 4clojure Android app but this paren behavior would force me to use it even more).

Why not toggle this? Maybe later on people will understand that they shouldn't delete parens randomly.

Modal doesn't work on mobile

When I try to solve anything on mobile then modal takes the wrong part of the screen.
Why do you want to have that modal at all? Why not display the result inline as the original 4clojure did? It simply worked.

For instance in this screenshot (from my phone) I don't see the result and I can't close the modal because the button it outside of the screen.

This also makes so that you can't simply run commands in the REPL and only when you're happy then you send them to evaluate for the test check. This also hides the results so that you won't be able to see them when you type your code.

Screenshot:
image

If I end up with `(])` in the field I can't delete any paren at all

I don't know how my younger brother ended up with (]) in the field but as it's there he can't delete anything using backspace on mobile phone. So he has to cut or reload the page.
This is related to #64 because it's the same buggy paren deletion prevention.

This is the reason why I don't use plugins like parinfer and other auto paren balancers. They do their job but then they interfere very much.

State related issues & port to re-frame

Going to next problem doesn't reset state properly

The state is already getting a bit messy. I've started a port to re-frame to make this more manageable. Might as well do it now, before it gets too late.

I'm also adding a better way to handle css.

Empty input passed certain problems

Certain problems incorrectly pass with empty inputs, for example Problem 2. If I run the default empty input on Problem 2, I get a successful completion. This exists for several other problems in the lower-tiers but doesn't seem to be a problem in the higher tiers.

Improve stacktrace

I might take a look at this myself, probably SCI could help in exposing the "pretty" stacktrace from babashka and scittle.

Screenshot 2021-07-11 at 21 39 21

Code Editor removed

Looks like there was some code introduced that removed the updated code input editor.

I'll submit something to get that back

Lazily load problem data

The data in data.cljc is effectively JSON / EDN. We don't need to load all this data in the first page load, but only the problem titles. Once you navigate to a problem, you can then load the problem data and show some other solutions when the problem is solved (these solutions could be contributed through PRs). I propose to store every problem in a separate JSON file that can be fetched using an HTTP request to implement this lazy loading.

0/0 Passed!

I'm not sure if this is a bug exactly but it looks weird,

Screenshot from 2022-11-10 15-23-52

This seems to happen when clicking 'Run' and there isn't a popup for tests passing or failing.

Getting a wrong feedback after solving more than one task

Description

Getting a wrong feedback of oh-no although the solution is correct to the current task, after solving more than one task,.
It thinks that the solution is still the the solution you wrote to the previous task.

To Reproduce

  1. Answer correct on a question and clicking run to check the solution, you will get complete!.
  2. Move to the next question
  • The previous answer automatic be shown on the window where you type the answer.
  1. Write the correct answer to the new question and run the solution.
  2. You will get an oh-no, which means that your answer is wrong although it is correct.

this happens both when navigation by changing the url and using the popup of the solution.

Work around

A hard reset to the browser every-time you move to a new question.

Running total of Passed problems

Currently in home page just above problems list there is

Problems (151)

Perhaps the line could report as well the number of totally passed problems like

Problems (151, passed 38)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.